Skip to content

Commit

Permalink
net: fix smatch warnings inside datagram_poll
Browse files Browse the repository at this point in the history
Commit 7d4c04f ("net: add option to enable
error queue packets waking select") has an issue due to operator precedence
causing the bit-wise OR to bind to the sock_flags call instead of the result of
the terniary conditional. This fixes the *_poll functions to work properly. The
old code results in "mask |= POLLPRI" instead of what was intended, which is to
only include POLLPRI when the socket option is enabled.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
jacob-keller authored and davem330 committed Apr 2, 2013
1 parent be0e2f1 commit 8facd5f
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion net/bluetooth/af_bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ unsigned int bt_sock_poll(struct file *file, struct socket *sock,

if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
mask |= POLLERR |
sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);

if (sk->sk_shutdown & RCV_SHUTDOWN)
mask |= POLLRDHUP | POLLIN | POLLRDNORM;
Expand Down
2 changes: 1 addition & 1 deletion net/core/datagram.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ unsigned int datagram_poll(struct file *file, struct socket *sock,
/* exceptional events? */
if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
mask |= POLLERR |
sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);

if (sk->sk_shutdown & RCV_SHUTDOWN)
mask |= POLLRDHUP | POLLIN | POLLRDNORM;
Expand Down
2 changes: 1 addition & 1 deletion net/iucv/af_iucv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,7 @@ unsigned int iucv_sock_poll(struct file *file, struct socket *sock,

if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
mask |= POLLERR |
sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);

if (sk->sk_shutdown & RCV_SHUTDOWN)
mask |= POLLRDHUP;
Expand Down
2 changes: 1 addition & 1 deletion net/nfc/llcp/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ static unsigned int llcp_sock_poll(struct file *file, struct socket *sock,

if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
mask |= POLLERR |
sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);

if (!skb_queue_empty(&sk->sk_receive_queue))
mask |= POLLIN | POLLRDNORM;
Expand Down
2 changes: 1 addition & 1 deletion net/unix/af_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -2197,7 +2197,7 @@ static unsigned int unix_dgram_poll(struct file *file, struct socket *sock,
/* exceptional events? */
if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
mask |= POLLERR |
sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0;
(sock_flag(sk, SOCK_SELECT_ERR_QUEUE) ? POLLPRI : 0);

if (sk->sk_shutdown & RCV_SHUTDOWN)
mask |= POLLRDHUP | POLLIN | POLLRDNORM;
Expand Down

0 comments on commit 8facd5f

Please sign in to comment.