Re: [PATCH] Staging: rtl8712: Prefer ether_addr_copy

From: Joe Perches
Date: Wed Aug 31 2016 - 13:34:30 EST


On Wed, 2016-08-31 at 22:48 +0530, Mani Sadhasivam wrote:
> This patch fixes the checkpatch.pl warning to prefer
> ether_addr_copy over memcpy

If you've verified that src & dst are _always_ __aligned(2),
(have you?, if so, please show that in the commit message)
then the other uses of memcmp and such should also be converted.

> diff --git a/drivers/staging/rtl8712/rtl871x_recv.c b/drivers/staging/rtl8712/rtl871x_recv.c
[]
> @@ -352,11 +352,11 @@ static sint sta2sta_data_frame(struct _adapter *adapter,
>   sta_addr = pattrib->src;
>   }
>   } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) {
> - memcpy(pattrib->dst, GetAddr1Ptr(ptr), ETH_ALEN);
> - memcpy(pattrib->src, GetAddr2Ptr(ptr), ETH_ALEN);
> - memcpy(pattrib->bssid, GetAddr3Ptr(ptr), ETH_ALEN);
> - memcpy(pattrib->ra, pattrib->dst, ETH_ALEN);
> - memcpy(pattrib->ta, pattrib->src, ETH_ALEN);
> + ether_addr_copy(pattrib->dst, GetAddr1Ptr(ptr));
> + ether_addr_copy(pattrib->src, GetAddr2Ptr(ptr));
> + ether_addr_copy(pattrib->bssid, GetAddr3Ptr(ptr));
> + ether_addr_copy(pattrib->ra, pattrib->dst);
> + ether_addr_copy(pattrib->ta, pattrib->src);

[etc...]