Skip to content

Commit dab24e4

Browse files
ttaylorrgitster
authored andcommitted
builtin/repack.c: avoid unnecessary numeric casts in existing_packs
There are a couple of spots that cause warnings within the existing_packs API without DISABLE_SIGN_COMPARE_WARNINGS under DEVELOPER=1 mode. In both cases, we have int values that are being compared against size_t ones. Neither of these two cases are incorrect, and the cast is completely OK in practice. But both are unnecessary, since: - in existing_packs_mark_for_deletion_1(), 'hexsz' should be defined as a size_t anyway, since algop->hexsz is. - in existing_packs_collect(), 'i' should be defined as a size_t since it is counting up to the value of a string_list's 'nr' field. (This patch is a little bit of noise, but I would rather see us squelch these warnings ahead of moving the existing_packs API into a separate compilation unit to avoid having to define DISABLE_SIGN_COMPARE_WARNINGS in repack.c.) Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 9574e8f commit dab24e4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

builtin/repack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static void existing_packs_mark_for_deletion_1(const struct git_hash_algo *algop
156156
struct string_list *list)
157157
{
158158
struct string_list_item *item;
159-
const int hexsz = algop->hexsz;
159+
const size_t hexsz = algop->hexsz;
160160

161161
for_each_string_list_item(item, list) {
162162
char *sha1;
@@ -250,7 +250,7 @@ static void existing_packs_collect(struct existing_packs *existing,
250250
struct strbuf buf = STRBUF_INIT;
251251

252252
for (p = packfile_store_get_all_packs(packs); p; p = p->next) {
253-
int i;
253+
size_t i;
254254
const char *base;
255255

256256
if (!p->pack_local)

0 commit comments

Comments
 (0)