Skip to content
Snippets Groups Projects
Commit 9f455bcb authored by oliver@schinagl.nl's avatar oliver@schinagl.nl Committed by Joe Hershberger
Browse files

net: cosmetic: Make the MAC address string less magical


In u-boot printf has been extended with the %pM formatter to allow
printing of MAC addresses. However buffers that want to store a MAC
address cannot safely get the size. Add a define for this case so the
string of a MAC address can be reliably obtained.

Signed-off-by: default avatarOlliver Schinagl <oliver@schinagl.nl>
Acked-by: default avatarJoe Hershberger <joe.hershberger@ni.com>
parent a40db6d5
No related branches found
No related tags found
No related merge requests found
...@@ -40,6 +40,11 @@ ...@@ -40,6 +40,11 @@
/* ARP hardware address length */ /* ARP hardware address length */
#define ARP_HLEN 6 #define ARP_HLEN 6
/*
* The size of a MAC address in string form, each digit requires two chars
* and five separator characters to form '00:00:00:00:00:00'.
*/
#define ARP_HLEN_ASCII (ARP_HLEN * 2) + (ARP_HLEN - 1)
/* IPv4 addresses are always 32 bits in size */ /* IPv4 addresses are always 32 bits in size */
struct in_addr { struct in_addr {
......
...@@ -32,7 +32,7 @@ int eth_getenv_enetaddr(const char *name, uchar *enetaddr) ...@@ -32,7 +32,7 @@ int eth_getenv_enetaddr(const char *name, uchar *enetaddr)
int eth_setenv_enetaddr(const char *name, const uchar *enetaddr) int eth_setenv_enetaddr(const char *name, const uchar *enetaddr)
{ {
char buf[20]; char buf[ARP_HLEN_ASCII + 1];
sprintf(buf, "%pM", enetaddr); sprintf(buf, "%pM", enetaddr);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment