Skip to content

Commit 47d72a7

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4f9264b commit 47d72a7

18 files changed

+1
-23
lines changed

builtin/am.c

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66

77
#define USE_THE_REPOSITORY_VARIABLE
8-
#define DISABLE_SIGN_COMPARE_WARNINGS
98

109
#include "builtin.h"
1110
#include "abspath.h"

builtin/diff-tree.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#define USE_THE_REPOSITORY_VARIABLE
2-
#define DISABLE_SIGN_COMPARE_WARNINGS
32

43
#include "builtin.h"
54
#include "config.h"

builtin/merge-ours.c

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*/
1010

1111
#define USE_THE_REPOSITORY_VARIABLE
12-
#define DISABLE_SIGN_COMPARE_WARNINGS
1312

1413
#include "git-compat-util.h"
1514
#include "builtin.h"

builtin/pack-refs.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#define USE_THE_REPOSITORY_VARIABLE
2-
#define DISABLE_SIGN_COMPARE_WARNINGS
32

43
#include "builtin.h"
54
#include "config.h"

builtin/range-diff.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#define USE_THE_REPOSITORY_VARIABLE
2-
#define DISABLE_SIGN_COMPARE_WARNINGS
32

43
#include "builtin.h"
54
#include "gettext.h"

builtin/reflog.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#define USE_THE_REPOSITORY_VARIABLE
2-
#define DISABLE_SIGN_COMPARE_WARNINGS
32

43
#include "builtin.h"
54
#include "config.h"

builtin/reset.c

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*/
1010

1111
#define USE_THE_REPOSITORY_VARIABLE
12-
#define DISABLE_SIGN_COMPARE_WARNINGS
1312

1413
#include "builtin.h"
1514
#include "advice.h"

builtin/revert.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#define USE_THE_REPOSITORY_VARIABLE
2-
#define DISABLE_SIGN_COMPARE_WARNINGS
32

43
#include "git-compat-util.h"
54
#include "builtin.h"

builtin/shortlog.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#define USE_THE_REPOSITORY_VARIABLE
2-
#define DISABLE_SIGN_COMPARE_WARNINGS
32

43
#include "builtin.h"
54
#include "config.h"

diff-merges.c

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#define DISABLE_SIGN_COMPARE_WARNINGS
2-
31
#include "git-compat-util.h"
42
#include "diff-merges.h"
53

diff.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,8 @@ static inline void diff_flags_or(struct diff_flags *a,
205205
{
206206
char *tmp_a = (char *)a;
207207
const char *tmp_b = (const char *)b;
208-
int i;
209208

210-
for (i = 0; i < sizeof(struct diff_flags); i++)
209+
for (size_t i = 0; i < sizeof(struct diff_flags); i++)
211210
tmp_a[i] |= tmp_b[i];
212211
}
213212

diffcore-order.c

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
* Copyright (C) 2005 Junio C Hamano
33
*/
44

5-
#define DISABLE_SIGN_COMPARE_WARNINGS
6-
75
#include "git-compat-util.h"
86
#include "gettext.h"
97
#include "diff.h"

diffcore-rotate.c

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
* Based on diffcore-order.c, which is Copyright (C) 2005, Junio C Hamano
44
*/
55

6-
#define DISABLE_SIGN_COMPARE_WARNINGS
7-
86
#include "git-compat-util.h"
97
#include "gettext.h"
108
#include "diff.h"

list-objects-filter.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#define USE_THE_REPOSITORY_VARIABLE
2-
#define DISABLE_SIGN_COMPARE_WARNINGS
32

43
#include "git-compat-util.h"
54
#include "dir.h"

patch-ids.c

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#define DISABLE_SIGN_COMPARE_WARNINGS
2-
31
#include "git-compat-util.h"
42
#include "diff.h"
53
#include "commit.h"

reachable.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#define USE_THE_REPOSITORY_VARIABLE
2-
#define DISABLE_SIGN_COMPARE_WARNINGS
32

43
#include "git-compat-util.h"
54
#include "gettext.h"

reflog-walk.c

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#define USE_THE_REPOSITORY_VARIABLE
2-
#define DISABLE_SIGN_COMPARE_WARNINGS
32

43
#include "git-compat-util.h"
54
#include "commit.h"

t/helper/test-revision-walking.c

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*/
1010

1111
#define USE_THE_REPOSITORY_VARIABLE
12-
#define DISABLE_SIGN_COMPARE_WARNINGS
1312

1413
#include "test-tool.h"
1514
#include "commit.h"

0 commit comments

Comments
 (0)