Re: [bug report] sfc: add functions to insert encap matches into the MAE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 31, 2023 at 11:35:42AM +0100, Edward Cree wrote:
> On 31/03/2023 07:54, Dan Carpenter wrote:
> > Hello Edward Cree,
> > 
> > The patch 2245eb0086d8: "sfc: add functions to insert encap matches
> > into the MAE" from Mar 27, 2023, leads to the following Smatch static
> > checker warning:
> > 
> > 	drivers/net/ethernet/sfc/mae.c:1002 efx_mae_register_encap_match()
> > 	warn: this cast is a no-op
> ...
> >     998         MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_ENC_FIELD_PAIRS_ENC_ETHER_TYPE_BE_MASK,
> >     999                                 ~(__be16)0);
> > 
> > But for these ones the u16 is type promoted to int and so ~0 is negative
> > one and will be sign extended.  The cast does nothing.
> > 
> >     1000         MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_ENC_FIELD_PAIRS_ENC_L4_DPORT_BE,
> >     1001                                 encap->udp_dport);
> > --> 1002         MCDI_STRUCT_SET_WORD_BE(match_crit, MAE_ENC_FIELD_PAIRS_ENC_L4_DPORT_BE_MASK,
> >     1003                                 ~(__be16)0);
> > 
> > Same.
> 
> The casts are there for Sparse reasons (endianness), rather than
>  particularly caring about the size (although that conveniently
>  documents to the reader the width of the MCDI field).
> We could instead use (__be16)~0 but I believe some versions of
>  sparse will warn on this (I forget the details).
> 
> To the compiler (i.e. outside of sparse) the cast is indeed a
>  no-op, but this is fine.  I would consider this Smatch warning
>  a false positive; lmk if you disagree.

Fair enough...  I didn't know that Sparse printed a warning for this.

regards,
dan carpenter





[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux