Subject: Re: [PATCH v7 3/9] packed-backend: check whether the "packed-refs" is regular file

From: Junio C Hamano <[email-masked]>
Date: Thu, 27 Feb 2025 08:57:11 -0800

shejialuo <[email-masked]> writes:

> You are right. Actually, I just want to avoid assigning the `fd` to -1.

Why not?

Between leaving it uninitialized and explicitly initializing it to
signal that it is invalid, the only difference is that you can
programmatically check if fd is invalid and refrain from calling
close(fd), for example, with the latter, while with the former you
cannot.

> However, I didn't realize that I would initialize the strbuf later.
> After waking up, I have suddenly realized this problem.

Given that initialized-but-never-used strbuf does not hold any
acquired resources, the current code at the end of the series is
still OK.  So there is technically nothing to fix.  I'll take a
reroll if you later send one, but as I said, I do not think it is
necessary to reroll only to add fd=-1 initialization.