From: Andrea Cervesato via ltp <ltp@lists.linux.it>
To: "Jinseok Kim" <always.starving0@gmail.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v4] open: fix cleanup condition and use snprintf
Date: Mon, 23 Mar 2026 06:45:26 +0000 [thread overview]
Message-ID: <69c0e189.050a0220.8a4b1.49b0@mx.google.com> (raw)
In-Reply-To: <20260321140819.4157-1-always.starving0@gmail.com>
Hi!
Since we are cleaning up the test, we can just do this instead:
static void cleanup(void)
{
if (first >= 0) {
int limit = fds_limit - first;
for (int i = 0; i < limit; i++) {
if (fds[i] != -1)
SAFE_CLOSE(fds[i]);
}
}
free(fds);
}
We don't need to calculate the index twice every iteration. Also, free(NULL)
is noop and we can safely call it without checking if it's NULL.
And please remove the `i` definition at static level. We don't really need that.
We can safely use `for (int i = 0`.
Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-03-23 6:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-18 14:47 [LTP] [PATCH v2 1/2] open: fix cleanup condition and use snprintf Jinseok Kim
2026-02-18 14:47 ` [LTP] [PATCH v2 2/2] open: replace getdtablesize with getrlimit Jinseok Kim
2026-02-19 9:37 ` [LTP] [PATCH v2 1/2] open: fix cleanup condition and use snprintf Andrea Cervesato via ltp
2026-02-19 14:15 ` [LTP] [PATCH v3 " Jinseok Kim
2026-02-19 14:15 ` [LTP] [PATCH v3 2/2] open: replace getdtablesize with getrlimit Jinseok Kim
2026-03-13 16:42 ` Petr Vorel
2026-03-20 13:56 ` [LTP] [PATCH v3 1/2] open: fix cleanup condition and use snprintf Andrea Cervesato via ltp
2026-03-21 14:08 ` [LTP] [PATCH v4] " Jinseok Kim
2026-03-23 6:45 ` Andrea Cervesato via ltp [this message]
2026-03-25 12:22 ` [LTP] [PATCH v5] " Jinseok Kim
2026-03-25 15:48 ` Andrea Cervesato via ltp
2026-03-27 14:03 ` [LTP] [PATCH v6] " Jinseok Kim
2026-03-27 14:52 ` Andrea Cervesato via ltp
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=69c0e189.050a0220.8a4b1.49b0@mx.google.com \
--to=ltp@lists.linux.it \
--cc=always.starving0@gmail.com \
--cc=andrea.cervesato@suse.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