[LTP] [PATCH v2] creat05: don't assume number of opened fds
Jan Stancek
jstancek@redhat.com
Tue May 17 17:13:46 CEST 2016
----- Original Message -----
> From: "Cyril Hrubis" <chrubis@suse.cz>
> To: "Jan Stancek" <jstancek@redhat.com>
> Cc: ltp@lists.linux.it
> Sent: Tuesday, 17 May, 2016 5:01:55 PM
> Subject: Re: [PATCH v2] creat05: don't assume number of opened fds
>
> 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.
Right.
>
> > - 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.
Added free.
>
> > }
>
> Otherwise it looks good, acked.
Thanks, pushed.
Regards,
Jan
>
> --
> Cyril Hrubis
> chrubis@suse.cz
>
More information about the ltp
mailing list