[PATCH 3/3] staging/ozwpan: coding style ether_addr_copy

Greg Kroah-Hartman gregkh at linuxfoundation.org
Thu Mar 13 02:28:21 UTC 2014


On Thu, Mar 13, 2014 at 10:21:44AM +0900, Jérôme Pinot wrote:
> This fixes the following issues detected by checkpatch.pl:
> 
>  WARNING: Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)
>  #220: FILE: drivers/staging/ozwpan/ozcdev.c:220:
>  +              memcpy(g_cdev.active_addr, addr, ETH_ALEN);
> 
>  WARNING: Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)
>  #286: FILE: drivers/staging/ozwpan/ozcdev.c:286:
>  +                      memcpy(addr, g_cdev.active_addr, ETH_ALEN);
> 
>  WARNING: Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)
>  #176: FILE: drivers/staging/ozwpan/ozpd.c:176:
>  +              memcpy(pd->mac_addr, mac_addr, ETH_ALEN);
> 
>  WARNING: Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)
>  #795: FILE: drivers/staging/ozwpan/ozproto.c:795:
>  +              memcpy(&addr[count++], pd->mac_addr, ETH_ALEN);
> 
> Signed-off-by: Jerome Pinot <ngc891 at gmail.com>
> ---
>  drivers/staging/ozwpan/ozcdev.c  | 4 ++--
>  drivers/staging/ozwpan/ozpd.c    | 2 +-
>  drivers/staging/ozwpan/ozproto.c | 2 +-
>  3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/ozwpan/ozcdev.c b/drivers/staging/ozwpan/ozcdev.c
> index 5de5981..10c0a96 100644
> --- a/drivers/staging/ozwpan/ozcdev.c
> +++ b/drivers/staging/ozwpan/ozcdev.c
> @@ -217,7 +217,7 @@ static int oz_set_active_pd(const u8 *addr)
>  	pd = oz_pd_find(addr);
>  	if (pd) {
>  		spin_lock_bh(&g_cdev.lock);
> -		memcpy(g_cdev.active_addr, addr, ETH_ALEN);
> +		ether_addr_copy(g_cdev.active_addr, addr);

Are you sure this will work?

You have to check the alignment of the variable.

Also, this breaks the build, you need to include some kind of .h file to
get this to work, please ALWAYS test your patches to make sure they
don't break things.

greg k-h


More information about the devel mailing list