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>

Patrick Steinhardt committed Dec 6, 2024 at 11:27 UTC 47d72a74a737f06791c282a75baf2c573cdf42f6
18 files changed +1 -23
builtin/am.c
-1
@@ -5,7 +5,6 @@
5 */
6
7 #define USE_THE_REPOSITORY_VARIABLE
8 -#define DISABLE_SIGN_COMPARE_WARNINGS
8
9 #include "builtin.h"
10 #include "abspath.h"
builtin/diff-tree.c
-1
@@ -1,5 +1,4 @@
1 #define USE_THE_REPOSITORY_VARIABLE
2 -#define DISABLE_SIGN_COMPARE_WARNINGS
2
3 #include "builtin.h"
4 #include "config.h"
builtin/merge-ours.c
-1
@@ -9,7 +9,6 @@
9 */
10
11 #define USE_THE_REPOSITORY_VARIABLE
12 -#define DISABLE_SIGN_COMPARE_WARNINGS
12
13 #include "git-compat-util.h"
14 #include "builtin.h"
builtin/pack-refs.c
-1
@@ -1,5 +1,4 @@
1 #define USE_THE_REPOSITORY_VARIABLE
2 -#define DISABLE_SIGN_COMPARE_WARNINGS
2
3 #include "builtin.h"
4 #include "config.h"
builtin/range-diff.c
-1
@@ -1,5 +1,4 @@
1 #define USE_THE_REPOSITORY_VARIABLE
2 -#define DISABLE_SIGN_COMPARE_WARNINGS
2
3 #include "builtin.h"
4 #include "gettext.h"
builtin/reflog.c
-1
@@ -1,5 +1,4 @@
1 #define USE_THE_REPOSITORY_VARIABLE
2 -#define DISABLE_SIGN_COMPARE_WARNINGS
2
3 #include "builtin.h"
4 #include "config.h"
builtin/reset.c
-1
@@ -9,7 +9,6 @@
9 */
10
11 #define USE_THE_REPOSITORY_VARIABLE
12 -#define DISABLE_SIGN_COMPARE_WARNINGS
12
13 #include "builtin.h"
14 #include "advice.h"
builtin/revert.c
-1
@@ -1,5 +1,4 @@
1 #define USE_THE_REPOSITORY_VARIABLE
2 -#define DISABLE_SIGN_COMPARE_WARNINGS
2
3 #include "git-compat-util.h"
4 #include "builtin.h"
builtin/shortlog.c
-1
@@ -1,5 +1,4 @@
1 #define USE_THE_REPOSITORY_VARIABLE
2 -#define DISABLE_SIGN_COMPARE_WARNINGS
2
3 #include "builtin.h"
4 #include "config.h"
diff-merges.c
-2
@@ -1,5 +1,3 @@
1 -#define DISABLE_SIGN_COMPARE_WARNINGS
2 -
1 #include "git-compat-util.h"
2 #include "diff-merges.h"
3
diff.h
+1 -2
@@ -205,9 +205,8 @@ static inline void diff_flags_or(struct diff_flags *a,
205 {
206 char *tmp_a = (char *)a;
207 const char *tmp_b = (const char *)b;
208 - int i;
208
210 - for (i = 0; i < sizeof(struct diff_flags); i++)
209 + for (size_t i = 0; i < sizeof(struct diff_flags); i++)
210 tmp_a[i] |= tmp_b[i];
211 }
212
diffcore-order.c
-2
@@ -2,8 +2,6 @@
2 * Copyright (C) 2005 Junio C Hamano
3 */
4
5 -#define DISABLE_SIGN_COMPARE_WARNINGS
6 -
5 #include "git-compat-util.h"
6 #include "gettext.h"
7 #include "diff.h"
diffcore-rotate.c
-2
@@ -3,8 +3,6 @@
3 * Based on diffcore-order.c, which is Copyright (C) 2005, Junio C Hamano
4 */
5
6 -#define DISABLE_SIGN_COMPARE_WARNINGS
7 -
6 #include "git-compat-util.h"
7 #include "gettext.h"
8 #include "diff.h"
list-objects-filter.c
-1
@@ -1,5 +1,4 @@
1 #define USE_THE_REPOSITORY_VARIABLE
2 -#define DISABLE_SIGN_COMPARE_WARNINGS
2
3 #include "git-compat-util.h"
4 #include "dir.h"
patch-ids.c
-2
@@ -1,5 +1,3 @@
1 -#define DISABLE_SIGN_COMPARE_WARNINGS
2 -
1 #include "git-compat-util.h"
2 #include "diff.h"
3 #include "commit.h"
reachable.c
-1
@@ -1,5 +1,4 @@
1 #define USE_THE_REPOSITORY_VARIABLE
2 -#define DISABLE_SIGN_COMPARE_WARNINGS
2
3 #include "git-compat-util.h"
4 #include "gettext.h"
reflog-walk.c
-1
@@ -1,5 +1,4 @@
1 #define USE_THE_REPOSITORY_VARIABLE
2 -#define DISABLE_SIGN_COMPARE_WARNINGS
2
3 #include "git-compat-util.h"
4 #include "commit.h"
t/helper/test-revision-walking.c
-1
@@ -9,7 +9,6 @@
9 */
10
11 #define USE_THE_REPOSITORY_VARIABLE
12 -#define DISABLE_SIGN_COMPARE_WARNINGS
12
13 #include "test-tool.h"
14 #include "commit.h"