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 <shejialuo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
shejialuo
2025-10-06 14:32:40 +08:00
committed by Junio C Hamano
parent e8a32e766f
commit 51c3385e37
5 changed files with 14 additions and 11 deletions

View File

@@ -222,7 +222,7 @@ static void find_unique_prefixes(struct prefix_item_list *list)
static ssize_t find_unique(const char *string, struct prefix_item_list *list)
{
bool exact_match;
int index = string_list_find_insert_index(&list->sorted, string, &exact_match);
size_t index = string_list_find_insert_index(&list->sorted, string, &exact_match);
struct string_list_item *item;
if (list->items.nr != list->sorted.nr)