netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/2] tipc: do some fixups
@ 2013-12-25  2:11 Wang Weidong
  2013-12-25  2:11 ` [PATCH net-next v2 1/2] tipc: make the code look more better Wang Weidong
  2013-12-25  2:11 ` [PATCH net-next v2 2/2] tipc: make the code look more readability Wang Weidong
  0 siblings, 2 replies; 7+ messages in thread
From: Wang Weidong @ 2013-12-25  2:11 UTC (permalink / raw)
  To: jeremy.kalman, jon.maloy, davem; +Cc: David.Laight, netdev

in commit 0cee6bbe06f ("tipc: remove unnecessary variables and conditions")
and commit 3b8401fe9d ("tipc: kill unnecessary goto's") not make the
code best. so fix them, as suggested by David Laight.

v1 -> v2:
  patch1 and patch2 fix the problem "Referring commit purely by
  SHA1 ID is ambiguous" which pointed out by David.

Wang Weidong (2):
  tipc: make the code look more better
  tipc: make the code look more readability

 net/tipc/port.c   | 13 ++++++-------
 net/tipc/socket.c |  7 ++-----
 2 files changed, 8 insertions(+), 12 deletions(-)

-- 
1.7.12

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH net-next v2 1/2] tipc: make the code look more better
  2013-12-25  2:11 [PATCH net-next v2 0/2] tipc: do some fixups Wang Weidong
@ 2013-12-25  2:11 ` Wang Weidong
  2013-12-25  2:42   ` Ying Xue
  2013-12-25  2:11 ` [PATCH net-next v2 2/2] tipc: make the code look more readability Wang Weidong
  1 sibling, 1 reply; 7+ messages in thread
From: Wang Weidong @ 2013-12-25  2:11 UTC (permalink / raw)
  To: jeremy.kalman, jon.maloy, davem; +Cc: David.Laight, netdev

In commit 0cee6bbe06f ("tipc: remove unnecessary variables and conditions")
didn't make the code look best. So fix it. This patch is cosmetic
and does not change the operation of TIPC in any way.

Suggested-by: David Laight <David.Laight@ACULAB.COM>
Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
---
 net/tipc/port.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/net/tipc/port.c b/net/tipc/port.c
index 5fd4c8c..ee81be0 100644
--- a/net/tipc/port.c
+++ b/net/tipc/port.c
@@ -832,14 +832,13 @@ exit:
  */
 int __tipc_disconnect(struct tipc_port *tp_ptr)
 {
-	if (tp_ptr->connected) {
-		tp_ptr->connected = 0;
-		/* let timer expire on it's own to avoid deadlock! */
-		tipc_nodesub_unsubscribe(&tp_ptr->subscription);
-		return 0;
-	}
+	if (!tp_ptr->connected)
+		return -ENOTCONN;
 
-	return -ENOTCONN;
+	tp_ptr->connected = 0;
+	/* let timer expire on it's own to avoid deadlock! */
+	tipc_nodesub_unsubscribe(&tp_ptr->subscription);
+	return 0;
 }
 
 /*
-- 
1.7.12

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH net-next v2 2/2] tipc: make the code look more readability
  2013-12-25  2:11 [PATCH net-next v2 0/2] tipc: do some fixups Wang Weidong
  2013-12-25  2:11 ` [PATCH net-next v2 1/2] tipc: make the code look more better Wang Weidong
@ 2013-12-25  2:11 ` Wang Weidong
  2013-12-25 10:47   ` Sergei Shtylyov
  1 sibling, 1 reply; 7+ messages in thread
From: Wang Weidong @ 2013-12-25  2:11 UTC (permalink / raw)
  To: jeremy.kalman, jon.maloy, davem; +Cc: David.Laight, netdev

In commit 3b8401fe9d ("tipc: kill unnecessary goto's") didn't make
the code look most readability, so fix it. This patch is cosmetic
and does not change the operation of TIPC in any way.

