Thread (47 messages) 47 messages, 3 authors, 2025-07-04

Re: [PATCH v2 4/8] string-list: enable sign compare warnings check

From: Patrick Steinhardt <hidden>
Date: 2025-05-19 07:18:06

On Sun, May 18, 2025 at 11:57:23PM +0800, shejialuo wrote:
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help