Skip to content

Commit

Permalink
net: Fix sysfs_format_mac() code duplication.
Browse files Browse the repository at this point in the history
It's just a duplicate implementation of "%*phC".  Thanks to Joe
Perches for showing that we had exactly this support in the
lib/vsprintf.c code already.

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jul 17, 2013
1 parent 52fe29e commit ae8e9c5
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions net/ethernet/eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,27 +401,8 @@ struct net_device *alloc_etherdev_mqs(int sizeof_priv, unsigned int txqs,
}
EXPORT_SYMBOL(alloc_etherdev_mqs);

static size_t _format_mac_addr(char *buf, int buflen,
const unsigned char *addr, int len)
{
int i;
char *cp = buf;

for (i = 0; i < len; i++) {
cp += scnprintf(cp, buflen - (cp - buf), "%02x", addr[i]);
if (i == len - 1)
break;
cp += scnprintf(cp, buflen - (cp - buf), ":");
}
return cp - buf;
}

ssize_t sysfs_format_mac(char *buf, const unsigned char *addr, int len)
{
size_t l;

l = _format_mac_addr(buf, PAGE_SIZE, addr, len);
l += scnprintf(buf + l, PAGE_SIZE - l, "\n");
return (ssize_t)l;
return scnprintf(buf, PAGE_SIZE, "%*phC\n", len, addr);
}
EXPORT_SYMBOL(sysfs_format_mac);

0 comments on commit ae8e9c5

Please sign in to comment.