Suggested-by: David Laight <David.Laight@ACULAB.COM>
Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
---
 net/tipc/socket.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 83f466e..5efdeef 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -751,13 +751,10 @@ static int send_stream(struct kiocb *iocb, struct socket *sock,
 
 	/* Handle special cases where there is no connection */
 	if (unlikely(sock->state != SS_CONNECTED)) {
-		res = -ENOTCONN;
-
 		if (sock->state == SS_UNCONNECTED)
 			res = send_packet(NULL, sock, m, total_len);
-		else if (sock->state == SS_DISCONNECTING)
-			res = -EPIPE;
-
+		else
+			res = sock->state == SS_DISCONNECTING ? -EPIPE : -ENOTCONN;
 		goto exit;
 	}
 
-- 
1.7.12

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next v2 1/2] tipc: make the code look more better
  2013-12-25  2:11 ` [PATCH net-next v2 1/2] tipc: make the code look more better Wang Weidong
@ 2013-12-25  2:42   ` Ying Xue
  2013-12-25  2:52     ` Wang Weidong
  0 siblings, 1 reply; 7+ messages in thread
From: Ying Xue @ 2013-12-25  2:42 UTC (permalink / raw)
  To: Wang Weidong, jeremy.kalman, jon.maloy, davem; +Cc: David.Laight, netdev

On 12/25/2013 10:11 AM, Wang Weidong wrote:
> In commit 0cee6bbe06f ("tipc: remove unnecessary variables and conditions")
> didn't make the code look best. So fix it. This patch is cosmetic
> and does not change the operation of TIPC in any way.
> 

I cannot see what value the patch does provide.

Actually the original logic seems better understandable for us because
it immediately lets us know how to do if "tp_ptr->connected" is true.
Instead the patch has a little negative effect on performance because
"tp_ptr->connected" is true in most time.

Regards,
Ying

> Suggested-by: David Laight <David.Laight@ACULAB.COM>
> Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
> ---
>  net/tipc/port.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/net/tipc/port.c b/net/tipc/port.c
> index 5fd4c8c..ee81be0 100644
> --- a/net/tipc/port.c
> +++ b/net/tipc/port.c
> @@ -832,14 +832,13 @@ exit:
>   */
>  int __tipc_disconnect(struct tipc_port *tp_ptr)
>  {
> -	if (tp_ptr->connected) {
> -		tp_ptr->connected = 0;
> -		/* let timer expire on it's own to avoid deadlock! */
> -		tipc_nodesub_unsubscribe(&tp_ptr->subscription);
> -		return 0;
> -	}
> +	if (!tp_ptr->connected)
> +		return -ENOTCONN;
>  
> -	return -ENOTCONN;
> +	tp_ptr->connected = 0;
> +	/* let timer expire on it's own to avoid deadlock! */
> +	tipc_nodesub_unsubscribe(&tp_ptr->subscription);
> +	return 0;
>  }
>  
>  /*
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next v2 1/2] tipc: make the code look more better
  2013-12-25  2:42   ` Ying Xue
