git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Johannes Sixt <j6t@kdbg.org>
Cc: David Soria Parra <sn_@gmx.net>,
	git@vger.kernel.org, David Soria Parra <dsp@php.net>
Subject: Re: [PATCH] Fix compiler warning by properly initialize failed_errno
Date: Tue, 04 Aug 2009 12:09:33 -0700	[thread overview]
Message-ID: <7v3a87o0pe.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <4A78834C.20002@kdbg.org> (Johannes Sixt's message of "Tue\, 04 Aug 2009 20\:51\:56 +0200")

Johannes Sixt <j6t@kdbg.org> writes:

> Junio C Hamano schrieb:
>
>> We would want to be able to distinguish between a workaround for a
>> compiler that is not clever/careful enough, and a necessary
>> initialization.  In this particular case, it is the former, and we should
>> say
>>
>> 	int failed_errno = failed_errno;
>>
>> instead.
>
> Frankly, I prefer the initialization with 0; this is not a performance
> critical place and micro-optimization is not appropriate here.

It is not about optimization at all.  This is about documenting the fact
that we have audited and know that the use of this variable in the code
that follows is Ok.  Initializing to 0 gives a false impression that the
code may rely on that value, but in this case nobody will ever read that
zero before overwriting it with an assignment.

The compiler may optimize this out, but that is an insignificant (I agree
this is not a performance critical codepath) side effect.

      reply	other threads:[~2009-08-04 19:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-02 19:34 [PATCH] Fix compiler warning by properly initialize failed_errno David Soria Parra
2009-08-04  6:07 ` Junio C Hamano
2009-08-04  9:27   ` sn_
2009-08-04 22:22     ` Junio C Hamano
2009-08-04 18:51   ` Johannes Sixt
2009-08-04 19:09     ` 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=7v3a87o0pe.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=dsp@php.net \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    --cc=sn_@gmx.net \
    /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).