[Intel-wired-lan] [PATCH][V2] i40evf: remove redundant array comparisons to 0 checks

Andy Shevchenko andy.shevchenko at gmail.com
Mon Feb 19 13:40:30 UTC 2018


On Mon, Feb 19, 2018 at 12:23 PM, Colin King <colin.king at canonical.com> wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> The checks to see if key->dst.s6_addr and key->src.s6_addr are null
> pointers are redundant because these are constant size arrays and
> so the checks always return true.  Fix this by removing the redundant
> checks.   Also replace filter->f with vf, allowing wide lines to be
> condensed and to rejoin some split wide lines.
>
> Detected by CoverityScan, CID#1465279 ("Array compared to 0")
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---

Changelog?


>         u16 addr_type = 0;
>         u16 n_proto = 0;
>         int i = 0;
> +       struct virtchnl_filter *vf = &filter->f;
>

Perhaps perserve reversed xmas tree order?


> -                       filter->f.flow_type = VIRTCHNL_TCP_V6_FLOW;
> +                       vf->flow_type = VIRTCHNL_TCP_V6_FLOW;

No need to touch.

>                 }
>
>                 if (key->ip_proto != IPPROTO_TCP) {
> @@ -2585,9 +2586,8 @@ static int i40evf_parse_cls_flower(struct i40evf_adapter *adapter,
>                             is_multicast_ether_addr(key->dst)) {
>                                 /* set the mask if a valid dst_mac address */
>                                 for (i = 0; i < ETH_ALEN; i++)
> -                                       filter->f.mask.tcp_spec.dst_mac[i] |=
> -                                                                       0xff;
> -                               ether_addr_copy(filter->f.data.tcp_spec.dst_mac,
> +                                       vf->mask.tcp_spec.dst_mac[i] |= 0xff;
> +                               ether_addr_copy(vf->data.tcp_spec.dst_mac,
>                                                 key->dst);

Instead, keep two pointers:
 ... *pointer_mask = &vf->mask.tcp_spec;
 ... *pointer_data = &vf->data.tcp_spec;


-- 
With Best Regards,
Andy Shevchenko


More information about the Intel-wired-lan mailing list