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

Re: [PATCH] connect: address -Wsign-compare warnings

From
Mike Hommey <mh@glandium.org>
Date
Jan 17, 2025, 21:18 UTC
Message-ID
<20250117211830.75prk6e2u3qlatwt@glandium.org>
In-Reply-To
<xmqqo705mjw7.fsf@gitster.g>
On Fri, Jan 17, 2025 at 09:26:32AM -0800, Junio C Hamano wrote:
Show 25 quoted lines
> Mike Hommey <mh@glandium.org> writes:
> 
> > Most of the warnings were about loop variables being declared as ints
> > with a condition using a size_t, whereby switching the variable to
> > size_t fixes the warning.
> >
> > One other case was comparing the result of strlen to an int passed
> > as an argument, which turns out could just as well be passed as a
> > size_t, albeit trickling to other functions.
> 
> As long as the blast radius is limited (like this one, which most of
> the cascades were within the callchain of file-scope statics), and
> the changes of type is going in the right direction (in this case, I
> see all are using size_t for length that may come from or compared
> with the result of strlen(), which falls into that category), such a
> change is very much welcomed.
> 
> Even if the primary objective is to squelch the -Wsign-compare and
> even if we are talking about a line in packet_reader object, which
> would not exceed 64k bytes and using size_t is way overkill, that
> is.  I personally do not think -Wsign-compare cleanliness is buying
> us all that much, compared to the amount of code churn.  But this
> one is well within the level that I can tolerate ;-).
> 
> Will queue.  Thanks.
Do you want me to address Patrick's comments?
Mike
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 6 in “connect: address -Wsign-compare warnings”
  1. connect: address -Wsign-compare warningsMike Hommey, Jan 17, 2025
  2. Patrick SteinhardtJan 17, 2025
  3. Junio C HamanoJan 17, 2025
  4. Mike HommeyJan 17, 2025
  5. Junio C HamanoJan 17, 2025
  6. Patrick SteinhardtJan 20, 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.