git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Ramsay Jones <ramsay@ramsayjones.plus.com>
Cc: Junio C Hamano <gitster@pobox.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	GIT Mailing-list <git@vger.kernel.org>
Subject: Re: [PATCH 2/2] read-cache: fix an -Wmaybe-uninitialized warning
Date: Wed, 21 Mar 2018 01:59:44 -0400	[thread overview]
Message-ID: <20180321055944.GA15719@sigill.intra.peff.net> (raw)
In-Reply-To: <e3894650-3639-c871-1291-f3efa7fbea0a@ramsayjones.plus.com>

On Tue, Mar 20, 2018 at 10:52:16PM +0000, Ramsay Jones wrote:

> > Maybe too clever, but I think you could just do:
> > 
> >   unsigned int saved_namelen = 0;
> >   ...
> > 	saved_namelen = ce_namelen(ce);
> >   ...
> >   if (saved_namelen)
> > 	ce->ce_namelen = saved_namelen;
> >   ce->ce_flags &= ~CE_STRIP_NAME;
> > 
> > the zero-length name case (if that's even legal) would work out the
> > same.
> 
> Yeah, that was one option that I looked at. The first option
> was to initialise saved_namelen to -1 (it was still an int) then
> the test became if (saved_namelen >= 0). However, that started
> me thinking about the zero-length case - should I assert if
> ((ce->ce_flags & CE_STRIP_NAME) && (ce_namelen(ce) == 0))? etc.
> 
> In the end, I decided that I wanted it to be 'drop dead' obvious
> what was going on! Hopefully, the result was just that. :-D

Yeah, thinking on it more, simple and stupid is the right thing to do
here. Thanks for a dose of sanity. :)

-Peff

      reply	other threads:[~2018-03-21  5:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-19 17:56 [PATCH 2/2] read-cache: fix an -Wmaybe-uninitialized warning Ramsay Jones
2018-03-20  4:36 ` Jeff King
2018-03-20 22:52   ` Ramsay Jones
2018-03-21  5:59     ` 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=20180321055944.GA15719@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=Johannes.Schindelin@gmx.de \
    --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;
as well as URLs for NNTP newsgroup(s).