Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934128AbbELToL (ORCPT ); Tue, 12 May 2015 15:44:11 -0400 Received: from mail-la0-f54.google.com ([209.85.215.54]:36257 "EHLO mail-la0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933852AbbELToJ (ORCPT ); Tue, 12 May 2015 15:44:09 -0400 Message-ID: <55525805.50807@gmail.com> Date: Tue, 12 May 2015 21:44:05 +0200 From: Mateusz Kulikowski User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Joe Perches CC: gregkh@linuxfoundation.org, dan.carpenter@oracle.com, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 01/33] staging: rtl8192e: Declare ethernet addresses as __aligned(2) References: <1431206361-13736-1-git-send-email-mateusz.kulikowski@gmail.com> <1431206361-13736-2-git-send-email-mateusz.kulikowski@gmail.com> <1431210572.22450.78.camel@perches.com> In-Reply-To: <1431210572.22450.78.camel@perches.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2351 Lines: 59 On 10.05.2015 00:29, Joe Perches wrote: > On Sat, 2015-05-09 at 23:18 +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. > [] >> diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c > [] >> @@ -321,7 +321,8 @@ 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}; >> + u8 bMac_Tmp_Addr[ETH_ALEN] __aligned(2) = {0x00, 0xe0, 0x4c, >> + 0x00, 0x00, 0x01}; > > While this is safe, as this follows a u16, it's unnecessary. > > Also, ideally, this would be > u8 foo[ETH_ALEN] = { > 1, 2, 3, 4, 5, 6 > }; > or just left on a single line. I put __aligned to most places to show authors intention and to prevent someone from breaking it by (for example) removing u16 above due some refactoring. If you insist - I will remove it. > >> diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c > [] >> @@ -2573,8 +2573,9 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) >> int ret = -1; >> struct rtllib_device *ieee = priv->rtllib; >> u32 key[4]; >> - u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; >> - u8 zero_addr[6] = {0}; >> + u8 broadcast_addr[ETH_ALEN] __aligned(2) = {0xff, 0xff, 0xff, >> + 0xff, 0xff, 0xff}; >> + u8 zero_addr[ETH_ALEN] __aligned(2) = {0}; > > If these are used only in tests, these are probably better > being removed and using is__ether_addr or maybe > if these used in things other than tests, being converted > to static const so they are not reinitialized on each > call of the function. > zero_addr in fact is used only for comparison - I'll use is_eth_zero_addr; broadcast is used as parameter so will make it static const (and update used functions to accept const ethaddr) Regards, Mateusz -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/