From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: Jeff King <peff@peff.net>, git@vger.kernel.org
Subject: Re: [PATCH] csum-file: introduce discard_hashfile()
Date: Fri, 26 Jul 2024 08:36:17 -0700 [thread overview]
Message-ID: <xmqqplr0xj0u.fsf@gitster.g> (raw)
In-Reply-To: <ZqORDmTj4GT0Eeqq@tanuki> (Patrick Steinhardt's message of "Fri, 26 Jul 2024 14:05:45 +0200")
Patrick Steinhardt <ps@pks.im> writes:
> On Fri, Jul 26, 2024 at 12:42:16AM -0400, Jeff King wrote:
>> On Thu, Jul 25, 2024 at 04:07:28PM -0700, Junio C Hamano wrote:
>>
>> > Introduce discard_hashfile() API function to allow them to release
>> > the resources held by a hashfile structure the callers want to
>> > dispose of, and use that in read-cache.c:do_write_index(), which is
>> > a central place that writes the index file.
>>
>> Nicely explained, and the patch looks good to me.
>>
>> A few small comments (that probably do not need any changes):
>>
>> > +void discard_hashfile(struct hashfile *f)
>> > +{
>> > + if (0 <= f->check_fd)
>> > + close(f->check_fd);
>> > + if (0 <= f->fd)
>> > + close(f->fd);
>> > + free_hashfile(f);
>> > +}
>
> Are we sure that this is always correct? A valid file descriptor may
> have a zero value, and we wouldn't end up closing it here.
I thought that these two fd members use -1 for their "zero value"
for that exact reason.
next prev parent reply other threads:[~2024-07-26 15:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-25 23:07 [PATCH] csum-file: introduce discard_hashfile() Junio C Hamano
2024-07-26 4:42 ` Jeff King
2024-07-26 12:05 ` Patrick Steinhardt
2024-07-26 15:36 ` Junio C Hamano [this message]
2024-07-26 14:41 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqplr0xj0u.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.