mirror of
https://github.com/git/git
synced 2024-08-27 11:39:22 +00:00
read-cache: use size_t for {base,df}_name_compare()
Support names of any length in base_name_compare() and df_name_compare() by using size_t for their length parameters. They pass the length on to memcmp(3), which also takes it as a size_t. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
844ede312b
commit
1b4a38d741
6
cache.h
6
cache.h
|
@ -1609,8 +1609,10 @@ int repo_interpret_branch_name(struct repository *r,
|
|||
|
||||
int validate_headref(const char *ref);
|
||||
|
||||
int base_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);
|
||||
int df_name_compare(const char *name1, int len1, int mode1, const char *name2, int len2, int mode2);
|
||||
int base_name_compare(const char *name1, size_t len1, int mode1,
|
||||
const char *name2, size_t len2, int mode2);
|
||||
int df_name_compare(const char *name1, size_t len1, int mode1,
|
||||
const char *name2, size_t len2, int mode2);
|
||||
int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
|
||||
int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);
|
||||
|
||||
|
|
13
read-cache.c
13
read-cache.c
|
@ -488,11 +488,11 @@ int ie_modified(struct index_state *istate,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int base_name_compare(const char *name1, int len1, int mode1,
|
||||
const char *name2, int len2, int mode2)
|
||||
int base_name_compare(const char *name1, size_t len1, int mode1,
|
||||
const char *name2, size_t len2, int mode2)
|
||||
{
|
||||
unsigned char c1, c2;
|
||||
int len = len1 < len2 ? len1 : len2;
|
||||
size_t len = len1 < len2 ? len1 : len2;
|
||||
int cmp;
|
||||
|
||||
cmp = memcmp(name1, name2, len);
|
||||
|
@ -517,11 +517,12 @@ int base_name_compare(const char *name1, int len1, int mode1,
|
|||
* This is used by routines that want to traverse the git namespace
|
||||
* but then handle conflicting entries together when possible.
|
||||
*/
|
||||
int df_name_compare(const char *name1, int len1, int mode1,
|
||||
const char *name2, int len2, int mode2)
|
||||
int df_name_compare(const char *name1, size_t len1, int mode1,
|
||||
const char *name2, size_t len2, int mode2)
|
||||
{
|
||||
int len = len1 < len2 ? len1 : len2, cmp;
|
||||
unsigned char c1, c2;
|
||||
size_t len = len1 < len2 ? len1 : len2;
|
||||
int cmp;
|
||||
|
||||
cmp = memcmp(name1, name2, len);
|
||||
if (cmp)
|
||||
|
|
Loading…
Reference in a new issue