From: Junio C Hamano Date: Tue, 04 Aug 2009 19:09:33 GMT Subject: Re: [PATCH] Fix compiler warning by properly initialize failed_errno Message-ID: <7v3a87o0pe.fsf@alter.siamese.dyndns.org> In-Reply-To: <4A78834C.20002@kdbg.org> Johannes Sixt 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.