Re: [PATCH] general style: replaces memcmp() with starts_with()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 12.03.2014 14:44, schrieb Quint Guvernator:
> memcmp() is replaced with starts_with() when comparing strings from the
> beginning. starts_with() looks nicer and it saves the extra argument of
> the length of the comparing string.
> 
> Signed-off-by: Quint Guvernator <quintus.public@xxxxxxxxx>
> ---

...

> diff --git a/submodule.c b/submodule.c
> index b80ecac..1edebc1 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -203,7 +203,7 @@ void gitmodules_config(void)
>  			if (active_nr > pos) {  /* there is a .gitmodules */
>  				const struct cache_entry *ce = active_cache[pos];
>  				if (ce_namelen(ce) == 11 &&
> -				    !memcmp(ce->name, ".gitmodules", 11))
> +				    !starts_with(ce->name, ".gitmodules"))
>  					gitmodules_is_unmerged = 1;
>  			}
>  		} else if (pos < active_nr) {

I think this hunk should be dropped as the memcmp() here doesn't mean
"starts with" but "is identical" (due to the "ce_namelen(ce) == 11" in
the line above).
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]