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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 19, 2025 at 09:18:03AM +0200, Patrick Steinhardt wrote:
> 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.
> 

Right, will improve this.

> Patrick




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux