From: Wang Weidong <weidong1991.wang@gmail.com>
To: David Laight <David.Laight@ACULAB.COM>,
jon.maloy@ericsson.com, allan.stephens@windriver.com,
davem@davemloft.net
Cc: erik.hugne@ericsson.com, maloy@donjonn.com, netdev@vger.kernel.org
Subject: Re: [PATCH net-next 2/4] tipc: kill unnecessary goto's
Date: Mon, 16 Dec 2013 22:19:47 +0800 [thread overview]
Message-ID: <52AF0C03.40409@gmail.com> (raw)
In-Reply-To: <AE90C24D6B3A694183C094C60CF0A2F6026B7495@saturn3.aculab.com>
From: Wang weidong <wangweidong1@huawei.com>
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 <jon.maloy@ericsson.com>
>> Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
>> Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
>> ---
>> 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 majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2013-12-16 14:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-16 12:40 [PATCH RESEND net-next 0/4] tipc: do some clean up Wang Weidong
2013-12-16 12:40 ` [PATCH net-next 1/4] tipc: remove unnecessary variables and conditions Wang Weidong
2013-12-16 13:33 ` David Laight
2013-12-16 14:16 ` Wang Weidong
2013-12-16 12:40 ` [PATCH net-next 2/4] tipc: kill unnecessary goto's Wang Weidong
2013-12-16 13:30 ` David Laight
2013-12-16 14:19 ` Wang Weidong [this message]
2013-12-16 18:01 ` David Miller
2013-12-17 6:00 ` Wang Weidong
2013-12-16 12:40 ` [PATCH net-next 3/4] tipc: Use <linux/uaccess.h> instead of <asm/uaccess.h> Wang Weidong
2013-12-16 12:40 ` [PATCH net-next 4/4] tipc: change lock_sock order in connect() Wang Weidong
2013-12-16 17:58 ` [PATCH RESEND net-next 0/4] tipc: do some clean up David Miller
2013-12-17 1:18 ` Wang Weidong
-- strict thread matches above, loose matches on Subject: below --
2013-12-12 1:36 [PATCH " Wang Weidong
2013-12-12 1:36 ` [PATCH net-next 2/4] tipc: kill unnecessary goto's Wang Weidong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52AF0C03.40409@gmail.com \
--to=weidong1991.wang@gmail.com \
--cc=David.Laight@ACULAB.COM \
--cc=allan.stephens@windriver.com \
--cc=davem@davemloft.net \
--cc=erik.hugne@ericsson.com \
--cc=jon.maloy@ericsson.com \
--cc=maloy@donjonn.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).