@ 2013-12-25  2:52     ` Wang Weidong
  0 siblings, 0 replies; 7+ messages in thread
From: Wang Weidong @ 2013-12-25  2:52 UTC (permalink / raw)
  To: Ying Xue, Stephens, Allan, jon.maloy, davem; +Cc: David.Laight, netdev

On 2013/12/25 10:42, Ying Xue wrote:
> On 12/25/2013 10:11 AM, Wang Weidong wrote:
>> In commit 0cee6bbe06f ("tipc: remove unnecessary variables and conditions")
>> didn't make the code look best. So fix it. This patch is cosmetic
>> and does not change the operation of TIPC in any way.
>>
> 
> I cannot see what value the patch does provide.
> 
> Actually the original logic seems better understandable for us because
> it immediately lets us know how to do if "tp_ptr->connected" is true.
> Instead the patch has a little negative effect on performance because
> "tp_ptr->connected" is true in most time.
> 
Sure, You are right. So just ignore it.

Thanks,
Wang

> Regards,
> Ying
> 
>> Suggested-by: David Laight <David.Laight@ACULAB.COM>
>> Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
>> ---
>>  net/tipc/port.c | 13 ++++++-------
>>  1 file changed, 6 insertions(+), 7 deletions(-)
>>
>> diff --git a/net/tipc/port.c b/net/tipc/port.c
>> index 5fd4c8c..ee81be0 100644
>> --- a/net/tipc/port.c
>> +++ b/net/tipc/port.c
>> @@ -832,14 +832,13 @@ exit:
>>   */
>>  int __tipc_disconnect(struct tipc_port *tp_ptr)
>>  {
>> -	if (tp_ptr->connected) {
>> -		tp_ptr->connected = 0;
>> -		/* let timer expire on it's own to avoid deadlock! */
>> -		tipc_nodesub_unsubscribe(&tp_ptr->subscription);
>> -		return 0;
>> -	}
>> +	if (!tp_ptr->connected)
>> +		return -ENOTCONN;
>>  
>> -	return -ENOTCONN;
>> +	tp_ptr->connected = 0;
>> +	/* let timer expire on it's own to avoid deadlock! */
>> +	tipc_nodesub_unsubscribe(&tp_ptr->subscription);
>> +	return 0;
>>  }
>>  
>>  /*
>>
> 
> 
> .
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next v2 2/2] tipc: make the code look more readability
  2013-12-25  2:11 ` [PATCH net-next v2 2/2] tipc: make the code look more readability Wang Weidong
@ 2013-12-25 10:47   ` Sergei Shtylyov
  2013-12-25 12:27     ` Wang Weidong
  0 siblings, 1 reply; 7+ messages in thread
From: Sergei Shtylyov @ 2013-12-25 10:47 UTC (permalink / raw)
  To: Wang Weidong, jeremy.kalman, jon.maloy, davem; +Cc: David.Laight, netdev

Hello.

On 25-12-2013 6:11, Wang Weidong wrote:

> In commit 3b8401fe9d ("tipc: kill unnecessary goto's") didn't make
> the code look most readability,

    Only "readable". The same error in the subject.

> so fix it. This patch is cosmetic
> and does not change the operation of TIPC in any way.

> Suggested-by: David Laight <David.Laight@ACULAB.COM>
> Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
> ---
>   net/tipc/socket.c | 7 ++-----
>   1 file changed, 2 insertions(+), 5 deletions(-)

WBR, Sergei

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH net-next v2 2/2] tipc: make the code look more readability
  2013-12-25 10:47   ` Sergei Shtylyov
@ 2013-12-25 12:27     ` Wang Weidong
  0 siblings, 0 replies; 7+ messages in thread
From: Wang Weidong @ 2013-12-25 12:27 UTC (permalink / raw)
  To: Sergei Shtylyov, jeremy.kalman, jon.maloy, davem; +Cc: David.Laight, netdev

From: Wang Weidong <wangweidong1@huawei.com>

On 2013/12/25 18:47, Sergei Shtylyov wrote:
> Hello.
>
> On 25-12-2013 6:11, Wang Weidong wrote:
>
>> In commit 3b8401fe9d ("tipc: kill unnecessary goto's") didn't make
>> the code look most readability,
>
>     Only "readable". The same error in the subject.
>
Thanks. I will fix it in v3.

Regards,
Wang

>> so fix it. This patch is cosmetic
>> and does not change the operation of TIPC in any way.
>
>> Suggested-by: David Laight <David.Laight@ACULAB.COM>
>> Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
>> ---
>>   net/tipc/socket.c | 7 ++-----
>>   1 file changed, 2 insertions(+), 5 deletions(-)
>
> WBR, Sergei
>
> --
> 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-12-25 12:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-25  2:11 [PATCH net-next v2 0/2] tipc: do some fixups Wang Weidong
2013-12-25  2:11 ` [PATCH net-next v2 1/2] tipc: make the code look more better Wang Weidong
2013-12-25  2:42   ` Ying Xue
2013-12-25  2:52     ` Wang Weidong
2013-12-25  2:11 ` [PATCH net-next v2 2/2] tipc: make the code look more readability Wang Weidong
2013-12-25 10:47   ` Sergei Shtylyov
2013-12-25 12:27     ` Wang Weidong

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).