[PATCH v4 02/35] staging: rtl8192e: Declare ethernet addresses as __aligned(2)

Dan Carpenter dan.carpenter at oracle.com
Mon May 25 13:53:20 UTC 2015


On Thu, May 21, 2015 at 05:53:15PM +0200, Mateusz Kulikowski wrote:
> Add __aligned(2) into ethernet addresses allocated on stack or in non-packed
> structures. Use ETH_ALEN as array length in places where it was hardcoded to 6.

To be honest, this patch makes me hate the stupid ether_addr_copy()
checkpatch warnings even more than I hated it before.  Do we really need
to add __aligned(2) to everything?  Is there no other option which isn't
as horrible?

We could introduce a new typedef:

typedef struct {
        char addr[6] __aligned(2);
} eth_addr_t;

Introducing a new kind of type is maybe a bit much just to make
checkpatch.pl happy but so is putting __aligned(2) everywhere.

Or maybe we could make a new ether_addr_copy() implementation that uses
preprocessor macros and chooses the right kind of implementation?

> diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
> index aad5cc9..9c6dc82 100644
> --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
> +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
> @@ -321,7 +321,9 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
>  	u8 ICVer8192, ICVer8256;
>  	u16 i, usValue, IC_Version;
>  	u16 EEPROMId;
> -	u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01};
> +	static const u8 bMac_Tmp_Addr[ETH_ALEN] __aligned(2) = {
> +					0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01
> +	};

What's up with the whacky indenting?

regards,
dan carpenter



More information about the devel mailing list