aboutsummaryrefslogtreecommitdiffstats
path: root/t/unit-tests
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-12-06 11:27:24 +0100
committerJunio C Hamano <gitster@pobox.com>2024-12-06 20:20:04 +0900
commit80c9e70ebe871f0826bc101142c66ff783405100 (patch)
treec95f04cef2dc0abb2d1fe8e4470e9e385e637b12 /t/unit-tests
parent25435e4ad87aa484ce0d9d2adf3aa407f0241704 (diff)
downloadgit-80c9e70ebe871f0826bc101142c66ff783405100.tar.gz
global: trivial conversions to fix `-Wsign-compare` warnings
We have a bunch of loops which iterate up to an unsigned boundary using a signed index, which generates warnigs because we compare a signed and unsigned value in the loop condition. Address these sites for trivial cases and enable `-Wsign-compare` warnings for these code units. This patch only adapts those code units where we can drop the `DISABLE_SIGN_COMPARE_WARNINGS` macro in the same step. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/unit-tests')
-rw-r--r--t/unit-tests/t-example-decorate.c5
-rw-r--r--t/unit-tests/t-prio-queue.c4
2 files changed, 3 insertions, 6 deletions
diff --git a/t/unit-tests/t-example-decorate.c b/t/unit-tests/t-example-decorate.c
index 61da8e1c8b..bfc776e223 100644
--- a/t/unit-tests/t-example-decorate.c
+++ b/t/unit-tests/t-example-decorate.c
@@ -1,5 +1,4 @@
#define USE_THE_REPOSITORY_VARIABLE
-#define DISABLE_SIGN_COMPARE_WARNINGS
#include "test-lib.h"
#include "object.h"
@@ -43,9 +42,9 @@ static void t_lookup(struct test_vars *vars)
static void t_loop(struct test_vars *vars)
{
- int i, objects_noticed = 0;
+ int objects_noticed = 0;
- for (i = 0; i < vars->n.size; i++) {
+ for (size_t i = 0; i < vars->n.size; i++) {
if (vars->n.entries[i].base)
objects_noticed++;
}
diff --git a/t/unit-tests/t-prio-queue.c b/t/unit-tests/t-prio-queue.c
index a3d1aabab5..a053635000 100644
--- a/t/unit-tests/t-prio-queue.c
+++ b/t/unit-tests/t-prio-queue.c
@@ -1,5 +1,3 @@
-#define DISABLE_SIGN_COMPARE_WARNINGS
-
#include "test-lib.h"
#include "prio-queue.h"
@@ -27,7 +25,7 @@ static void test_prio_queue(int *input, size_t input_size,
struct prio_queue pq = { intcmp };
int j = 0;
- for (int i = 0; i < input_size; i++) {
+ for (size_t i = 0; i < input_size; i++) {
void *peek, *get;
switch(input[i]) {
case GET: