git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Karthik NayakNext: Tuomas Ahola
Message 7 of 9 in “bulk-checkin: fix sign compare warnings”
  1. bulk-checkin: fix sign compare warningsTuomas Ahola, Mar 21, 2025
  2. Karthik NayakMar 21, 2025
  3. bulk-checkin: fix sign compare warningsTuomas Ahola, Mar 21, 2025
  4. Junio C HamanoMar 23, 2025
  5. Jeff KingMar 24, 2025
  6. Karthik NayakMar 24, 2025
  7. Jeff KingMar 24, 2025
  8. bulk-checkin: fix sign compare warningsTuomas Ahola, Mar 24, 2025
  9. Jeff KingMar 24, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.