From: David Kastrup <dak@gnu.org>
To: git@vger.kernel.org
Subject: Re: [PATCH] Fix an unitialized pointer in merge-recursive.c
Date: Thu, 16 Aug 2007 11:07:24 +0200 [thread overview]
Message-ID: <86643f4zlf.fsf@lola.quinscape.zz> (raw)
In-Reply-To: 7vodh7khuo.fsf@gitster.siamese.dyndns.org
Junio C Hamano <gitster@pobox.com> writes:
> "Marco Costalba" <mcostalba@gmail.com> writes:
>
>> On 8/16/07, Junio C Hamano <gitster@pobox.com> wrote:
>>> "Marco Costalba" <mcostalba@gmail.com> writes:
>>>
>>> > Indeed &mrtree is passed to merge_trees() that not always
>>> > seems to set the value, so on some paths mrtree could
>>> > return uninitialized.
>>> >
>>> > Spotted by a gcc 4.2.1 warning
>>>
>>> Are you sure that gcc is correctly seeing the codeflow?
>>>
>>> In merge(), mrtree is used only under index_only, and
>>> merge_trees() always sets *result under index_only.
>>
>> Ok ;-)
>>
>> Now two options:
>>
>> - discard the patch
>>
>> - change the title in 'silence a gcc bougus warning'
>
> Third option. Change the assignment from "mrtree = NULL" to
> "mrtree = mtree". It is a standard idiom to work around stupid
> gcc warnings.
I think it is more efficient to write mrtree = NULL: For the computer,
it makes a minuscule difference, and it can save programmers a bit of
confusion and worrying times. Time that may be better spent improving
things elsewhere.
I don't think that we have a contest running for least redundancy in
code layout, have we? Why then require the programmer to do a
complete call trace analysis before he can feel comfortable about the
code? And what if callers change at some point of time?
--
David Kastrup
next prev parent reply other threads:[~2007-08-16 9:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-16 8:00 [PATCH] Fix an unitialized pointer in merge-recursive.c Marco Costalba
2007-08-16 8:08 ` Junio C Hamano
2007-08-16 8:11 ` Marco Costalba
2007-08-16 8:23 ` Junio C Hamano
2007-08-16 8:30 ` Junio C Hamano
2007-08-16 9:07 ` David Kastrup [this message]
2007-08-16 13:16 ` Florian Weimer
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=86643f4zlf.fsf@lola.quinscape.zz \
--to=dak@gnu.org \
--cc=git@vger.kernel.org \
/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).