From: Junio C Hamano <gitster@pobox.com>
To: Mike Hommey <mh@glandium.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] connect: address -Wsign-compare warnings
Date: Fri, 17 Jan 2025 09:26:32 -0800 [thread overview]
Message-ID: <xmqqo705mjw7.fsf@gitster.g> (raw)
In-Reply-To: <20250117074909.1430067-1-mh@glandium.org> (Mike Hommey's message of "Fri, 17 Jan 2025 16:49:09 +0900")
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.
next prev parent reply other threads:[~2025-01-17 17:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-17 7:49 [PATCH] connect: address -Wsign-compare warnings Mike Hommey
2025-01-17 9:36 ` Patrick Steinhardt
2025-01-17 17:26 ` Junio C Hamano [this message]
2025-01-17 21:18 ` Mike Hommey
2025-01-17 21:21 ` Junio C Hamano
2025-01-20 7:58 ` Patrick Steinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqo705mjw7.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=mh@glandium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.