From: Shan Wei <shanwei@cn.fujitsu.com>
To: David Miller <davem@davemloft.net>
Cc: brian.haley@hp.com, netdev@vger.kernel.org
Subject: Re: [PATCH RESEND] ipv6: return with appropriate error code when sending RH0 using setsockopt()
Date: Tue, 16 Sep 2008 15:13:33 +0800 [thread overview]
Message-ID: <48CF5C9D.5090200@cn.fujitsu.com> (raw)
In-Reply-To: <20080911.201458.162553481.davem@davemloft.net>
David Miller 写道:
> From: Shan Wei <shanwei@cn.fujitsu.com>
> Date: Thu, 04 Sep 2008 11:44:10 +0800
>
>> Brian Haley 写道:
>>> Shan Wei wrote:
>>>> diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
>>>> index 4e5eac3..7a58597 100644
>>>> --- a/net/ipv6/ipv6_sockglue.c
>>>> +++ b/net/ipv6/ipv6_sockglue.c
>>>> @@ -353,9 +353,10 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
>>>> goto e_inval;
>>>>
>>>> /* hop-by-hop / destination options are privileged option */
>>>> - retv = -EPERM;
>>>> - if (optname != IPV6_RTHDR && !capable(CAP_NET_RAW))
>>>> + if (optname != IPV6_RTHDR && !capable(CAP_NET_RAW)) {
>>>> + retv = -EPERM;
>>>> break;
>>>> + }
>>> I'm not sure you need this since it doesn't actually change anything,
>>> setting the error before the check just seems like the style in this
>>> function. It will get set to -EINVAL below...
>>>
>> For uncommon expection, if the check is true, we set the error.
>> it will reduce the number of setting retv value.
>
> Do you have some emotional attachment to this change? :-/
>
> The compiler optimizer will make the transformation you claim is
> now possible, all by itself, if it is deemed more optimal.
>
> Never make any claims about how many times something will or will not
> happen in the compiled output without consulting and providing
> examples of the resulting assembler. Otherwise you are just guessing.
>
> This is just a pointless change, and as Brian said it disagrees with
> the way this construct is made in the rest of this function. So
> please take it out of your patch.
sorry for repling late.
maybe what i describe is not explicit.
in this function the style is like this:
case XX:
{
retv = -EPROTO;
if (condition1) break;
...
retv = -EFAULT;
if (condition2) break;
...
retv = -EINVAL;
if (condition3) break;
...
}
when the conditions are all false, the retv value is set three times.
but with the following style, the retv value is not set.
case XX:
{
if (condition1){ retv = -EPROTO;break;}
...
if (condition2){ retv = -EFAULT;break;}
...
if (condition3){ retv = -EINVAL;break;}
...
}
Seting the retv value when expection is occurred almost don't improve
the performance, but it's a little better.
next prev parent reply other threads:[~2008-09-16 7:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-03 8:41 [PATCH RESEND] ipv6: return with appropriate error code when sending RH0 using setsockopt() Shan Wei
2008-09-03 9:23 ` David Miller
2008-09-03 9:41 ` Shan Wei
2008-09-03 18:36 ` Brian Haley
2008-09-04 3:44 ` Shan Wei
2008-09-12 3:14 ` David Miller
2008-09-16 7:13 ` Shan Wei [this message]
2008-09-04 5:53 ` Shan Wei
2008-09-04 13:54 ` Brian Haley
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=48CF5C9D.5090200@cn.fujitsu.com \
--to=shanwei@cn.fujitsu.com \
--cc=brian.haley@hp.com \
--cc=davem@davemloft.net \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.