linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Garzarella <sgarzare@redhat.com>
To: davem@davemloft.net
Cc: Jorgen Hansen <jhansen@vmware.com>,
	Stefano Garzarella <sgarzare@redhat.com>,
	netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
	Dexuan Cui <decui@microsoft.com>,
	linux-kernel@vger.kernel.org,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: [PATCH net 2/2] vsock: small cleanup in vsock_poll()
Date: Tue, 11 Aug 2020 11:55:04 +0200	[thread overview]
Message-ID: <20200811095504.25051-3-sgarzare@redhat.com> (raw)
In-Reply-To: <20200811095504.25051-1-sgarzare@redhat.com>

This patch combines nested if statements in a single one to reduce
the indentation in vsock_poll().
It also combines an if nested in the else branch.

The behavior isn't changed.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
---
 net/vmw_vsock/af_vsock.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 9e93bc201cc0..2c80dc14fa60 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -1032,21 +1032,18 @@ static __poll_t vsock_poll(struct file *file, struct socket *sock,
 		}
 
 		/* Connected sockets that can produce data can be written. */
-		if (transport && sk->sk_state == TCP_ESTABLISHED) {
-			if (!(sk->sk_shutdown & SEND_SHUTDOWN)) {
-				bool space_avail_now = false;
-				int ret = transport->notify_poll_out(
-						vsk, 1, &space_avail_now);
-				if (ret < 0) {
-					mask |= EPOLLERR;
-				} else {
-					if (space_avail_now)
-						/* Remove EPOLLWRBAND since INET
-						 * sockets are not setting it.
-						 */
-						mask |= EPOLLOUT | EPOLLWRNORM;
-
-				}
+		if (transport && sk->sk_state == TCP_ESTABLISHED &&
+		    !(sk->sk_shutdown & SEND_SHUTDOWN)) {
+			bool space_avail_now = false;
+			int ret = transport->notify_poll_out(vsk, 1,
+							     &space_avail_now);
+			if (ret < 0) {
+				mask |= EPOLLERR;
+			} else if (space_avail_now) {
+				/* Remove EPOLLWRBAND since INET
+				 * sockets are not setting it.
+				 */
+				mask |= EPOLLOUT | EPOLLWRNORM;
 			}
 		}
 
-- 
2.26.2


  parent reply	other threads:[~2020-08-11  9:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-11  9:55 [PATCH net 0/2] vsock: fix null pointer dereference and cleanup in vsock_poll() Stefano Garzarella
2020-08-11  9:55 ` [PATCH net 1/2] vsock: fix potential null pointer dereference " Stefano Garzarella
2020-08-11  9:55 ` Stefano Garzarella [this message]
2020-08-11 17:24 ` [PATCH net 0/2] vsock: fix null pointer dereference and cleanup " David Miller
2020-08-12  7:17   ` Stefano Garzarella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200811095504.25051-3-sgarzare@redhat.com \
    --to=sgarzare@redhat.com \
    --cc=davem@davemloft.net \
    --cc=decui@microsoft.com \
    --cc=jhansen@vmware.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).