[LTP] [PATCH v4] open: fix cleanup condition and use snprintf
Andrea Cervesato
andrea.cervesato@suse.com
Mon Mar 23 07:45:26 CET 2026
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
More information about the ltp
mailing list