Re: [PATCH] bulk-checkin: fix sign compare warnings
From: Jeff King <hidden>
Date: 2025-03-24 20:13:45
From: Jeff King <hidden>
Date: 2025-03-24 20:13:45
On Mon, Mar 24, 2025 at 07:48:59PM +0000, Karthik Nayak wrote:
quoted
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