Skip to contentSkip to conversation

staging: slicoss: Fix prefer ether_addr_copy over memcpy

PATCH In review Joel Pelaez Jorge 4 participants 4 messages Mar 18, 2014 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: slicoss: Fix prefer ether_addr_copy over memcpy

This patch fixes the following checkpatch.pl issues caused by the new function: ether_addr_copy

---

drivers/staging/slicoss/slicoss.c +1 -1
index 12aafe3..4ff39aa 100644
@@ -2313,7 +2313,7 @@ static int slic_mcast_add_list(struct adapter *adapter, char *address)
     if (mcaddr == NULL)
         return 1;
 
-    memcpy(mcaddr->address, address, ETH_ALEN);
+    ether_addr_copy(mcaddr->address, address);
 
     mcaddr->next = adapter->mcastaddrs;
     adapter->mcastaddrs = mcaddr;
#1 lore raw
Quoted 12 lines · Joel Pelaez Jorge

This patch fixes the following checkpatch.pl issues caused by the new
function: ether_addr_copy

---

drivers/staging/slicoss/slicoss.c +0 -0
index 12aafe3..4ff39aa 100644

drivers/staging/slicoss/slicoss.c static int slic_mcast_add_list(struct adapter · line 2317

Quoted 6 lines
drivers/staging/slicoss/slicoss.c +1 -1
@@ -2313,7 +2313,7 @@ static int slic_mcast_add_list(struct adapter
 *adapter, char *address)
      if (mcaddr == NULL)
          return 1;
 
-    memcpy(mcaddr->address, address, ETH_ALEN);
+    ether_addr_copy(mcaddr->address, address);

In addition to this, there are the same cases like this, in this file as below. Please search other same cases. For instance, 'grep' will be a good way to find it.

static void slic_adapter_set_hwaddr(struct adapter *adapter)

{
        struct sliccard *card = adapter->card;

        if ((adapter->card) && (card->config_set)) {
                memcpy(adapter->macaddr,
                       card->config.MacInfo[adapter->functionnumber].macaddrA,
                       sizeof(struct slic_config_mac));
                if (is_zero_ether_addr(adapter->currmacaddr))
                        memcpy(adapter->currmacaddr, adapter->macaddr,
                               ETH_ALEN);
                if (adapter->netdev)
                        memcpy(adapter->netdev->dev_addr, adapter->currmacaddr,
                               ETH_ALEN);
        }
}

Joe Perches,
These are not spotted by checkpatch.pl.
However, after modifying it as below, checkpatch warnings are printed. Would you confirm it?

	if (is_zero_ether_addr(adapter->currmacaddr))
		memcpy(adapter->currmacaddr, adapter->macaddr, ETH_ALEN);
	if (adapter->netdev)
		memcpy(adapter->netdev->dev_addr, adapter->currmacaddr, ETH_ALEN);
	}

Best regards,
Jingoo Han

Quoted 3 lines
drivers/staging/slicoss/slicoss.c +0 -0
      mcaddr->next = adapter->mcastaddrs;
      adapter->mcastaddrs = mcaddr;
#2 lore raw
Quoted 3 lines · Jingoo Han

In addition to this, there are the same cases like this, in this file as below. Please search other same cases. For instance, 'grep' will be a good way to find it.

[]

Quoted 3 lines

static void slic_adapter_set_hwaddr(struct adapter *adapter)

{
        struct sliccard *card = adapter->card;

[]

Quoted 9 lines
                if (is_zero_ether_addr(adapter->currmacaddr))
                        memcpy(adapter->currmacaddr, adapter->macaddr,
                               ETH_ALEN);
                if (adapter->netdev)
                        memcpy(adapter->netdev->dev_addr, adapter->currmacaddr,
                               ETH_ALEN);
        }
}
Quoted 4 lines

Joe Perches,
These are not spotted by checkpatch.pl.
However, after modifying it as below, checkpatch warnings are printed. Would you confirm it?

If it's not on a single line, checkpatch won't find it.

#3 lore raw
In reply to Joel Pelaez Jorge
Quoted 19 lines · Joel Pelaez Jorge

This patch fixes the following checkpatch.pl issues caused by the new
function: ether_addr_copy

---

drivers/staging/slicoss/slicoss.c +1 -1
index 12aafe3..4ff39aa 100644
@@ -2313,7 +2313,7 @@ static int slic_mcast_add_list(struct adapter
 *adapter, char *address)
     if (mcaddr == NULL)
         return 1;
 
-    memcpy(mcaddr->address, address, ETH_ALEN);
+    ether_addr_copy(mcaddr->address, address);
 
     mcaddr->next = adapter->mcastaddrs;
Quoted 1 line
     adapter->mcastaddrs = mcaddr;

The patch is line-wrapped, and tabs converted to spaces, making it impossible to apply the patch.

Please fix your email client and try again.

greg k-h