diff options
author | pjd <pjd@FreeBSD.org> | 2010-06-14 21:18:58 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2010-06-14 21:18:58 +0000 |
commit | 7824be8be004a77de157cf30d317990b32ee47f8 (patch) | |
tree | d144721201629eb2cc9ea9f69e833644a5257215 /sbin | |
parent | e6a1cebf1aacba8458fe987e873a65f4a8762e38 (diff) | |
download | FreeBSD-src-7824be8be004a77de157cf30d317990b32ee47f8.zip FreeBSD-src-7824be8be004a77de157cf30d317990b32ee47f8.tar.gz |
Remove macros that are not really needed. The idea was to have them in case
we grow more descriptors, but I'll reconsider readding them once we get there.
Passing (a = b) expression to FD_ISSET() is bad idea, as FD_ISSET() evaluates
its argument twice.
Found by: Coverity Prevent
CID: 5243
MFC after: 3 days
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/hastd/hastd.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/sbin/hastd/hastd.c b/sbin/hastd/hastd.c index 27b9bba..bc0521b 100644 --- a/sbin/hastd/hastd.c +++ b/sbin/hastd/hastd.c @@ -400,7 +400,11 @@ static void main_loop(void) { fd_set rfds, wfds; - int fd, maxfd, ret; + int cfd, lfd, maxfd, ret; + + cfd = proto_descriptor(cfg->hc_controlconn); + lfd = proto_descriptor(cfg->hc_listenconn); + maxfd = cfd > lfd ? cfd : lfd; for (;;) { if (sigchld_received) { @@ -412,22 +416,13 @@ main_loop(void) hastd_reload(); } - maxfd = 0; + /* Setup descriptors for select(2). */ FD_ZERO(&rfds); + FD_SET(cfd, &rfds); + FD_SET(lfd, &rfds); FD_ZERO(&wfds); - - /* Setup descriptors for select(2). */ -#define SETUP_FD(conn) do { \ - fd = proto_descriptor(conn); \ - if (fd >= 0) { \ - maxfd = fd > maxfd ? fd : maxfd; \ - FD_SET(fd, &rfds); \ - FD_SET(fd, &wfds); \ - } \ -} while (0) - SETUP_FD(cfg->hc_controlconn); - SETUP_FD(cfg->hc_listenconn); -#undef SETUP_FD + FD_SET(cfd, &wfds); + FD_SET(lfd, &wfds); ret = select(maxfd + 1, &rfds, &wfds, NULL, NULL); if (ret == -1) { @@ -437,13 +432,10 @@ main_loop(void) pjdlog_exit(EX_OSERR, "select() failed"); } -#define ISSET_FD(conn) \ - (FD_ISSET((fd = proto_descriptor(conn)), &rfds) || FD_ISSET(fd, &wfds)) - if (ISSET_FD(cfg->hc_controlconn)) + if (FD_ISSET(cfd, &rfds) || FD_ISSET(cfd, &wfds)) control_handle(cfg); - if (ISSET_FD(cfg->hc_listenconn)) + if (FD_ISSET(lfd, &rfds) || FD_ISSET(lfd, &wfds)) listen_accept(); -#undef ISSET_FD } } |