From 78b9724b38a0778c7fef46eead2be344422c07d9 Mon Sep 17 00:00:00 2001 From: Matheus Date: Mon, 2 Jan 2023 23:42:25 -0300 Subject: [PATCH] poll syscall: add volatile keyword to fd count to prevent a loop from being optimized out --- src/sys/syscalls/poll.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/sys/syscalls/poll.c b/src/sys/syscalls/poll.c index 3abff3fd..8f92f43c 100644 --- a/src/sys/syscalls/poll.c +++ b/src/sys/syscalls/poll.c @@ -11,7 +11,7 @@ #define MAXNFDS 4096 -syscallret syscall_poll(pollfd *fds, size_t nfds, int timeoutms){ +syscallret syscall_poll(pollfd *fds, volatile int nfds, int timeoutms){ syscallret retv; retv.ret = -1; @@ -117,8 +117,7 @@ syscallret syscall_poll(pollfd *fds, size_t nfds, int timeoutms){ size_t eventcount = 0; - for(uintmax_t i = 0; i < nfds; ++i){ - + for(int i = 0; i < nfds; ++i){ if(ilist[i].fd < 0) continue; @@ -138,6 +137,6 @@ syscallret syscall_poll(pollfd *fds, size_t nfds, int timeoutms){ if(ilist) free(ilist); - + return retv; }