Re: [PATCH net-2.6.24] introduce MAC_FMT/MAC_ARG
From: Joe Perches <joe@perches.com>
Date: 2007-08-27 15:45:49
On Mon, 2007-08-27 at 12:54 +0200, Johannes Berg wrote:
Thanks for this patch though, I'd have done it otherwise.
I had it, it was just a s/EUI48/MAC/ and copy/paste thing. There are also the arch, drivers/[^net], and net directories that have a few of these. The patch also added the missing ")" in drivers/net/82596.c
I was rereading your original conversion and noticed that it is now
trivial to make the kernel smaller like you originally wanted by doing
something like this
-- define this function somewhere --
print_mac(u8 *mac, char *buf)
{
sprintf(buf, "%02x:...", mac[0], mac[1], ...);
}
EXPORT_SYMBOL(print_mac)
-- change macros to --
#define MAC_FMT "%s"
#define MAC_ARG(a) ({char __buf[18]; print_mac(a, buf); __buf})
I'm not sure we'd want that, but at the time you said it made the kernel
significantly smaller and I doubt there's a performance problem with it
(who prints mac addresses regularly?)The reduction is ~.1% in an allyesconfig. The compound statement to hide the automatic works well. The function call is noise compared to the printk. cheers, Joe