[LTP] [PATCH v2] creat05: don't assume number of opened fds
Cyril Hrubis
chrubis@suse.cz
Tue May 17 17:01:55 CEST 2016
Hi!
> - if (last_fd <= 0)
> + if (num_opened_fds == 0)
> return;
We can leave out this if now since the for would be no-op now.
> - for (fd = first_fd + 1; fd <= last_fd; fd++) {
> - if (close(fd))
> - tst_res(TWARN | TERRNO, "close(%i) failed", fd);
> + for (i = 0; i < num_opened_fds; i++) {
> + if (close(opened_fds[i])) {
> + tst_res(TWARN | TERRNO, "close(%i) failed",
> + opened_fds[i]);
> + }
> }
We may also free the allocated array here.
> }
Otherwise it looks good, acked.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list