git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] builtin/receive-pack: dead initializer for retval in check_nonce

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 22, 2018, 03:35 UTC
Message-ID
<xmqqzhv6wt4n.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20181020164526.GA1077@tor.lan>
Torsten Bögershausen <tboegi@web.de> writes:
Show 10 quoted lines
> 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.
Previous: Carlo Arenas
Message 4 of 4 in “builtin/receive-pack: dead initializer for retval in check_nonce”
  1. builtin/receive-pack: dead initializer for retval in check_nonceCarlo Marcelo Arenas Belón, Oct 20, 2018
  2. Torsten BögershausenOct 20, 2018
  3. Carlo ArenasOct 21, 2018
  4. Junio C HamanoOct 22, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.