Re: [PATCH v2 4/8] string-list: enable sign compare warnings check
- From
Patrick Steinhardt <ps@pks.im>
- Date
- May 19, 2025, 07:18 UTC
- Message-ID
- <aCrbKz6tr0vj7ytY@pks.im>
- In-Reply-To
- <aCoDY4A62uWb-_MV@ArchLinux>
On Sun, May 18, 2025 at 11:57:23PM +0800, shejialuo wrote:
Show 8 quoted lines
> The only sign compare warning in "string-list" is that we compare the > `index` of the `int` type with the `list->nr` of unsigned type. We get > index by calling "get_entry_index", which would always return unsigned > index. > > Let's change the return type of "get_entry_index" to be "size_t" by > slightly modifying the binary search algorithm. Instead of letting > "left" to be "-1" initially, assign 0 to it.
It would help the reader to explain why this change is equivalent to how it worked before.
Patrick