From: Jonathan Nieder <jrnieder@gmail.com>
To: AreaZR via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, AreaZR <gfunni234@gmail.com>,
Seija Kijin <doremylover123@gmail.com>
Subject: Re: [PATCH] git: use U to denote unsigned to prevent UB
Date: Thu, 2 Jan 2025 16:43:43 +0100 [thread overview]
Message-ID: <Z3a0LzChuIzmr7jw@google.com> (raw)
In-Reply-To: <pull.1849.git.git.1734488549111.gitgitgadget@gmail.com>
Hi,
Seija Kijin wrote:
> 1 << can be UB if 1 ends up overflowing and
> being assigned to an unsigned int or long.
>
> Signed-off-by: Seija Kijin <doremylover123@gmail.com>
> ---
> builtin/checkout.c | 2 +-
> builtin/merge-tree.c | 4 ++--
> builtin/receive-pack.c | 2 +-
> color.c | 4 ++--
> delta-islands.c | 2 +-
> diff-delta.c | 2 +-
> diff.c | 2 +-
> help.c | 2 +-
> imap-send.c | 2 +-
> merge-ort.c | 18 +++++++++---------
> xdiff/xhistogram.c | 2 +-
> xdiff/xprepare.c | 4 ++--
> 12 files changed, 23 insertions(+), 23 deletions(-)
That said, most of these don't overflow, so it's not obvious this
results in higher quality or more readable code than before the patch.
By "not obvious" I don't mean that it _doesn't_, by the way, but just
that we don't have enough information to evaluate it here. What
motivated writing this patch? Is there a style guideline about it
that will remind us not to backslide in the future, for example? Or
is there a tool that notices? Was there an example you ran into that
led you to look for more examples?
This kind of information about context will make it easier for other
in the project to ensure the patch does what it intends, and even more
importantly, to see if there are additional checks to add or other
instances that also need updating.
Thanks and hope that helps,
Jonathan
next prev parent reply other threads:[~2025-01-02 15:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-18 2:22 [PATCH] git: use U to denote unsigned to prevent UB AreaZR via GitGitGadget
2025-01-02 15:43 ` Jonathan Nieder [this message]
2025-01-02 21:33 ` Junio C Hamano
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=Z3a0LzChuIzmr7jw@google.com \
--to=jrnieder@gmail.com \
--cc=doremylover123@gmail.com \
--cc=gfunni234@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
/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 NNTP newsgroup(s).