From: =?utf-8?q?Ferenc_W=C3=A1gner?= Date: Sat, 31 Aug 2024 14:29:02 +0200 Subject: Use nfds_t in cl_poll() This complements our long-existing ipc_param_type patch. Closes: #1077353 --- Index: cluster-glue/lib/clplumbing/cl_poll.c =================================================================== --- cluster-glue.orig/lib/clplumbing/cl_poll.c 2024-08-31 14:47:54.956141061 +0200 +++ cluster-glue/lib/clplumbing/cl_poll.c 2024-08-31 14:48:12.635692755 +0200 @@ -98,8 +98,8 @@ } #else /* HAVE_FCNTL_F_SETSIG */ -static void dump_fd_info(struct pollfd *fds, unsigned int nfds, int timeoutms); -static void check_fd_info(struct pollfd *fds, unsigned int nfds); +static void dump_fd_info(struct pollfd *fds, nfds_t nfds, int timeoutms); +static void check_fd_info(struct pollfd *fds, nfds_t nfds); static void cl_real_poll_fd(int fd); static void cl_poll_sigpoll_overflow_sigaction(int nsig, siginfo_t* , void*); static void cl_poll_sigpoll_overflow(void); @@ -136,7 +136,7 @@ static int cl_nsig = 0; static gboolean SigQOverflow = FALSE; -static int cl_init_poll_sig(struct pollfd *fds, unsigned int nfds); +static int cl_init_poll_sig(struct pollfd *fds, nfds_t nfds); static short cl_poll_assignsig(int fd); static void cl_poll_sigaction(int nsig, siginfo_t* info, void* v); static int cl_poll_prepsig(int nsig); @@ -216,9 +216,9 @@ * file descriptors. */ static int -cl_init_poll_sig(struct pollfd *fds, unsigned int nfds) +cl_init_poll_sig(struct pollfd *fds, nfds_t nfds) { - unsigned j; + nfds_t j; int maxmonfd = -1; int nmatch = 0; @@ -543,7 +543,7 @@ */ int -cl_poll(struct pollfd *fds, unsigned int nfds, int timeoutms) +cl_poll(struct pollfd *fds, nfds_t nfds, int timeoutms) { int nready; struct timespec ts; @@ -551,7 +551,7 @@ const struct timespec* itertime = &ts; siginfo_t info; int eventcount = 0; - unsigned int j; + nfds_t j; int savederrno = errno; int stw_errno; int rc; @@ -679,19 +679,20 @@ * Debugging routine for printing current poll arguments, etc. */ static void -dump_fd_info(struct pollfd *fds, unsigned int nfds, int timeoutms) +dump_fd_info(struct pollfd *fds, nfds_t nfds, int timeoutms) { unsigned j; + nfds_t fd_index; cl_log(LOG_DEBUG, "timeout: %d milliseconds", timeoutms); - for (j=0; j < nfds; ++j) { - int fd = fds[j].fd; + for (fd_index=0; fd_index < nfds; ++fd_index) { + int fd = fds[fd_index].fd; poll_info_t* moni = monitorinfo+fd; cl_log(LOG_DEBUG, "fd %d flags: 0%o, signal: %d, events: 0x%x" ", revents: 0x%x, pendevents: 0x%x" , fd, fcntl(fd, F_GETFL), moni->nsig - , fds[j].events, fds[j].revents, moni->pendevents); + , fds[fd_index].events, fds[fd_index].revents, moni->pendevents); } for (j=SIGRTMIN; j < (unsigned)SIGRTMAX; ++j) { if (!sigismember(&SignalSet, j)) { @@ -705,12 +706,13 @@ * Debugging routine for auditing our file descriptors, etc. */ static void -check_fd_info(struct pollfd *fds, unsigned int nfds) +check_fd_info(struct pollfd *fds, nfds_t nfds) { unsigned j; + nfds_t fd_index; - for (j=0; j < nfds; ++j) { - int fd = fds[j].fd; + for (fd_index=0; fd_index < nfds; ++fd_index) { + int fd = fds[fd_index].fd; poll_info_t* moni = monitorinfo+fd; if (!sigismember(&SignalSet, moni->nsig)) { Index: cluster-glue/include/clplumbing/cl_poll.h =================================================================== --- cluster-glue.orig/include/clplumbing/cl_poll.h 2024-08-31 14:47:54.956141061 +0200 +++ cluster-glue/include/clplumbing/cl_poll.h 2024-08-31 14:47:54.952141163 +0200 @@ -31,7 +31,7 @@ * uses the real poll() call. * */ -int cl_poll(struct pollfd *fds, unsigned int nfds, int timeout_ms); +int cl_poll(struct pollfd *fds, nfds_t nfds, int timeout_ms); /* * Call cl_poll_ignore() when you close a file descriptor you monitored