]> Kevux Git Server - rit/commitdiff
diff.h: fix index used to loop through unsigned integer
authorPatrick Steinhardt <ps@pks.im>
Fri, 6 Dec 2024 10:27:21 +0000 (11:27 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 6 Dec 2024 11:20:03 +0000 (20:20 +0900)
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>
18 files changed:
builtin/am.c
builtin/diff-tree.c
builtin/merge-ours.c
builtin/pack-refs.c
builtin/range-diff.c
builtin/reflog.c
builtin/reset.c
builtin/revert.c
builtin/shortlog.c
diff-merges.c
diff.h
diffcore-order.c
diffcore-rotate.c
list-objects-filter.c
patch-ids.c
reachable.c
reflog-walk.c
t/helper/test-revision-walking.c

index f3b6546..1338b60 100644 (file)
@@ -5,7 +5,6 @@
  */
 
 #define USE_THE_REPOSITORY_VARIABLE
-#define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
 #include "abspath.h"
index a4df2d0..40804e7 100644 (file)
@@ -1,5 +1,4 @@
 #define USE_THE_REPOSITORY_VARIABLE
-#define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
 #include "config.h"
index 3672c63..3ecd917 100644 (file)
@@ -9,7 +9,6 @@
  */
 
 #define USE_THE_REPOSITORY_VARIABLE
-#define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
 #include "builtin.h"
index 71175a7..4fdd688 100644 (file)
@@ -1,5 +1,4 @@
 #define USE_THE_REPOSITORY_VARIABLE
-#define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
 #include "config.h"
index aa88a46..433c305 100644 (file)
@@ -1,5 +1,4 @@
 #define USE_THE_REPOSITORY_VARIABLE
-#define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
 #include "gettext.h"
index 08e99a2..95f2649 100644 (file)
@@ -1,5 +1,4 @@
 #define USE_THE_REPOSITORY_VARIABLE
-#define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
 #include "config.h"
index f34d221..73b4537 100644 (file)
@@ -9,7 +9,6 @@
  */
 
 #define USE_THE_REPOSITORY_VARIABLE
-#define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
 #include "advice.h"
index 4b57c2c..aca6c29 100644 (file)
@@ -1,5 +1,4 @@
 #define USE_THE_REPOSITORY_VARIABLE
-#define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
 #include "builtin.h"
index 1c46f13..30075b6 100644 (file)
@@ -1,5 +1,4 @@
 #define USE_THE_REPOSITORY_VARIABLE
-#define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
 #include "config.h"
index 0adfe7f..4550758 100644 (file)
@@ -1,5 +1,3 @@
-#define DISABLE_SIGN_COMPARE_WARNINGS
-
 #include "git-compat-util.h"
 #include "diff-merges.h"
 
diff --git a/diff.h b/diff.h
index 5c8de79..6e6007c 100644 (file)
--- 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];
 }
 
index ec59d3d..f91ef22 100644 (file)
@@ -2,8 +2,6 @@
  * Copyright (C) 2005 Junio C Hamano
  */
 
-#define DISABLE_SIGN_COMPARE_WARNINGS
-
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "diff.h"
index 941a022..67b5912 100644 (file)
@@ -3,8 +3,6 @@
  * Based on diffcore-order.c, which is Copyright (C) 2005, Junio C Hamano
  */
 
-#define DISABLE_SIGN_COMPARE_WARNINGS
-
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "diff.h"
index 4afa302..dc598a0 100644 (file)
@@ -1,5 +1,4 @@
 #define USE_THE_REPOSITORY_VARIABLE
-#define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
 #include "dir.h"
index 8b89198..a5683b4 100644 (file)
@@ -1,5 +1,3 @@
-#define DISABLE_SIGN_COMPARE_WARNINGS
-
 #include "git-compat-util.h"
 #include "diff.h"
 #include "commit.h"
index 34079e1..3e9b3dd 100644 (file)
@@ -1,5 +1,4 @@
 #define USE_THE_REPOSITORY_VARIABLE
-#define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
 #include "gettext.h"
index b53628e..c7070b1 100644 (file)
@@ -1,5 +1,4 @@
 #define USE_THE_REPOSITORY_VARIABLE
-#define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
 #include "commit.h"
index 3b931a3..071f5bd 100644 (file)
@@ -9,7 +9,6 @@
  */
 
 #define USE_THE_REPOSITORY_VARIABLE
-#define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "test-tool.h"
 #include "commit.h"