summaryrefslogtreecommitdiff
path: root/diff.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-12-06 11:27:21 +0100
committerJunio C Hamano <gitster@pobox.com>2024-12-06 20:20:03 +0900
commit47d72a74a737f06791c282a75baf2c573cdf42f6 (patch)
treeb5c04796ba6e418f79f9621bff13900442e956b3 /diff.h
parent4f9264b0cdf588745ebd71638a216e626b89df35 (diff)
diff.h: fix index used to loop through unsigned integer
The `struct diff_flags` structure is essentially an array of flags, all of which have the same type. We can thus use `sizeof()` to iterate through all of the flags, which we do in `diff_flags_or()`. But while the statement returns an unsigned integer, we used a signed integer to iterate through the flags, which generates a warning. Fix this by using `size_t` for the index instead. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.h')
-rw-r--r--diff.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/diff.h b/diff.h
index 5c8de79535..6e6007c17b 100644
--- a/diff.h
+++ b/diff.h
@@ -205,9 +205,8 @@ static inline void diff_flags_or(struct diff_flags *a,
{
char *tmp_a = (char *)a;
const char *tmp_b = (const char *)b;
- int i;
- for (i = 0; i < sizeof(struct diff_flags); i++)
+ for (size_t i = 0; i < sizeof(struct diff_flags); i++)
tmp_a[i] |= tmp_b[i];
}