From: Christian Brauner Date: Wed, 11 Aug 2021 13:52:12 +0000 (+0200) Subject: mainloop: move variables into tighter scope X-Git-Tag: lxc-5.0.0~115^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96348aa8ab8555df85c76bfb950993e5babfa183;p=thirdparty%2Flxc.git mainloop: move variables into tighter scope Signed-off-by: Christian Brauner --- diff --git a/src/lxc/mainloop.c b/src/lxc/mainloop.c index 4d3b7cc43..a937c5cc7 100644 --- a/src/lxc/mainloop.c +++ b/src/lxc/mainloop.c @@ -315,11 +315,10 @@ static int __lxc_mainloop_io_uring(struct lxc_async_descr *descr, int timeout_ms static int __lxc_mainloop_epoll(struct lxc_async_descr *descr, int timeout_ms) { - int i, nfds, ret; - struct mainloop_handler *handler; - struct epoll_event events[MAX_EVENTS]; - for (;;) { + int nfds; + struct epoll_event events[MAX_EVENTS]; + nfds = epoll_wait(descr->epfd, events, MAX_EVENTS, timeout_ms); if (nfds < 0) { if (errno == EINTR) @@ -328,8 +327,9 @@ static int __lxc_mainloop_epoll(struct lxc_async_descr *descr, int timeout_ms) return -errno; } - for (i = 0; i < nfds; i++) { - handler = events[i].data.ptr; + for (int i = 0; i < nfds; i++) { + int ret; + struct mainloop_handler *handler = events[i].data.ptr; /* If the handler returns a positive value, exit the * mainloop.