From: Junio C Hamano <gitster@pobox.com>
To: Hoyoung Lee <lhywkd22@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v3 1/2] t/helper/test-truncate: close file descriptor after truncation
Date: Tue, 22 Jul 2025 14:48:19 -0700 [thread overview]
Message-ID: <xmqqqzy7rj6k.fsf@gitster.g> (raw)
In-Reply-To: <20250722174102.1876197-2-lhywkd22@gmail.com> (Hoyoung Lee's message of "Tue, 22 Jul 2025 17:41:01 +0000")
Hoyoung Lee <lhywkd22@gmail.com> writes:
> Fix a resource leak where the file descriptor was not closed after
> truncating a file in t/helper/test-truncate.c.
>
> Signed-off-by: Hoyoung Lee <lhywkd22@gmail.com>
> ---
> t/helper/test-truncate.c | 3 +++
> 1 file changed, 3 insertions(+)
While it is not wrong per-se, it is not like a function that can
potentially be called number of times returns without closing it.
Nobody other than the main() function would be calling this
function, so the only thing that is done after this function returns
to its caller is for the caller to return leading to exit from the
process at which point the leftover file descriptor would be
closed.
So I am a bit curious what triggered you to send in these changes.
Are there some automated resource leak checker, without fixes like
these whose output would be noisy with complaints about these "known
leaking, no ill effects in practice, yet gets flagged by checkers"
code to be useful, or something?
Will queue; thanks.
> diff --git a/t/helper/test-truncate.c b/t/helper/test-truncate.c
> index 3931deaec7..104bc36cc0 100644
> --- a/t/helper/test-truncate.c
> +++ b/t/helper/test-truncate.c
> @@ -21,5 +21,8 @@ int cmd__truncate(int argc, const char **argv)
>
> if (ftruncate(fd, (off_t) sz) < 0)
> die_errno("failed to truncate file");
> +
> + close(fd);
> +
> return 0;
> }
next prev parent reply other threads:[~2025-07-22 21:48 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-22 17:41 [PATCH v3 0/2] fix resource leaks in test helpers Hoyoung Lee
2025-07-22 17:41 ` [PATCH v3 1/2] t/helper/test-truncate: close file descriptor after truncation Hoyoung Lee
2025-07-22 21:48 ` Junio C Hamano [this message]
2025-07-22 17:41 ` [PATCH v3 2/2] t/helper/test-delta: fix possible resource leak and ensure safe cleanup Hoyoung Lee
2025-07-23 7:28 ` Eric Sunshine
2025-07-23 7:55 ` Jeff King
2025-07-23 8:06 ` Jeff King
2025-07-23 8:17 ` Eric Sunshine
2025-07-23 23:59 ` Jeff King
2025-07-24 0:00 ` [PATCH 1/3] test-delta: handle errors with die() Jeff King
2025-07-24 0:02 ` [PATCH 2/3] test-delta: use strbufs to hold input files Jeff King
2025-07-24 0:03 ` [PATCH 3/3] test-delta: close output descriptor after use Jeff King
2025-07-23 8:11 ` [PATCH v3 2/2] t/helper/test-delta: fix possible resource leak and ensure safe cleanup Eric Sunshine
2025-07-23 8:46 ` Jeff King
2025-07-23 16:37 ` Eric Sunshine
2025-07-23 17:11 ` Junio C Hamano
2025-07-23 16:48 ` Junio C Hamano
2025-07-23 16:44 ` 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=xmqqqzy7rj6k.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=lhywkd22@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).