Calculate remain from idx at the top of the loop. This avoids having
to keep both remain and idx in step.
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
static void run(void)
{
struct poll_interest *i;
static void run(void)
{
struct poll_interest *i;
- int rv, nfds, remain, idx;
int timeout;
struct pollfd *fds=0;
int allocdfds=0, shortfall=0;
int timeout;
struct pollfd *fds=0;
int allocdfds=0, shortfall=0;
allocdfds += shortfall;
fds=safe_realloc_ary(fds,sizeof(*fds),allocdfds, "run");
}
allocdfds += shortfall;
fds=safe_realloc_ary(fds,sizeof(*fds),allocdfds, "run");
}
shortfall=0;
idx=0;
timeout=-1;
LIST_FOREACH(i, ®, entry) {
shortfall=0;
idx=0;
timeout=-1;
LIST_FOREACH(i, ®, entry) {
+ int remain=allocdfds-idx;
nfds=remain;
rv=i->before(i->state, fds+idx, &nfds, &timeout);
if (rv!=0) {
nfds=remain;
rv=i->before(i->state, fds+idx, &nfds, &timeout);
if (rv!=0) {
i->desc,timeout);
}
idx+=nfds;
i->desc,timeout);
}
idx+=nfds;