From: Junio C Hamano Date: Mon, 22 Feb 2010 19:56:53 GMT Subject: Re: [PATCH 5/6] git_mkstemps_mode: don't set errno to EINVAL for any error. Message-ID: <7vzl31cad6.fsf@alter.siamese.dyndns.org> In-Reply-To: Matthieu Moy writes: > Just removing the line would work with the current code, but this "if > (errno <= 0) errno = EINVAL;" allows enforcing the invariant that > errno > 0 when reaching "return -1" in a simple and reliable way (i.e. > changing the for loop later cannot break this invariant by mistake). I do not think "errno > 0 when -1 is returned" is a meaningful invariant. You may return EINVAL which is positive and that may keep that invariant, but you should not be returning that errno unless the error is "template not ending with 6-X" to begin with, so there isn't a real gain, no?