From 51c3385e3736aeb5f78cc9ed193779e2cb4a2a29 Mon Sep 17 00:00:00 2001 From: shejialuo Date: Mon, 6 Oct 2025 14:32:40 +0800 Subject: string-list: change "string_list_find_insert_index" return type to "size_t" As "string_list_find_insert_index" is a simple wrapper of "get_entry_index" and the return type of "get_entry_index" is already "size_t", we could simply change its return type to "size_t". Update all callers to use size_t variables for storing the return value. The tricky fix is the loop condition in "mailmap.c" to properly handle "size_t" underflow by changing from `0 <= --i` to `i--`. Remove "DISABLE_SIGN_COMPARE_WARNINGS" from "mailmap.c" as it's no longer needed with the proper unsigned types. Signed-off-by: shejialuo Signed-off-by: Junio C Hamano --- mailmap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'mailmap.c') diff --git a/mailmap.c b/mailmap.c index 58a4484963..37fd158a51 100644 --- a/mailmap.c +++ b/mailmap.c @@ -1,5 +1,4 @@ #define USE_THE_REPOSITORY_VARIABLE -#define DISABLE_SIGN_COMPARE_WARNINGS #include "git-compat-util.h" #include "environment.h" @@ -244,7 +243,7 @@ static struct string_list_item *lookup_prefix(struct string_list *map, const char *string, size_t len) { bool exact_match; - int i = string_list_find_insert_index(map, string, &exact_match); + size_t i = string_list_find_insert_index(map, string, &exact_match); if (exact_match) { if (!string[len]) return &map->items[i]; @@ -266,7 +265,7 @@ static struct string_list_item *lookup_prefix(struct string_list *map, * overlong key would be inserted, which must come after the * real location of the key if one exists. */ - while (0 <= --i && i < map->nr) { + while (i-- && i < map->nr) { int cmp = strncasecmp(map->items[i].string, string, len); if (cmp < 0) /* -- cgit v1.3-5-g9baa