diff options
author | Rene Scharfe <rene.scharfe@lsrfire.ath.cx> | 2006-08-11 14:01:45 +0200 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-08-11 16:06:34 -0700 |
commit | 5bb1cda5f73988963e7470f3cd75a380751f6d99 (patch) | |
tree | 550b8a6f962d816b7fa0e796d1c5d1f4037d0375 /verify-pack.c | |
parent | ca9e3b124f6313187da641b5cd55100c4ade6a9a (diff) | |
download | git-5bb1cda5f73988963e7470f3cd75a380751f6d99.tar.gz git-5bb1cda5f73988963e7470f3cd75a380751f6d99.tar.xz |
drop length argument of has_extension
As Fredrik points out the current interface of has_extension() is
potentially confusing. Its parameters include both a nul-terminated
string and a length-limited string.
This patch drops the length argument, requiring two nul-terminated
strings; all callsites are updated. I checked that all of them indeed
provide nul-terminated strings. Filenames need to be nul-terminated
anyway if they are to be passed to open() etc. The performance penalty
of the additional strlen() is negligible compared to the system calls
which inevitably surround has_extension() calls.
Additionally, change has_extension() to use size_t inside instead of
int, as that is the exact type strlen() returns and memcmp() expects.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'verify-pack.c')
-rw-r--r-- | verify-pack.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/verify-pack.c b/verify-pack.c index f440a3967..357970da3 100644 --- a/verify-pack.c +++ b/verify-pack.c @@ -16,10 +16,10 @@ static int verify_one_pack(const char *path, int verbose) * In addition to "foo.idx" we accept "foo.pack" and "foo"; * normalize these forms to "foo.idx" for add_packed_git(). */ - if (has_extension(arg, len, ".pack")) { + if (has_extension(arg, ".pack")) { strcpy(arg + len - 5, ".idx"); len--; - } else if (!has_extension(arg, len, ".idx")) { + } else if (!has_extension(arg, ".idx")) { if (len + 4 >= PATH_MAX) return error("name too long: %s.idx", arg); strcpy(arg + len, ".idx"); |