Re: [PATCH] Fix an unitialized pointer in merge-recursive.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> "Marco Costalba" <mcostalba@xxxxxxxxx> writes:
>
>> On 8/16/07, Junio C Hamano <gitster@xxxxxxxxx> wrote:
>>> "Marco Costalba" <mcostalba@xxxxxxxxx> 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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux