All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Parkin <tparkin@katalix.com>
To: netdev@vger.kernel.org
Cc: Tom Parkin <tparkin@katalix.com>
Subject: [PATCH 11/29] l2tp: cleanup unnecessary braces in if statements
Date: Tue, 21 Jul 2020 18:32:03 +0100	[thread overview]
Message-ID: <20200721173221.4681-12-tparkin@katalix.com> (raw)
In-Reply-To: <20200721173221.4681-1-tparkin@katalix.com>

These checks are all simple and don't benefit from extra braces to
clarify intent.  Remove them for easier-reading code.

Signed-off-by: Tom Parkin <tparkin@katalix.com>
---
 net/l2tp/l2tp_core.c |  6 +++---
 net/l2tp/l2tp_ppp.c  | 23 +++++++++--------------
 2 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
index dc8cb1fe94dc..acba7757bd79 100644
--- a/net/l2tp/l2tp_core.c
+++ b/net/l2tp/l2tp_core.c
@@ -681,7 +681,7 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
 		 * check if we sre sending sequence numbers and if not,
 		 * configure it so.
 		 */
-		if ((!session->lns_mode) && (!session->send_seq)) {
+		if (!session->lns_mode && !session->send_seq) {
 			l2tp_info(session, L2TP_MSG_SEQ,
 				  "%s: requested to enable seq numbers by LNS\n",
 				  session->name);
@@ -705,7 +705,7 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
 		 * If we're the LNS and we're sending sequence numbers, the
 		 * LAC is broken. Discard the frame.
 		 */
-		if ((!session->lns_mode) && (session->send_seq)) {
+		if (!session->lns_mode && session->send_seq) {
 			l2tp_info(session, L2TP_MSG_SEQ,
 				  "%s: requested to disable seq numbers by LNS\n",
 				  session->name);
@@ -1387,7 +1387,7 @@ static int l2tp_tunnel_sock_create(struct net *net,
 
 out:
 	*sockp = sock;
-	if ((err < 0) && sock) {
+	if (err < 0 && sock) {
 		kernel_sock_shutdown(sock, SHUT_RDWR);
 		sock_release(sock);
 		*sockp = NULL;
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
index 7404661d4117..e58fe7e3b884 100644
--- a/net/l2tp/l2tp_ppp.c
+++ b/net/l2tp/l2tp_ppp.c
@@ -802,8 +802,7 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
 	 * the internal context for use by ioctl() and sockopt()
 	 * handlers.
 	 */
-	if ((session->session_id == 0) &&
-	    (session->peer_session_id == 0)) {
+	if (session->session_id == 0 && session->peer_session_id == 0) {
 		error = 0;
 		goto out_no_ppp;
 	}
@@ -925,7 +924,7 @@ static int pppol2tp_getname(struct socket *sock, struct sockaddr *uaddr,
 	tunnel = session->tunnel;
 
 	inet = inet_sk(tunnel->sock);
-	if ((tunnel->version == 2) && (tunnel->sock->sk_family == AF_INET)) {
+	if (tunnel->version == 2 && tunnel->sock->sk_family == AF_INET) {
 		struct sockaddr_pppol2tp sp;
 
 		len = sizeof(sp);
@@ -943,8 +942,7 @@ static int pppol2tp_getname(struct socket *sock, struct sockaddr *uaddr,
 		sp.pppol2tp.addr.sin_addr.s_addr = inet->inet_daddr;
 		memcpy(uaddr, &sp, len);
 #if IS_ENABLED(CONFIG_IPV6)
-	} else if ((tunnel->version == 2) &&
-		   (tunnel->sock->sk_family == AF_INET6)) {
+	} else if (tunnel->version == 2 && tunnel->sock->sk_family == AF_INET6) {
 		struct sockaddr_pppol2tpin6 sp;
 
 		len = sizeof(sp);
@@ -962,8 +960,7 @@ static int pppol2tp_getname(struct socket *sock, struct sockaddr *uaddr,
 		memcpy(&sp.pppol2tp.addr.sin6_addr, &tunnel->sock->sk_v6_daddr,
 		       sizeof(tunnel->sock->sk_v6_daddr));
 		memcpy(uaddr, &sp, len);
-	} else if ((tunnel->version == 3) &&
-		   (tunnel->sock->sk_family == AF_INET6)) {
+	} else if (tunnel->version == 3 && tunnel->sock->sk_family == AF_INET6) {
 		struct sockaddr_pppol2tpv3in6 sp;
 
 		len = sizeof(sp);
@@ -1179,7 +1176,7 @@ static int pppol2tp_session_setsockopt(struct sock *sk,
 
 	switch (optname) {
 	case PPPOL2TP_SO_RECVSEQ:
-		if ((val != 0) && (val != 1)) {
+		if (val != 0 && val != 1) {
 			err = -EINVAL;
 			break;
 		}
@@ -1190,7 +1187,7 @@ static int pppol2tp_session_setsockopt(struct sock *sk,
 		break;
 
 	case PPPOL2TP_SO_SENDSEQ:
-		if ((val != 0) && (val != 1)) {
+		if (val != 0 && val != 1) {
 			err = -EINVAL;
 			break;
 		}
@@ -1208,7 +1205,7 @@ static int pppol2tp_session_setsockopt(struct sock *sk,
 		break;
 
 	case PPPOL2TP_SO_LNSMODE:
-		if ((val != 0) && (val != 1)) {
+		if (val != 0 && val != 1) {
 			err = -EINVAL;
 			break;
 		}
@@ -1274,8 +1271,7 @@ static int pppol2tp_setsockopt(struct socket *sock, int level, int optname,
 
 	/* Special case: if session_id == 0x0000, treat as operation on tunnel
 	 */
-	if ((session->session_id == 0) &&
-	    (session->peer_session_id == 0)) {
+	if (session->session_id == 0 && session->peer_session_id == 0) {
 		tunnel = session->tunnel;
 		err = pppol2tp_tunnel_setsockopt(sk, tunnel, optname, val);
 	} else {
@@ -1392,8 +1388,7 @@ static int pppol2tp_getsockopt(struct socket *sock, int level, int optname,
 		goto end;
 
 	/* Special case: if session_id == 0x0000, treat as operation on tunnel */
-	if ((session->session_id == 0) &&
-	    (session->peer_session_id == 0)) {
+	if (session->session_id == 0 && session->peer_session_id == 0) {
 		tunnel = session->tunnel;
 		err = pppol2tp_tunnel_getsockopt(sk, tunnel, optname, &val);
 		if (err)
-- 
2.17.1


  parent reply	other threads:[~2020-07-21 17:41 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-21 17:31 [PATCH net-next 00/29] l2tp: cleanup checkpatch.pl warnings Tom Parkin
2020-07-21 17:31 ` [PATCH 01/29] l2tp: cleanup whitespace around operators Tom Parkin
2020-07-21 17:31 ` [PATCH 02/29] l2tp: tweak comment style for consistency Tom Parkin
2020-07-21 17:31 ` [PATCH 03/29] l2tp: add a blank line following declarations Tom Parkin
2020-07-21 17:31 ` [PATCH 04/29] l2tp: cleanup excessive blank lines Tom Parkin
2020-07-21 17:31 ` [PATCH 05/29] l2tp: cleanup difficult-to-read line breaks Tom Parkin
2020-07-21 20:59   ` Jakub Kicinski
2020-07-21 23:26     ` David Miller
2020-07-22  9:06     ` Tom Parkin
2020-07-21 17:31 ` [PATCH 06/29] l2tp: cleanup wonky alignment of line-broken function calls Tom Parkin
2020-07-21 17:31 ` [PATCH 07/29] l2tp: cleanup suspect code indent Tom Parkin
2020-07-21 17:32 ` [PATCH 08/29] l2tp: add identifier name in function pointer prototype Tom Parkin
2020-07-21 17:32 ` [PATCH 09/29] l2tp: prefer using BIT macro Tom Parkin
2020-07-21 17:32 ` [PATCH 10/29] l2tp: cleanup comparisons to NULL Tom Parkin
2020-07-21 17:32 ` Tom Parkin [this message]
2020-07-21 17:32 ` [PATCH 12/29] l2tp: prefer seq_puts for unformatted output Tom Parkin
2020-07-21 17:32 ` [PATCH 13/29] l2tp: avoid multiple assignments Tom Parkin
2020-07-21 17:32 ` [PATCH 14/29] l2tp: line-break long function prototypes Tom Parkin
2020-07-21 17:32 ` [PATCH 15/29] l2tp: comment per net spinlock instances Tom Parkin
2020-07-21 17:32 ` [PATCH 16/29] l2tp: fix up incorrect comment in l2tp_recv_common Tom Parkin
2020-07-21 17:32 ` [PATCH 17/29] l2tp: avoid precidence issues in L2TP_SKB_CB macro Tom Parkin
2020-07-28 16:21   ` Joe Perches
2020-07-28 18:08     ` Joe Perches
2020-07-28 19:31       ` Tom Parkin
2020-07-21 17:32 ` [PATCH 18/29] l2tp: WARN_ON rather than BUG_ON in l2tp_debugfs.c Tom Parkin
2020-07-21 17:32 ` [PATCH 19/29] l2tp: use a function to render tunnel address in l2tp_debugfs Tom Parkin
2020-07-21 17:32 ` [PATCH 20/29] l2tp: cleanup netlink send of tunnel address information Tom Parkin
2020-07-21 17:32 ` [PATCH 21/29] l2tp: cleanup netlink tunnel create address handling Tom Parkin
2020-07-21 17:32 ` [PATCH 22/29] l2tp: cleanup kzalloc calls Tom Parkin
2020-07-21 17:32 ` [PATCH 23/29] l2tp: remove BUG_ON in l2tp_session_queue_purge Tom Parkin
2020-07-21 17:32 ` [PATCH 24/29] l2tp: remove BUG_ON in l2tp_tunnel_closeall Tom Parkin
2020-07-21 17:32 ` [PATCH 25/29] l2tp: don't BUG_ON session magic checks in l2tp_ppp Tom Parkin
2020-07-21 17:32 ` [PATCH 26/29] l2tp: don't BUG_ON seqfile " Tom Parkin
2020-07-21 17:32 ` [PATCH 27/29] l2tp: WARN_ON rather than BUG_ON in l2tp_session_queue_purge Tom Parkin
2020-07-21 17:32 ` [PATCH 28/29] l2tp: remove BUG_ON refcount value in l2tp_session_free Tom Parkin
2020-07-21 17:32 ` [PATCH 29/29] l2tp: WARN_ON rather than BUG_ON " Tom Parkin
2020-07-21 23:19 ` [PATCH net-next 00/29] l2tp: cleanup checkpatch.pl warnings David Miller
2020-07-22  9:07   ` Tom Parkin

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=20200721173221.4681-12-tparkin@katalix.com \
    --to=tparkin@katalix.com \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.