Merge branch 'rs/use-xstrncmpz'

Code clean-up.

* rs/use-xstrncmpz:
  use xstrncmpz()
This commit is contained in:
Junio C Hamano
2024-02-26 18:10:24 -08:00
10 changed files with 38 additions and 16 deletions

View File

@ -136,8 +136,7 @@ static int anonymized_entry_cmp(const void *cmp_data UNUSED,
a = container_of(eptr, const struct anonymized_entry, hash);
if (keydata) {
const struct anonymized_entry_key *key = keydata;
int equal = !strncmp(a->orig, key->orig, key->orig_len) &&
!a->orig[key->orig_len];
int equal = !xstrncmpz(a->orig, key->orig, key->orig_len);
return !equal;
}

View File

@ -192,8 +192,7 @@ static struct strategy *get_strategy(const char *name)
int j, found = 0;
struct cmdname *ent = main_cmds.names[i];
for (j = 0; !found && j < ARRAY_SIZE(all_strategy); j++)
if (!strncmp(ent->name, all_strategy[j].name, ent->len)
&& !all_strategy[j].name[ent->len])
if (!xstrncmpz(all_strategy[j].name, ent->name, ent->len))
found = 1;
if (!found)
add_cmdname(&not_strategies, ent->name, ent->len);

View File

@ -96,8 +96,7 @@ static struct reflog_expire_cfg *find_cfg_ent(const char *pattern, size_t len)
reflog_expire_cfg_tail = &reflog_expire_cfg;
for (ent = reflog_expire_cfg; ent; ent = ent->next)
if (!strncmp(ent->pattern, pattern, len) &&
ent->pattern[len] == '\0')
if (!xstrncmpz(ent->pattern, pattern, len))
return ent;
FLEX_ALLOC_MEM(ent, pattern, pattern, len);