Re: [PATCH] Fix compiler warning by properly initialize failed_errno

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

 



Johannes Sixt <j6t@xxxxxxxx> 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.

--
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]