Re: [PATCH v7 3/9] packed-backend: check whether the "packed-refs" is regular file
- From
shejialuo <shejialuo@gmail.com>
- Date
- Feb 28, 2025, 05:02 UTC
- Message-ID
- <Z8FDX9-BbAt4H1RV@ArchLinux>
- In-Reply-To
- <xmqqeczj9vh4.fsf@gitster.g>
On Thu, Feb 27, 2025 at 08:57:11AM -0800, Junio C Hamano wrote:
Show 12 quoted lines
> shejialuo <shejialuo@gmail.com> 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. >
Yes, that's correct.
Show 8 quoted lines
> > 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.
Yes, as you have said, there is nothing wrong at now. And as Patrick has nothing comment. I have sent out a reroll to make code better.
Thanks, Jialuo