Subject: Re: [PATCH v2 6/6] midx-write: simplify error cases

From: Junio C Hamano <[email-masked]>
Date: Wed, 03 Sep 2025 11:43:08 -0700

Patrick Steinhardt <[email-masked]> writes:

>> -	int result = 0;
>> +	int result = -1;
>>  	const char **keep_hashes = NULL;
>>  	struct chunkfile *cf;
>
> I personally prefer to keep the result uninitialized and then assign the
> result of `error()` to it. It's almost the same lines of code as we have
> right now, but it has the advantage that the compiler will complain
> about `result` being uninitialized if we ever forget to set it. So it's
> overall way more explicit, and the compiler protects us.
>
> But seeing that Junio previously recommended to go into the direction of
> setting it to `-1` I won't insist on such a refactoring. So please feel
> free to ignore this comment.

I am equally fine with uninitialized one, as long as compilers are
trustworthy in all cases.  But the code path I made a comment IIRC
did not necessarily have calls to error(), so the same number of
code argument does not apply.  And initializing it to zero is worse
than leaving it uninitialized.

Thanks.