Thread (2 messages) 2 messages, 2 authors, 2025-02-28

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

From: shejialuo <hidden>
Date: 2025-02-28 05:02:13

On Thu, Feb 27, 2025 at 08:57:11AM -0800, Junio C Hamano wrote:
shejialuo [off-list ref] writes:
quoted
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.
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help