Re: [PATCH net-next v3 2/2] net: thunderbolt: Use bitwise types in the struct thunderbolt_ip_frame_header

From: Andy Shevchenko
Date: Wed Nov 30 2022 - 09:13:15 EST


On Wed, Nov 30, 2022 at 02:58:31PM +0200, Mika Westerberg wrote:
> On Wed, Nov 30, 2022 at 02:36:13PM +0200, Andy Shevchenko wrote:
> > The main usage of the struct thunderbolt_ip_frame_header is to handle
> > the packets on the media layer. The header is bound to the protocol
> > in which the byte ordering is crucial. However the data type definition
> > doesn't use that and sparse is unhappy, for example (17 altogether):
> >
> > .../thunderbolt.c:718:23: warning: cast to restricted __le32
> >
> > .../thunderbolt.c:966:42: warning: incorrect type in assignment (different base types)
> > .../thunderbolt.c:966:42: expected unsigned int [usertype] frame_count
> > .../thunderbolt.c:966:42: got restricted __le32 [usertype]
> >
> > Switch to the bitwise types in the struct thunderbolt_ip_frame_header to
> > reduce this, but not completely solving (9 left), because the same data
> > type is used for Rx header handled locally (in CPU byte order).
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
>
> Looks good to me. I assume you tested this against non-Linux OS to
> ensure nothing broke? ;-)

Oh, no. It's compile tested only. And since we are using leXX_to_cpu() against
fields in that data structure I assume that it won't be any functional issue
with this. It's all about strict type checking.

> Acked-by: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx>

Thank you!

--
With Best Regards,
Andy Shevchenko