Re: [PATCH 3/4] string-list: change "string_list_find_insert_index" return type to "size_t"
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Sep 9, 2025, 06:23 UTC
- Message-ID
- <aL_HySU6d1a9qIBf@pks.im>
- In-Reply-To
- <aL21_e9B8aCpPRyX@ArchLinux>
On Mon, Sep 08, 2025 at 12:42:37AM +0800, shejialuo wrote:
> As "string_list_find_insert_index" is a simple wrapper of > "get_entry_index", we could simply change its return type to "size_t".
The missing connecting piece is that `get_entry_index()` itself already returns a `size_t`.
Show 10 quoted lines
> diff --git a/mailmap.c b/mailmap.c
> index 253517cdf6..0168342650 100644
> --- a/mailmap.c
> +++ b/mailmap.c
> @@ -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-- > 0 && i < map->nr) {This could simply be `while (i-- && i < map->nr)`.
Patrick