From: Joe Perches <joe@perches.com>
To: David Miller <davem@davemloft.net>
Cc: johannes@sipsolutions.net, netdev@vger.kernel.org,
akpm@linux-foundation.org, jgarzik@pobox.com
Subject: Re: [PATCH net-2.6.24] introduce MAC_FMT/MAC_ARG
Date: Mon, 24 Sep 2007 10:28:34 -0700 [thread overview]
Message-ID: <1190654914.2010.8.camel@localhost> (raw)
In-Reply-To: <20070919.125451.112289690.davem@davemloft.net>
On Wed, 2007-09-19 at 12:54 -0700, David Miller wrote:
> Applied to net-2.6.24, thanks Joe!
Here is a patch that adds some type safety to print_mac
by using a struct print_mac_buf * instead of char *.
It also reduces the defconfig vmlinux size by 8 bytes.
Signed-off-by: Joe Perches <joe@perches.com>
--
include/linux/if_ether.h | 12 ++++++++++--
net/ethernet/eth.c | 6 +++---
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
index 57abca1..620d6b1 100644
--- a/include/linux/if_ether.h
+++ b/include/linux/if_ether.h
@@ -126,7 +126,15 @@ extern struct ctl_table ether_table[];
* Display a 6 byte device address (MAC) in a readable format.
*/
#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
-extern char *print_mac(char *buf, const u8 *addr);
-#define DECLARE_MAC_BUF(var) char var[18] __maybe_unused
+
+struct print_mac_buf {
+ char formatted_mac_addr[18];
+};
+
+#define DECLARE_MAC_BUF(var) \
+ struct print_mac_buf __maybe_unused _##var; \
+ struct print_mac_buf __maybe_unused *var = &_##var
+
+extern char *print_mac(struct print_mac_buf *buf, const u8 *addr);
#endif /* _LINUX_IF_ETHER_H */
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index 2aaf6fa..ad82613 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -338,10 +338,10 @@ struct net_device *alloc_etherdev_mq(int sizeof_priv, unsigned int queue_count)
}
EXPORT_SYMBOL(alloc_etherdev_mq);
-char *print_mac(char *buf, const u8 *addr)
+char *print_mac(struct print_mac_buf *buf, const u8 *addr)
{
- sprintf(buf, MAC_FMT,
+ sprintf(buf->formatted_mac_addr, MAC_FMT,
addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
- return buf;
+ return buf->formatted_mac_addr;
}
EXPORT_SYMBOL(print_mac);
prev parent reply other threads:[~2007-09-24 17:29 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-22 18:46 [PATCH net-2.6.24] introduce MAC_FMT/MAC_ARG Johannes Berg
2007-08-23 16:01 ` Joe Perches
2007-08-23 16:12 ` Johannes Berg
2007-08-23 17:08 ` John W. Linville
2007-08-25 6:14 ` David Miller
2007-08-26 0:09 ` Joe Perches
2007-08-27 10:54 ` Johannes Berg
2007-08-27 15:44 ` Joe Perches
2007-08-27 20:41 ` David Miller
[not found] ` <1188248263.18004.131.camel@localhost>
2007-08-27 21:09 ` Stephen Hemminger
2007-08-27 21:11 ` David Miller
[not found] ` <200708281648.44352.mb@bu3sch.de>
[not found] ` <20070828.155419.74563234.davem@davemloft.net>
2007-08-29 17:46 ` Michael Buesch
2007-08-27 21:26 ` Joe Perches
2007-08-27 21:37 ` David Miller
[not found] ` <1188335521.6062.56.camel@localhost>
[not found] ` <20070828.142216.99461544.davem@davemloft.net>
2007-08-31 22:16 ` Joe Perches
2007-08-31 22:21 ` Johannes Berg
2007-08-31 22:24 ` Joe Perches
2007-08-31 22:27 ` Johannes Berg
2007-08-31 22:32 ` Johannes Berg
2007-08-31 22:39 ` Joe Perches
2007-09-14 19:41 ` Joe Perches
2007-09-14 19:48 ` David Miller
2007-09-18 2:05 ` David Miller
2007-09-18 2:14 ` Joe Perches
2007-09-19 4:50 ` Joe Perches
2007-09-19 18:11 ` David Miller
2007-09-19 18:50 ` Joe Perches
2007-09-19 19:54 ` David Miller
2007-09-24 17:28 ` Joe Perches [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1190654914.2010.8.camel@localhost \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=jgarzik@pobox.com \
--cc=johannes@sipsolutions.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).