Git development
 help / color / mirror / Atom feed
From: "Kristoffer Haugsbakk" <code@khaugsbakk.name>
To: "Ramsay Jones" <ramsay@ramsayjones.plus.com>
Cc: "GIT Mailing-list" <git@vger.kernel.org>,
	"Junio C Hamano" <gitster@pobox.com>
Subject: Re: [PATCH] name-rev: fix an 'may be used uninitialized' error
Date: Sun, 03 May 2026 20:52:00 +0200	[thread overview]
Message-ID: <66710fd7-23bb-4b1f-852a-f61ea1f188e0@app.fastmail.com> (raw)
In-Reply-To: <e74a8fd8-0617-46a8-8bef-a454d51a99c1@ramsayjones.plus.com>

On Sun, May 3, 2026, at 17:16, Ramsay Jones wrote:
> Today's seen branch fails to build (with DEVELOPER=1), like so:
>
>       CC builtin/name-rev.o
>   builtin/name-rev.c: In function ‘cmd_format_rev’:
>   builtin/name-rev.c:885:28: error: ‘commit’ may be used uninitialized
> [-Werror=maybe-uninitialized]
>     885 |                         if (!commit) {
>         |                            ^
>   builtin/name-rev.c:867:40: note: ‘commit’ was declared here
>     867 |                         struct commit *commit;
>         |                                        ^~~~~~
>   cc1: all warnings being treated as errors
>   make: *** [Makefile:2932: builtin/name-rev.o] Error 1
>
> This can be fixed in several ways; initialise the 'commit' variable to
> NULL (on line 867), initialise 'commit' to NULL on the line before the
> conditional on line 883, or (as I chose here) initialise the 'commit'
> variable in an else arm of the conditional.
>
> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
> ---
>
> Hi Kristoffer,
>
> I wrote this patch yesterday, just before I had to go out, and didn't
> get around to sending it to the list. Today, the problem has gone
> away ... (along with the 'kh/name-rev-custom-format' branch)!
>
> Assuming you will be sending a new version soon, ... could you please
> squash this (or similar) into the patch corresponding to commit 5903855b1c
> ("format-rev: introduce builtin for on-demand pretty formatting", 2026-04-29).
>
> Note that I don't think this particular fix is better than any other, it
> was just that my cursor was on that line in vim ... :)
>
> ATB,
> Ramsay Jones

I’ll incorporate it. Thank you!

>
>  builtin/name-rev.c | 2 ++
>  1 file changed, 2 insertions(+)
>
>[snip]

  reply	other threads:[~2026-05-03 18:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-03 15:16 [PATCH] name-rev: fix an 'may be used uninitialized' error Ramsay Jones
2026-05-03 18:52 ` Kristoffer Haugsbakk [this message]
2026-05-04  1:13 ` Junio C Hamano
2026-05-04  8:55   ` Kristoffer Haugsbakk
2026-05-04 20:26   ` Ramsay Jones
2026-05-04 21:56     ` Kristoffer Haugsbakk
2026-05-05  0:41       ` Ramsay Jones
2026-05-05 19:09         ` Kristoffer Haugsbakk

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=66710fd7-23bb-4b1f-852a-f61ea1f188e0@app.fastmail.com \
    --to=code@khaugsbakk.name \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=ramsay@ramsayjones.plus.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