Re: [PATCH v3] bulk-checkin: fix sign compare warnings

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

 



On Mon, Mar 24, 2025 at 11:47:03PM +0200, Tuomas Ahola wrote:

> In file bulk-checkin.c, three warnings are emitted by
> "-Wsign-compare", two of which are caused by trivial loop iterator
> type mismatches.  For the third case, the type of `rsize` from
> 
> 			ssize_t rsize = size < sizeof(ibuf) ? size : sizeof(ibuf);
> 
> can be changed to size_t as both options of the ternary expression are
> unsigned and the signedness of the variable isn't really needed
> anywhere.
> 
> To prevent `read_result != rsize` making a clash, it is to be noted
> that `read_result` is checked not to hold negative values.  Therefore
> casting the variable to size_t is a safe operation and enough to
> remove the sign-compare warning.

Thanks, this description (and the matching changes in the patch) look
good to me.

-Peff




[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