From 585dc5facf76440beca8e1ed9c55ff0c870b075a Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 10 Jun 2015 19:11:35 +0200 Subject: call: Rewrite excessivly long select call for readability. Signed-off-by: Ralf Baechle --- call/call.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'call/call.c') diff --git a/call/call.c b/call/call.c index 2f606bd..6c797f0 100644 --- a/call/call.c +++ b/call/call.c @@ -1630,7 +1630,8 @@ int cmd_call(char *call[], int mode) } while (TRUE) { - struct timeval tv; + struct timeval tv, *timeout; + int nfds; if (inactivity_timeout_is_set == TRUE && uploadfile == -1 && downloadfile == -1) { tv.tv_sec = inactivity_timeout.tv_sec; tv.tv_usec = inactivity_timeout.tv_usec; @@ -1647,7 +1648,13 @@ int cmd_call(char *call[], int mode) if (uploadfile != -1) FD_SET(fd, &sock_write); - if (select(fd + 1, &sock_read, &sock_write, NULL, (uploadfile == -1 && downloadfile == -1 && inactivity_timeout_is_set == FALSE) ? NULL : &tv) == -1) { + if (uploadfile == -1 && downloadfile == -1 && + inactivity_timeout_is_set == FALSE) + timeout = NULL; + else + timeout = &tv; + nfds = select(fd + 1, &sock_read, &sock_write, NULL, timeout); + if (nfds == -1) { if (!interrupted) { if (errno == EINTR) continue; -- cgit v1.2.3