Re: /* compiler workaround */ - what was the issue?

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

 



On Fri, May 6, 2016 at 4:41 AM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> "Philip Oakley" <philipoakley@xxxxxxx> writes:
>
>>     int saved_namelen = saved_namelen; /* compiler workaround */
>>
>> Which then becomes an MSVC compile warning C4700: uninitialized local
>> variable.
>>
>> I'm wondering what was the compiler workaround being referred to? i.e. why
>> does it need that tweak? There's no mention of the reason in the commit
>> message.
>
> That was a fairly well-known workaround for GCC that issues a false
> warning that variable is used before initialized.  I thought we
> stopped using it several years ago in new code after doing a bulk
> sanitizing

I guess that's 803a777 (cat-file: Fix an gcc -Wuninitialized warning -
2013-03-26) and more commits around that time. The split-index commit
is in 2014. I must have missed the trend.

> (I think the new recommended workaround was to initialise
> such a variable to the nil value like '0' for integers).

Yep. First Jeff removed the " = xxx" part from "xxx = xxx" then Ramsay
added the " = NULL" back. So we probably just do "int saved_namelen =
0;" in this case.
-- 
Duy
--
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]