[PATCH] net: ipv4: fixed brace and space style

From: Armin Gholampoor
Date: Wed Nov 18 2020 - 03:29:20 EST


Fixed bracings for if statements

Fixed spacings around operators

Signed-off-by: Armin Gholampoor <armingh379@xxxxxxxxx>
---
net/ipv4/tcp.c | 67 +++++++++++++++++++++++++++-----------------------
1 file changed, 36 insertions(+), 31 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index b2bc3d7fe..8c31ed8a6 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -581,8 +581,9 @@ __poll_t tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
if (__sk_stream_is_writeable(sk, 1))
mask |= EPOLLOUT | EPOLLWRNORM;
}
- } else
+ } else {
mask |= EPOLLOUT | EPOLLWRNORM;
+ }

if (tp->urg_data & TCP_URG_VALID)
mask |= EPOLLPRI;
@@ -1479,8 +1480,9 @@ static int tcp_recv_urg(struct sock *sk, struct msghdr *msg, int len, int flags)
if (!(flags & MSG_TRUNC))
err = memcpy_to_msg(msg, &c, 1);
len = 1;
- } else
+ } else {
msg->msg_flags |= MSG_TRUNC;
+ }

return err ? -EFAULT : len;
}
@@ -2194,8 +2196,9 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
if (!used)
goto skip_copy;
}
- } else
+ } else {
used = urg_offset;
+ }
}
}

@@ -2340,20 +2343,20 @@ EXPORT_SYMBOL_GPL(tcp_set_state);
*/

static const unsigned char new_state[16] = {
- /* current state: new state: action: */
- [0 /* (Invalid) */] = TCP_CLOSE,
- [TCP_ESTABLISHED] = TCP_FIN_WAIT1 | TCP_ACTION_FIN,
- [TCP_SYN_SENT] = TCP_CLOSE,
- [TCP_SYN_RECV] = TCP_FIN_WAIT1 | TCP_ACTION_FIN,
- [TCP_FIN_WAIT1] = TCP_FIN_WAIT1,
- [TCP_FIN_WAIT2] = TCP_FIN_WAIT2,
- [TCP_TIME_WAIT] = TCP_CLOSE,
- [TCP_CLOSE] = TCP_CLOSE,
- [TCP_CLOSE_WAIT] = TCP_LAST_ACK | TCP_ACTION_FIN,
- [TCP_LAST_ACK] = TCP_LAST_ACK,
- [TCP_LISTEN] = TCP_CLOSE,
- [TCP_CLOSING] = TCP_CLOSING,
- [TCP_NEW_SYN_RECV] = TCP_CLOSE, /* should not happen ! */
+ /* current state: new state: action: */
+ [0 /* (Invalid) */] = TCP_CLOSE,
+ [TCP_ESTABLISHED] = TCP_FIN_WAIT1 | TCP_ACTION_FIN,
+ [TCP_SYN_SENT] = TCP_CLOSE,
+ [TCP_SYN_RECV] = TCP_FIN_WAIT1 | TCP_ACTION_FIN,
+ [TCP_FIN_WAIT1] = TCP_FIN_WAIT1,
+ [TCP_FIN_WAIT2] = TCP_FIN_WAIT2,
+ [TCP_TIME_WAIT] = TCP_CLOSE,
+ [TCP_CLOSE] = TCP_CLOSE,
+ [TCP_CLOSE_WAIT] = TCP_LAST_ACK | TCP_ACTION_FIN,
+ [TCP_LAST_ACK] = TCP_LAST_ACK,
+ [TCP_LISTEN] = TCP_CLOSE,
+ [TCP_CLOSING] = TCP_CLOSING,
+ [TCP_NEW_SYN_RECV] = TCP_CLOSE, /* should not happen ! */
};

static int tcp_close_state(struct sock *sk)
@@ -3043,7 +3046,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, int optname,
return -EINVAL;

val = strncpy_from_sockptr(name, optval,
- min_t(long, TCP_CA_NAME_MAX-1, optlen));
+ min_t(long, TCP_CA_NAME_MAX - 1, optlen));
if (val < 0)
return -EFAULT;
name[val] = 0;
@@ -3135,9 +3138,9 @@ static int do_tcp_setsockopt(struct sock *sk, int level, int optname,
break;

case TCP_REPAIR:
- if (!tcp_can_repair_sock(sk))
+ if (!tcp_can_repair_sock(sk)) {
err = -EPERM;
- else if (val == TCP_REPAIR_ON) {
+ } else if (val == TCP_REPAIR_ON) {
tp->repair = 1;
sk->sk_reuse = SK_FORCE_REUSE;
tp->repair_queue = TCP_NO_QUEUE;
@@ -3148,8 +3151,9 @@ static int do_tcp_setsockopt(struct sock *sk, int level, int optname,
} else if (val == TCP_REPAIR_OFF_NO_WP) {
tp->repair = 0;
sk->sk_reuse = SK_NO_REUSE;
- } else
+ } else {
err = -EINVAL;
+ }

break;

@@ -3163,16 +3167,16 @@ static int do_tcp_setsockopt(struct sock *sk, int level, int optname,
break;

case TCP_QUEUE_SEQ:
- if (sk->sk_state != TCP_CLOSE)
+ if (sk->sk_state != TCP_CLOSE) {
err = -EPERM;
- else if (tp->repair_queue == TCP_SEND_QUEUE)
+ } else if (tp->repair_queue == TCP_SEND_QUEUE) {
WRITE_ONCE(tp->write_seq, val);
- else if (tp->repair_queue == TCP_RECV_QUEUE) {
+ } else if (tp->repair_queue == TCP_RECV_QUEUE) {
WRITE_ONCE(tp->rcv_nxt, val);
WRITE_ONCE(tp->copied_seq, val);
- }
- else
+ } else {
err = -EINVAL;
+ }
break;

case TCP_REPAIR_OPTIONS:
@@ -3241,9 +3245,10 @@ static int do_tcp_setsockopt(struct sock *sk, int level, int optname,
break;
}
tp->window_clamp = 0;
- } else
+ } else {
tp->window_clamp = val < SOCK_MIN_RCVBUF / 2 ?
SOCK_MIN_RCVBUF / 2 : val;
+ }
break;

case TCP_QUICKACK:
@@ -4186,12 +4191,12 @@ void __init tcp_init(void)
tcp_init_mem();
/* Set per-socket limits to no more than 1/128 the pressure threshold */
limit = nr_free_buffer_pages() << (PAGE_SHIFT - 7);
- max_wshare = min(4UL*1024*1024, limit);
- max_rshare = min(6UL*1024*1024, limit);
+ max_wshare = min(4UL * 1024 * 1024, limit);
+ max_rshare = min(6UL * 1024 * 1024, limit);

init_net.ipv4.sysctl_tcp_wmem[0] = SK_MEM_QUANTUM;
- init_net.ipv4.sysctl_tcp_wmem[1] = 16*1024;
- init_net.ipv4.sysctl_tcp_wmem[2] = max(64*1024, max_wshare);
+ init_net.ipv4.sysctl_tcp_wmem[1] = 16 * 1024;
+ init_net.ipv4.sysctl_tcp_wmem[2] = max(64 * 1024, max_wshare);

init_net.ipv4.sysctl_tcp_rmem[0] = SK_MEM_QUANTUM;
init_net.ipv4.sysctl_tcp_rmem[1] = 131072;
--
2.29.2