From: Jeff King <peff@peff.net>
To: Tuomas Ahola <taahol@utu.fi>
Cc: git@vger.kernel.org, karthik.188@gmail.com, gitster@pobox.com
Subject: Re: [PATCH v3] bulk-checkin: fix sign compare warnings
Date: Mon, 24 Mar 2025 19:46:35 -0400 [thread overview]
Message-ID: <20250324234635.GA789136@coredump.intra.peff.net> (raw)
In-Reply-To: <20250324214703.7547-1-taahol@utu.fi>
On Mon, Mar 24, 2025 at 11:47:03PM +0200, Tuomas Ahola wrote:
> 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
prev parent reply other threads:[~2025-03-24 23:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-21 20:07 [PATCH] bulk-checkin: fix sign compare warnings Tuomas Ahola
2025-03-21 21:08 ` Karthik Nayak
2025-03-21 22:14 ` [PATCH v2] " Tuomas Ahola
2025-03-23 22:08 ` Junio C Hamano
2025-03-24 2:53 ` [PATCH] " Jeff King
2025-03-24 19:48 ` Karthik Nayak
2025-03-24 20:13 ` Jeff King
2025-03-24 21:47 ` [PATCH v3] " Tuomas Ahola
2025-03-24 23:46 ` Jeff King [this message]
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=20250324234635.GA789136@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=karthik.188@gmail.com \
--cc=taahol@utu.fi \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).