From 979500fb2d3fbf747907d22a4e9dcc3410e24aad Mon Sep 17 00:00:00 2001 From: sin Date: Mon, 8 Dec 2014 10:06:51 +0000 Subject: Guard FD_APPEND with a do { } while(0) --- ratox.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ratox.c b/ratox.c index 02fb07b..ca6752e 100644 --- a/ratox.c +++ b/ratox.c @@ -222,8 +222,12 @@ static void initshutdown(int); static void shutdown(void); static void usage(void); -#define FD_APPEND(fd) FD_SET((fd), &rfds); \ - if ((fd) > fdmax) fdmax = (fd); +#define FD_APPEND(fd) do { \ + FD_SET((fd), &rfds); \ + if ((fd) > fdmax) \ + fdmax = (fd); \ + } while(0) + #undef MIN #define MIN(x,y) ((x) < (y) ? (x) : (y)) @@ -1652,13 +1656,11 @@ loop(void) FD_ZERO(&rfds); fdmax = -1; - for (i = 0; i < LEN(gslots); i++) { + for (i = 0; i < LEN(gslots); i++) FD_APPEND(gslots[i].fd[IN]); - } - TAILQ_FOREACH(req, &reqhead, entry) { + TAILQ_FOREACH(req, &reqhead, entry) FD_APPEND(req->fd); - } TAILQ_FOREACH(f, &friendhead, entry) { /* File transfer cooldown */ @@ -1678,14 +1680,12 @@ loop(void) FD_APPEND(f->fd[FTEXT_IN]); if (f->tx.state == TRANSFER_NONE || - (f->tx.state == TRANSFER_INPROGRESS && !f->tx.cooldown)) { + (f->tx.state == TRANSFER_INPROGRESS && !f->tx.cooldown)) FD_APPEND(f->fd[FFILE_IN]); - } if (f->av.num < 0 || (toxav_get_call_state(toxav, f->av.num) == av_CallActive && - f->av.state & TRANSMITTING)) { + f->av.state & TRANSMITTING)) FD_APPEND(f->fd[FCALL_IN]); - } } FD_APPEND(f->fd[FREMOVE]); } -- cgit v1.2.3