Re: [PATCH] bulk-checkin: fix sign compare warnings
- From
Jeff King <peff@peff.net>
- Date
- Mar 24, 2025, 20:13 UTC
- Message-ID
- <20250324201343.GA777700@coredump.intra.peff.net>
- In-Reply-To
- <CAOLa=ZRkzp6A+S-bqbUMnkovazrczFi=B8tG06xqTzsNQB2enA@mail.gmail.com>
On Mon, Mar 24, 2025 at 07:48:59PM +0000, Karthik Nayak wrote:
Show 13 quoted lines
> > However, if you switch it, then we get a different -Wsign-compare
> > problem: we compare "rsize" and "read_result". So you still have to
> > cast, but at a different spot.
>
> True. But this would be better in my regards, since this would directly
> follow the
>
> if (read_result < 0)
> die_errno("failed to read from '%s'", path);
>
> code, so a `if ((size_t)read_result != rsize)` here makes logical sense
> since we can clearly see that this section is only reached when
> `read_result` has a positive value.Yeah, agreed. And after doing that, it's probably the right stopping point for this patch.
I do think the safe_scast() thing could be a good general tool for this kind of case, but I'd rather not hold up an immediate fix for it.
-Peff