summaryrefslogtreecommitdiffstats
path: root/path.c
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 12:20:04 +0100
commit80c9e70ebe871f0826bc101142c66ff783405100 (patch)
treec95f04cef2dc0abb2d1fe8e4470e9e385e637b12 /path.c
parentpkt-line: fix -Wsign-compare warning on 32 bit platform (diff)
downloadgit-80c9e70ebe871f0826bc101142c66ff783405100.tar.xz
git-80c9e70ebe871f0826bc101142c66ff783405100.zip
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 'path.c')
-rw-r--r--path.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/path.c b/path.c
index 1f21004804..b4be7581aa 100644
--- a/path.c
+++ b/path.c
@@ -3,7 +3,6 @@
*/
#define USE_THE_REPOSITORY_VARIABLE
-#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "abspath.h"
@@ -1141,12 +1140,12 @@ int strbuf_normalize_path(struct strbuf *src)
*/
int longest_ancestor_length(const char *path, struct string_list *prefixes)
{
- int i, max_len = -1;
+ int max_len = -1;
if (!strcmp(path, "/"))
return -1;
- for (i = 0; i < prefixes->nr; i++) {
+ for (size_t i = 0; i < prefixes->nr; i++) {
const char *ceil = prefixes->items[i].string;
int len = strlen(ceil);