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

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

From
Jeff King <peff@peff.net>
Date
Mar 24, 2025, 23:46 UTC
Message-ID
<20250324234635.GA789136@coredump.intra.peff.net>
In-Reply-To
<20250324214703.7547-1-taahol@utu.fi>
On Mon, Mar 24, 2025 at 11:47:03PM +0200, Tuomas Ahola wrote:
Show 14 quoted lines
> 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
Previous: Tuomas Ahola
Message 9 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.