From: Denis Vlasenko <vda.linux@googlemail.com>
To: Joe Perches <joe@perches.com>
Cc: Randy Dunlap <rdunlap@xenotime.net>, Greg KH <greg@kroah.com>,
Jesper Juhl <jesper.juhl@gmail.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: Tiny error in printk output for clocksource : a3:<6>Time: acpi_pm clocksource has been installed.
Date: Thu, 28 Sep 2006 18:19:43 +0200 [thread overview]
Message-ID: <200609281819.43712.vda.linux@googlemail.com> (raw)
In-Reply-To: <1159459694.5015.19.camel@localhost>
On Thursday 28 September 2006 18:08, Joe Perches wrote:
> On Thu, 2006-09-28 at 12:56 +0200, Denis Vlasenko wrote:
> > \#define MACSTR "%02X:%02X:%02X:%02X:%02X:%02X"
> > #define MAC(bytevector) \
> > ((unsigned char *)bytevector)[0], \
> > ((unsigned char *)bytevector)[1], \
> > ((unsigned char *)bytevector)[2], \
> > ((unsigned char *)bytevector)[3], \
> > ((unsigned char *)bytevector)[4], \
> > ((unsigned char *)bytevector)[5]
>
> This is similar to the 802.11 way.
> 802.11 uses MAC_FMT and MAC_ARG.
> I think a common style is preferable.
>
> It's fine, but it increases the size of kernel image
> by up to ~100K. Using a common function, a stack
> automatic and "%s" in the printk decreases the size
> of the kernel.
You deleted part of my message where I show exactly that:
a common function, which handles 80% of usage cases.
You are trying to cover all possible cases with this monstrosity:
extern char *__dev_addr6_fmt(char* buf, const unsigned char *addr);
#define DEV_ADDR6_FMT "%s" /* expands to: "FF:FF:FF:FF:FF:FF" */
#define DEV_ADDR6_BUF char __dev_addr6_buf[sizeof("FF:FF:FF:FF:FF:FF")]
#define DEV_ADDR6(addr) __dev_addr6_fmt(__dev_addr6_buf,(const unsigned char*)addr)
#define DEV_ADDR6_BUF_2 char __dev_addr6_buf_2[sizeof("FF:FF:FF:FF:FF:FF")]
#define DEV_ADDR6_2(addr) __dev_addr6_fmt(__dev_addr6_buf_2,(const unsigned char*)addr)
#define DEV_ADDR6_BUF_3 char __dev_addr6_buf_3[sizeof("FF:FF:FF:FF:FF:FF")]
#define DEV_ADDR6_3(addr) __dev_addr6_fmt(__dev_addr6_buf_3,(const unsigned char*)addr)
#define DEV_ADDR6_BUF_4 char __dev_addr6_buf_4[sizeof("FF:FF:FF:FF:FF:FF")]
#define DEV_ADDR6_4(addr) __dev_addr6_fmt(__dev_addr6_buf_4,(const unsigned char*)addr)
Usage:
DEV_ADDR6_BUF;
...
printk(", h/w address " DEV_ADDR6_FMT "\n", DEV_ADDR6(dev->dev_addr));
Why don't you use a parameter for DEV_ADDR6{_BUF}? DEV_ADDR6_BUF(var_name).
DEV_ADDR6(var_name, addr). That would be less cryptic.
In my case, it's just
print_mac(", h/w address ", dev->dev_addr, "\n");
Actually, I think it makes sense to have both: yours for complicated
cases (printk with lots of other %something) and mine for simple ones
(no local variable, smaller code).
> Strictly, not all MAC addresses are 6 byte.
>
> Maybe all the Ethernet/TR addresses should use the
> IEEE EUI48 designation? That feels a bit like the
> KiB/KB distinction, but it is technically correct.
>
> Would a patch with an DEV6_ADDR->EUI48 substitution
> be acceptable?
Maybe. Doesn't look obvious, but if it is in standards...
--
vda
next prev parent reply other threads:[~2006-09-28 16:25 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-27 0:22 Tiny error in printk output for clocksource : a3:<6>Time: acpi_pm clocksource has been installed Jesper Juhl
2006-09-27 0:33 ` Randy Dunlap
2006-09-27 0:36 ` Jesper Juhl
2006-09-27 0:54 ` Randy Dunlap
2006-09-27 1:15 ` Jesper Juhl
2006-09-27 3:54 ` Randy Dunlap
2006-09-27 4:32 ` Greg KH
2006-09-27 4:52 ` Randy Dunlap
2006-09-27 4:56 ` Randy Dunlap
2006-09-27 5:07 ` Greg KH
2006-09-27 5:10 ` Joe Perches
2006-09-27 5:17 ` Randy Dunlap
2006-09-27 5:19 ` Joe Perches
2006-09-27 15:24 ` Randy Dunlap
2006-09-28 10:56 ` Denis Vlasenko
2006-09-28 16:08 ` Joe Perches
2006-09-28 16:19 ` Denis Vlasenko [this message]
2006-09-28 17:03 ` Joe Perches
2006-09-28 23:26 ` Joe Perches
2006-09-27 21:38 ` Jesper Juhl
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=200609281819.43712.vda.linux@googlemail.com \
--to=vda.linux@googlemail.com \
--cc=greg@kroah.com \
--cc=jesper.juhl@gmail.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rdunlap@xenotime.net \
/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