Re: [LTP] [PATCH v2 2/5] syscalls: Add epoll_wait13

Cyril Hrubis <[email protected]> Fri, 31 Jul 2026 14:17:59 +0200
Newsgroups it.linux.lists.ltp
Message-ID <[email protected]>
Hi!
> >		if (fds[i][0] > 0) {
> >			  SAFE_CLOSE(fds[i][0]);
> >			  SAFE_CLOSE(fds[i][1]);
> >		}
> 
> It's worth to change the statement to check for fd != -1.
> Otherwise:

Fixed with:

diff --git a/testcases/kernel/syscalls/epoll_wait/epoll_wait13.c b/testcases/kernel/syscalls/epoll_wait/epoll_wait13.c
index 8a8446baa..53a75ef1a 100644
--- a/testcases/kernel/syscalls/epoll_wait/epoll_wait13.c
+++ b/testcases/kernel/syscalls/epoll_wait/epoll_wait13.c
@@ -56,15 +56,28 @@ static void close_fds(int fds[][2], int n)
        int i;
 
        for (i = 0; i < n; i++) {
-               if (fds[i][0] > 0) {
+               if (fds[i][0] != -1) {
                        SAFE_CLOSE(fds[i][0]);
                        SAFE_CLOSE(fds[i][1]);
                }
        }
 }
 
+static void init_fds(int fds[][2], int n)
+{
+       int i;
+
+       for (i = 0; i < n; i++) {
+               fds[i][0] = -1;
+               fds[i][1] = -1;
+       }
+}
+
 static void setup(void)
 {
+       init_fds(ready_fds, NREADY);
+       init_fds(quiet_fds, NQUIET);
+
        epfd = SAFE_EPOLL_CREATE1(0);
 
        register_fds(ready_fds, NREADY, 0);

And pushed, thanks.

-- 
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp