Re: [PATCH net v6 5/5] net: macb: avoid dealing with endianness in macb_set_hwaddr()
From: Simon Horman
Date: Thu Sep 25 2025 - 04:52:41 EST
On Tue, Sep 23, 2025 at 06:00:27PM +0200, Théo Lebrun wrote:
> bp->dev->dev_addr is of type `unsigned char *`. Casting it to a u32
> pointer and dereferencing implies dealing manually with endianness,
> which is error-prone.
>
> Replace by calls to get_unaligned_le32|le16() helpers.
>
> This was found using sparse:
> ⟩ make C=2 drivers/net/ethernet/cadence/macb_main.o
> warning: incorrect type in assignment (different base types)
> expected unsigned int [usertype] bottom
> got restricted __le32 [usertype]
> warning: incorrect type in assignment (different base types)
> expected unsigned short [usertype] top
> got restricted __le16 [usertype]
> ...
>
> Reviewed-by: Sean Anderson <sean.anderson@xxxxxxxxx>
> Signed-off-by: Théo Lebrun <theo.lebrun@xxxxxxxxxxx>
Reviewed-by: Simon Horman <horms@xxxxxxxxxx>