Message ID | 1387197631-17240-2-git-send-email-wangweidong1@huawei.com |
---|---|
State | Not Applicable, archived |
Delegated to: | David Miller |
Headers | show |
> From: Wang Weidong > Sent: 16 December 2013 12:40 > We remove a number of unnecessary variables and branches > in TIPC. This patch is cosmetic and does not change the > operation of TIPC in any way. > ... > int __tipc_disconnect(struct tipc_port *tp_ptr) > { > - int res; > - > if (tp_ptr->connected) { > tp_ptr->connected = 0; > /* let timer expire on it's own to avoid deadlock! */ > tipc_nodesub_unsubscribe(&tp_ptr->subscription); > - res = 0; > - } else { > - res = -ENOTCONN; > + return 0; > } > - return res; > + > + return -ENOTCONN; > } IMHO better coded as: if (!tp_ptr->connected) return -ENOTCON; tp_ptr->connected = 0; /* let timer expire on it's own to avoid deadlock! */ tipc_nodesub_unsubscribe(&tp_ptr->subscription); return 0; David -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 2013/12/16 21:33, David Laight wrote: >> From: Wang Weidong >> Sent: 16 December 2013 12:40 >> We remove a number of unnecessary variables and branches >> in TIPC. This patch is cosmetic and does not change the >> operation of TIPC in any way. >> > ... >> int __tipc_disconnect(struct tipc_port *tp_ptr) >> { >> - int res; >> - >> if (tp_ptr->connected) { >> tp_ptr->connected = 0; >> /* let timer expire on it's own to avoid deadlock! */ >> tipc_nodesub_unsubscribe(&tp_ptr->subscription); >> - res = 0; >> - } else { >> - res = -ENOTCONN; >> + return 0; >> } >> - return res; >> + >> + return -ENOTCONN; >> } > > IMHO better coded as: > > if (!tp_ptr->connected) > return -ENOTCON; > > tp_ptr->connected = 0; > /* let timer expire on it's own to avoid deadlock! */ > tipc_nodesub_unsubscribe(&tp_ptr->subscription); > return 0; > > David > > Sure, I will fix it in v2. Thanks. > > > -- > To unsubscribe from this list: send the line "unsubscribe netdev" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c index 09dcd54..92a1533 100644 --- a/net/tipc/name_table.c +++ b/net/tipc/name_table.c @@ -148,8 +148,7 @@ static struct publication *publ_create(u32 type, u32 lower, u32 upper, */ static struct sub_seq *tipc_subseq_alloc(u32 cnt) { - struct sub_seq *sseq = kcalloc(cnt, sizeof(struct sub_seq), GFP_ATOMIC); - return sseq; + return kcalloc(cnt, sizeof(struct sub_seq), GFP_ATOMIC); } /** diff --git a/net/tipc/port.c b/net/tipc/port.c index c081a76..5fd4c8c 100644 --- a/net/tipc/port.c +++ b/net/tipc/port.c @@ -832,17 +832,14 @@ exit: */ int __tipc_disconnect(struct tipc_port *tp_ptr) { - int res; - if (tp_ptr->connected) { tp_ptr->connected = 0; /* let timer expire on it's own to avoid deadlock! */ tipc_nodesub_unsubscribe(&tp_ptr->subscription); - res = 0; - } else { - res = -ENOTCONN; + return 0; } - return res; + + return -ENOTCONN; } /* diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 3b61851..32037c5 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c @@ -239,7 +239,6 @@ static int tipc_sk_create(struct net *net, struct socket *sock, int protocol, int tipc_sock_create_local(int type, struct socket **res) { int rc; - struct sock *sk; rc = sock_create_lite(AF_TIPC, type, 0, res); if (rc < 0) { @@ -248,8 +247,6 @@ int tipc_sock_create_local(int type, struct socket **res) } tipc_sk_create(&init_net, *res, 0, 1); - sk = (*res)->sk; - return 0; } @@ -1311,14 +1308,12 @@ static u32 filter_connect(struct tipc_sock *tsock, struct sk_buff **buf) static unsigned int rcvbuf_limit(struct sock *sk, struct sk_buff *buf) { struct tipc_msg *msg = buf_msg(buf); - unsigned int limit; if (msg_connected(msg)) - limit = sysctl_tipc_rmem[2]; - else - limit = sk->sk_rcvbuf >> TIPC_CRITICAL_IMPORTANCE << - msg_importance(msg); - return limit; + return sysctl_tipc_rmem[2]; + + return sk->sk_rcvbuf >> TIPC_CRITICAL_IMPORTANCE << + msg_importance(msg); } /**