use xstrncmpz()
Add and apply a semantic patch for calling xstrncmpz() to compare a NUL-terminated string with a buffer of a known length instead of using strncmp() and checking the terminating NUL explicitly. This simplifies callers by reducing code duplication. I had to adjust remote.c manually because Coccinelle inexplicably changed the indent of the else branches. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
3526e67d91
commit
f0e578c69c
@ -1028,7 +1028,7 @@ static int read_convert_config(const char *var, const char *value,
|
||||
if (parse_config_key(var, "filter", &name, &namelen, &key) < 0 || !name)
|
||||
return 0;
|
||||
for (drv = user_convert; drv; drv = drv->next)
|
||||
if (!strncmp(drv->name, name, namelen) && !drv->name[namelen])
|
||||
if (!xstrncmpz(drv->name, name, namelen))
|
||||
break;
|
||||
if (!drv) {
|
||||
CALLOC_ARRAY(drv, 1);
|
||||
|
Reference in New Issue
Block a user