[ovs-dev] [PATCH] checkpatch.py: Fix false positive on if/when/for
Eric Garver
e at erig.me
Thu Mar 16 14:55:09 UTC 2017
On Thu, Mar 16, 2017 at 10:37:00AM -0400, Aaron Conole wrote:
> Eric Garver <e at erig.me> writes:
>
> > We need to use == instead of the is operator. If you're unlucky it may
> > fail because they're not exactly the same object, but hold the same
> > value.
> >
> > Example false positive:
> >
> > E(120): Inappropriate bracing around statement
> >
> > + if (0 != nl_attr_get_u8(vxlan[IFLA_VXLAN_LEARNING])
>
> I count an unbalanced brace. There may be something wrong, but at least
> from the example, I don't see it.
>
> Can you include a bit more context? Perhaps the hunk that failed?
It's from a multi-line if statement.
if (0 != nl_attr_get_u8(vxlan[IFLA_VXLAN_LEARNING])
|| 1 != nl_attr_get_u8(vxlan[IFLA_VXLAN_COLLECT_METADATA])
|| 1 != nl_attr_get_u8(vxlan[IFLA_VXLAN_UDP_ZERO_CSUM6_RX])
|| (tnl_cfg->dst_port !=
nl_attr_get_be16(vxlan[IFLA_VXLAN_PORT]))) {
err = EINVAL;
}
In some cases the check
if letter is '(':
evaluates to false and balanced_parens() unexpectedly returns true, as
such if_and_for_end_with_bracket_check() returns False because there is
no { at the end of the line.
I could not reproduce this manually in the interpreter. But adding print
statements inside the check for '(' results in zero prints. So it must
have something to do with string/char caching.
$ python --version
Python 2.7.5
More information about the dev
mailing list