[PATCH 4/7] src: clarify '&' vs '?' precedence

From: Roman I Khimov <khimov_at_altell.ru>
Date: Fri, 13 Mar 2015 17:24:23 +0300

Purely stylistic, suggested by cppcheck: "Clarify calculation precedence for
'&' and '?'"
---
 src/libstddjb/iobufferk_fill.c          | 4 ++--
 src/libstddjb/iobufferk_flush.c         | 2 +-
 src/libunixonacid/unixmessage_receive.c | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/libstddjb/iobufferk_fill.c b/src/libstddjb/iobufferk_fill.c
index c811c24..452bf5c 100644
--- a/src/libstddjb/iobufferk_fill.c
+++ b/src/libstddjb/iobufferk_fill.c
_at_@ -11,7 +11,7 @@
 
 static int iobufferk_tee (iobufferk *k)
 {
-  register int r = tee(k->fd[0], k->fd[1], IOBUFFERK_SIZE - k->n, k->nb & 1 ? SPLICE_F_NONBLOCK : 0) ;
+  register int r = tee(k->fd[0], k->fd[1], IOBUFFERK_SIZE - k->n, (k->nb & 1) ? SPLICE_F_NONBLOCK : 0) ;
   if (r > 0) k->n += r ;
   return r ;
 }
_at_@ -26,7 +26,7 @@ static int iobufferk_splice (iobufferk *k)
 
 static int iobufferk_fill_3 (iobufferk *k)
 {
-  register int r = splice(k->fd[0], 0, k->p[1], 0, IOBUFFERK_SIZE - k->n, k->nb & 1 ? SPLICE_F_NONBLOCK : 0) ;
+  register int r = splice(k->fd[0], 0, k->p[1], 0, IOBUFFERK_SIZE - k->n, (k->nb & 1) ? SPLICE_F_NONBLOCK : 0) ;
   if (r > 0) k->n += r ;
   if ((r < 0) && (errno == EINVAL)) errno = ENOSYS ;
   return r ;
diff --git a/src/libstddjb/iobufferk_flush.c b/src/libstddjb/iobufferk_flush.c
index 674ffec..b18af4e 100644
--- a/src/libstddjb/iobufferk_flush.c
+++ b/src/libstddjb/iobufferk_flush.c
_at_@ -31,7 +31,7 @@ static int iobufferk_flush_3 (iobufferk *k)
 {
   while (k->n)
   {
-    register int r = splice(k->p[0], 0, k->fd[1], 0, k->n, SPLICE_F_MORE | (k->nb & 2 ? SPLICE_F_NONBLOCK : 0)) ;
+    register int r = splice(k->p[0], 0, k->fd[1], 0, k->n, SPLICE_F_MORE | ((k->nb & 2) ? SPLICE_F_NONBLOCK : 0)) ;
     if (r < 0)
     {
       if (errno == EINVAL) errno = ENOSYS ;
diff --git a/src/libunixonacid/unixmessage_receive.c b/src/libunixonacid/unixmessage_receive.c
index 885a7bc..7ddcf00 100644
--- a/src/libunixonacid/unixmessage_receive.c
+++ b/src/libunixonacid/unixmessage_receive.c
_at_@ -46,8 +46,8 @@ static int unixmessage_receiver_fill (unixmessage_receiver_t *b)
     .msg_iov = iov,
     .msg_iovlen = 2,
     .msg_flags = 0,
-    .msg_control = b->fds_ok & 1 ? ancilbuf : 0,
-    .msg_controllen = b->fds_ok & 1 ? sizeof(ancilbuf) : 0
+    .msg_control = (b->fds_ok & 1) ? ancilbuf : 0,
+    .msg_controllen = (b->fds_ok & 1) ? sizeof(ancilbuf) : 0
   } ;
   int r = -1 ;
   if (cbuffer_isfull(&b->mainb) || ((b->fds_ok & 1) && cbuffer_isfull(&b->auxb)))
-- 
2.1.4
Received on Fri Mar 13 2015 - 14:24:23 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC