diff mbox series

[v2,28/29] staging: wilc1000: avoid spaces preferred around checkpatch issue

Message ID 1537424620-6982-29-git-send-email-ajay.kathat@microchip.com (mailing list archive)
State Not Applicable
Delegated to: Kalle Valo
Headers show
Series staging: wilc1000: avoid static variables and cleanup changes | expand

Commit Message

Ajay Singh Sept. 20, 2018, 6:23 a.m. UTC
Cleanup patch to add extra spaces around the '/' to avoid the below
checkpatch warning.

'spaces preferred around that '/' (ctx:VxV)'

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
---
 drivers/staging/wilc1000/linux_wlan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Joe Perches Sept. 20, 2018, 9:57 a.m. UTC | #1
On Thu, 2018-09-20 at 11:53 +0530, Ajay Singh wrote:
> Cleanup patch to add extra spaces around the '/' to avoid the below
> checkpatch warning.
> 
> 'spaces preferred around that '/' (ctx:VxV)'
> 
> Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
> ---
>  drivers/staging/wilc1000/linux_wlan.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
> index 695d5b2..29c1317 100644
> --- a/drivers/staging/wilc1000/linux_wlan.c
> +++ b/drivers/staging/wilc1000/linux_wlan.c
> @@ -823,7 +823,7 @@ static void wilc_set_multicast_list(struct net_device *dev)
>  
>  	netdev_for_each_mc_addr(ha, dev) {
>  		memcpy(mc_list + i, ha->addr, ETH_ALEN);
> -		netdev_dbg(dev, "Entry[%d]: %x:%x:%x:%x:%x:%x\n", i/ETH_ALEN,
> +		netdev_dbg(dev, "Entry[%d]: %x:%x:%x:%x:%x:%x\n", i / ETH_ALEN,
>  			   mc_list[i], mc_list[i + 1], mc_list[i + 2],
>  			   mc_list[i + 3], mc_list[i + 4], mc_list[i + 5]);
>  		i += ETH_ALEN;

Probably better using the vsprintf %pM extension:

	netdev_dbg(dev, Entry[%d]: %pM\n", i / ETH_ALEN, mc_list + i);

though I would also suggest using another temporary
pointer instead of an offset and divisions.

Something like:

o use kmalloc_array
o remove unnecessary res
o add u8 *cur_mc
o use i as index

---
diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index 49afda669393..2b4c92319507 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -802,9 +802,9 @@ static void wilc_set_multicast_list(struct net_device *dev)
 {
 	struct netdev_hw_addr *ha;
 	struct wilc_vif *vif = netdev_priv(dev);
-	int i = 0;
+	int i;
 	u8 *mc_list;
-	int res;
+	u8 *cur_mc;
 
 	if (dev->flags & IFF_PROMISC)
 		return;
@@ -820,20 +820,20 @@ static void wilc_set_multicast_list(struct net_device *dev)
 		return;
 	}
 
-	mc_list = kmalloc(dev->mc.count * ETH_ALEN, GFP_KERNEL);
+	mc_list = kmalloc_array(dev->mc.count, ETH_ALEN, GFP_KERNEL);
 	if (!mc_list)
 		return;
 
+	cur_mc = mc_list;
+	i = 0;
 	netdev_for_each_mc_addr(ha, dev) {
-		memcpy(mc_list + i, ha->addr, ETH_ALEN);
-		netdev_dbg(dev, "Entry[%d]: %x:%x:%x:%x:%x:%x\n", i/ETH_ALEN,
-			   mc_list[i], mc_list[i + 1], mc_list[i + 2],
-			   mc_list[i + 3], mc_list[i + 4], mc_list[i + 5]);
-		i += ETH_ALEN;
+		memcpy(cur_mc, ha->addr, ETH_ALEN);
+		netdev_dbg(dev, "Entry[%d]: %pM\n", i, cur_mc);
+		i++;
+		cur_mc += ETH_ALEN;
 	}
 
-	res = wilc_setup_multicast_filter(vif, true, dev->mc.count, mc_list);
-	if (res)
+	if (wilc_setup_multicast_filter(vif, true, dev->mc.count, mc_list))
 		kfree(mc_list);
 }
Ajay Singh Sept. 20, 2018, 11:21 a.m. UTC | #2
On Thu, 20 Sep 2018 02:57:21 -0700
Joe Perches <joe@perches.com> wrote:

> On Thu, 2018-09-20 at 11:53 +0530, Ajay Singh wrote:
> > Cleanup patch to add extra spaces around the '/' to avoid the below
> > checkpatch warning.
> > 
> > 'spaces preferred around that '/' (ctx:VxV)'
> > 
> > Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
> > ---
> >  drivers/staging/wilc1000/linux_wlan.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/wilc1000/linux_wlan.c
> > b/drivers/staging/wilc1000/linux_wlan.c index 695d5b2..29c1317
> > 100644 --- a/drivers/staging/wilc1000/linux_wlan.c
> > +++ b/drivers/staging/wilc1000/linux_wlan.c
> > @@ -823,7 +823,7 @@ static void wilc_set_multicast_list(struct
> > net_device *dev) 
> >  	netdev_for_each_mc_addr(ha, dev) {
> >  		memcpy(mc_list + i, ha->addr, ETH_ALEN);
> > -		netdev_dbg(dev, "Entry[%d]: %x:%x:%x:%x:%x:%x\n",
> > i/ETH_ALEN,
> > +		netdev_dbg(dev, "Entry[%d]: %x:%x:%x:%x:%x:%x\n",
> > i / ETH_ALEN, mc_list[i], mc_list[i + 1], mc_list[i + 2],
> >  			   mc_list[i + 3], mc_list[i + 4],
> > mc_list[i + 5]); i += ETH_ALEN;  
> 
> Probably better using the vsprintf %pM extension:
> 
> 	netdev_dbg(dev, Entry[%d]: %pM\n", i / ETH_ALEN, mc_list + i);
> 
> though I would also suggest using another temporary
> pointer instead of an offset and divisions.
> 
> Something like:
> 
> o use kmalloc_array
> o remove unnecessary res
> o add u8 *cur_mc
> o use i as index

Hi Joe,

Thanks for your suggestion and sharing the code changes.
I agree, it looks better with your modification.


Do I need to resend the updated patch series by including your
changes or can this patch be applied from your mail ?

Regards,
Ajay
diff mbox series

Patch

diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
index 695d5b2..29c1317 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -823,7 +823,7 @@  static void wilc_set_multicast_list(struct net_device *dev)
 
 	netdev_for_each_mc_addr(ha, dev) {
 		memcpy(mc_list + i, ha->addr, ETH_ALEN);
-		netdev_dbg(dev, "Entry[%d]: %x:%x:%x:%x:%x:%x\n", i/ETH_ALEN,
+		netdev_dbg(dev, "Entry[%d]: %x:%x:%x:%x:%x:%x\n", i / ETH_ALEN,
 			   mc_list[i], mc_list[i + 1], mc_list[i + 2],
 			   mc_list[i + 3], mc_list[i + 4], mc_list[i + 5]);
 		i += ETH_ALEN;