Skip to content

Commit

Permalink
l2tp: cleanup unnecessary braces in if statements
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Tom Parkin authored and David S. Miller committed Jul 23, 2020
1 parent 0febc7b commit 6c0ec37
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
6 changes: 3 additions & 3 deletions net/l2tp/l2tp_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,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);
Expand All @@ -707,7 +707,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);
Expand Down Expand Up @@ -1389,7 +1389,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;
Expand Down
23 changes: 9 additions & 14 deletions net/l2tp/l2tp_ppp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6c0ec37

Please sign in to comment.