Do not use memcmp(sha1_1, sha1_2, 20) with hardcoded length.
Introduces global inline: hashcmp(const unsigned char *sha1, const unsigned char *sha2) Uses memcmp for comparison and returns the result based on the length of the hash name (a future runtime decision). Acked-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
committed by
Junio C Hamano
parent
d4baf9eaf4
commit
a89fccd281
@ -378,7 +378,7 @@ static int unresolve_one(const char *path)
|
||||
ret = -1;
|
||||
goto free_return;
|
||||
}
|
||||
if (!memcmp(ce_2->sha1, ce_3->sha1, 20) &&
|
||||
if (!hashcmp(ce_2->sha1, ce_3->sha1) &&
|
||||
ce_2->ce_mode == ce_3->ce_mode) {
|
||||
fprintf(stderr, "%s: identical in both, skipping.\n",
|
||||
path);
|
||||
@ -460,7 +460,7 @@ static int do_reupdate(int ac, const char **av,
|
||||
old = read_one_ent(NULL, head_sha1,
|
||||
ce->name, ce_namelen(ce), 0);
|
||||
if (old && ce->ce_mode == old->ce_mode &&
|
||||
!memcmp(ce->sha1, old->sha1, 20)) {
|
||||
!hashcmp(ce->sha1, old->sha1)) {
|
||||
free(old);
|
||||
continue; /* unchanged */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user