From 9d6b104ec8b4dc8ce182158bf6c81db23e937c5f Mon Sep 17 00:00:00 2001 From: =?utf8?q?=D0=9A=D0=BE=D1=80=D0=B5=D0=BD=D0=B1=D0=B5=D1=80=D0=B3=20?= =?utf8?q?=D0=9C=D0=B0=D1=80=D0=BA=20=28=D0=BD=D0=BE=D1=83=D1=82=D0=B1?= =?utf8?q?=D1=83=D0=BA=20=D0=B4=D0=BE=D0=BC=D0=B0=29?= Date: Mon, 10 Sep 2012 02:25:07 +0600 Subject: [PATCH] nl_recv(): "else if" logick simplified and refined --- lib/nl.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/nl.c b/lib/nl.c index 2fa741f..8426c58 100644 --- a/lib/nl.c +++ b/lib/nl.c @@ -459,25 +459,31 @@ retry: n = recvmsg(sk->s_fd, &msg, flags); if (!n) goto abort; - else if (n < 0) { + + if (n < 0) { + if (errno == EINTR) { NL_DBG(3, "recvmsg() returned EINTR, retrying\n"); goto retry; - } else if (errno == EAGAIN) { + } + + if (errno == EAGAIN) { NL_DBG(3, "recvmsg() returned EAGAIN, aborting\n"); goto abort; - } else { - free(msg.msg_control); - free(*buf); - return -nl_syserr2nlerr(errno); } + + free(msg.msg_control); + free(*buf); + return -nl_syserr2nlerr(errno); } if (msg.msg_flags & MSG_CTRUNC) { msg.msg_controllen *= 2; msg.msg_control = realloc(msg.msg_control, msg.msg_controllen); goto retry; - } else if (iov.iov_len < n || msg.msg_flags & MSG_TRUNC) { + } + + if (iov.iov_len < n || msg.msg_flags & MSG_TRUNC) { /* Provided buffer is not long enough, enlarge it * to size of n (which should be total length of the message) * and try again. */ @@ -485,7 +491,9 @@ retry: iov.iov_base = *buf = realloc(*buf, iov.iov_len); flags = 0; goto retry; - } else if (flags != 0) { + } + + if (flags != 0) { /* Buffer is big enough, do the actual reading */ flags = 0; goto retry; -- 2.40.0