[ovs-dev] [PATCH 5/6] datapath: Update IPv6 parsing code for kernel style.

Jesse Gross jesse at nicira.com
Thu Mar 3 20:21:59 UTC 2011


On Thu, Mar 3, 2011 at 10:55 AM, Ben Pfaff <blp at nicira.com> wrote:
> On Wed, Mar 02, 2011 at 07:20:34PM -0800, Jesse Gross wrote:
>> Fixes a number of minor elements in the IPv6 extraction and
>> parsing code to better conform to kernel style.  Examples include
>> using kernel types/functions, adding line breaks, and using
>> unlikely() macros.  There is no functional change.
>>
>> Signed-off-by: Jesse Gross <jesse at nicira.com>
>
> I see some overparenthesization is still here, e.g.
>        if (icmp->icmp6_code == 0 &&
>            ((icmp->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION) ||
>             (icmp->icmp6_type == NDISC_NEIGHBOUR_ADVERTISEMENT))) {
> could be reduced to:
>        if (icmp->icmp6_code == 0 &&
>            (icmp->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION ||
>             icmp->icmp6_type == NDISC_NEIGHBOUR_ADVERTISEMENT)) {
> I find the latter easier to read but it's a judgment call of course.
>
> As another example:
>                        if (unlikely(!opt_len || (opt_len > icmp_len)))
> could be:
>                        if (unlikely(!opt_len || opt_len > icmp_len))

I agree that it is easier to read this way, so I dropped the extra parentheses.

>
> Here, I think that kernel style calls for && to be at end of line:
>> +                                && opt_len == 8) {
>
> Ditto here:
>> +                         && swkey->tp_src != htons(NDISC_NEIGHBOUR_ADVERTISEMENT))

I usually put && at the end of the line because I find it easier to
read; I don't think that kernel style prescribes one way or the other
(there were some arguments on LKML a while back about whether it
should).  In these cases I did it this way to avoid long lines.




More information about the dev mailing list