git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Torsten Bögershausen" <tboegi@web.de>
Cc: "Carlo Marcelo Arenas Belón" <carenas@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH] builtin/receive-pack: dead initializer for retval in check_nonce
Date: Mon, 22 Oct 2018 12:35:36 +0900	[thread overview]
Message-ID: <xmqqzhv6wt4n.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20181020164526.GA1077@tor.lan> ("Torsten Bögershausen"'s message of "Sat, 20 Oct 2018 18:45:26 +0200")

Torsten Bögershausen <tboegi@web.de> writes:

> Initializing a variable to "BAD" in the beginning can be a good thing
> for two reasons:
> - There is a complex if-elseif chain, which should set retval
>   in any case, this is at least what I expect taking a very quick look at the
>   code:
> ...
> # The second reason is that some compilers don't understand this complex
> # stuff either, and through out a warning, like
> # "retval may be uninitialized" or something in that style.
> # This is very compiler dependent.

And to help humans that unless some if/else chain explicitly says it
is OK, the caller receives BAD by default.  In other words, it is
being defensive.

At least that was the reasoning behind the original code that did
not support SLOP.

> So yes, the current code may seem to be over-eager and ask for
> optimization, but we don't gain more that a couple of nano-seconds
> or so.  The good thing is that we have the code a little bit more
> robust, when changes are done in the future.

True.


      parent reply	other threads:[~2018-10-22  3:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-20  7:08 [PATCH] builtin/receive-pack: dead initializer for retval in check_nonce Carlo Marcelo Arenas Belón
2018-10-20 16:45 ` Torsten Bögershausen
2018-10-21 10:00   ` Carlo Arenas
2018-10-22  3:35   ` Junio C Hamano [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=xmqqzhv6wt4n.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=carenas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=tboegi@web.de \
    /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).