Subject: Re: [PATCH net-next 2/4] tipc: kill unnecessary goto's

From: Wang Weidong <[email-masked]>
Date: Mon, 16 Dec 2013 22:19:47 +0800

From: Wang weidong <[email-masked]>

On 2013/12/16 21:30, David Laight wrote:
>> From: Wang Weidong
>> Sent: 16 December 2013 12:40
>> Remove a number of needless 'goto exit' in send_stream
>> when the socket is in an unconnected state.
>> This patch is cosmetic and does not alter the operation of
>> TIPC in any way.
>>
>> Reviewed-by: Jon Maloy <[email-masked]>
>> Reviewed-by: Erik Hugne <[email-masked]>
>> Signed-off-by: Wang Weidong <[email-masked]>
>> ---
>>   net/tipc/socket.c | 14 ++++++--------
>>   1 file changed, 6 insertions(+), 8 deletions(-)
>>
>> diff --git a/net/tipc/socket.c b/net/tipc/socket.c
>> index 32037c5..844bf34 100644
>> --- a/net/tipc/socket.c
>> +++ b/net/tipc/socket.c
>> @@ -751,16 +751,14 @@ static int send_stream(struct kiocb *iocb, struct socket *sock,
>>
>>   	/* Handle special cases where there is no connection */
>>   	if (unlikely(sock->state != SS_CONNECTED)) {
>> -		if (sock->state == SS_UNCONNECTED) {
>> +		res = -ENOTCONN;
>> +
>> +		if (sock->state == SS_UNCONNECTED)
>>   			res = send_packet(NULL, sock, m, total_len);
>> -			goto exit;
>> -		} else if () {
>> +		else if (sock->state == SS_DISCONNECTING)
>>   			res = -EPIPE;
>> -			goto exit;
>> -		} else {
>> -			res = -ENOTCONN;
>> -			goto exit;
>> -		}
>> +
>> +		goto exit;
>
> I'm not sure that 'removing needless gotos' is a good description of the change.
> Possibly the code is easier to read with only one goto, ymmv.

I thinks so.

> You could remove the 'else' after the 'goto'.
> Maybe the easiest to read is:
> 	if (sock->state == SS_UNCONNECTED)
> 		res = send_packet(NULL, sock, m, total_len);
> 	else
> 		res = sock->state == SS_DISCONNECTING ? -EPIPE : -ENOTCONN;
> 	goto exit;
>
> 	David
>
Thanks for your suggestion. I will fix it too.

Regards.
Wang
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to [email-masked]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>