[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20070827.134131.41639376.davem@davemloft.net>
Date: Mon, 27 Aug 2007 13:41:31 -0700 (PDT)
From: David Miller <davem@...emloft.net>
To: johannes@...solutions.net
Cc: joe@...ches.com, netdev@...r.kernel.org
Subject: Re: [PATCH net-2.6.24] introduce MAC_FMT/MAC_ARG
From: Johannes Berg <johannes@...solutions.net>
Date: Mon, 27 Aug 2007 12:54:09 +0200
> -- 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?)
I don't think this works.
The scope of the __buf[18] array is inside of that MAC_ARG()
expression, which will be fully evaluated before constructing
the argument to printk().
Therefore printk() will be passed what is essentially a stale stack
pointer.
You'd need something like a "MAC_BUF buf;" all the callers need
to declare, and a new "buf" argument to MAC_ARG().
If this was the goal, there are better approches to this, how
about just calling:
print_mac(dev->dev_addr);
Sure, we'll have to split up printk() calls, but in the end it's
likely still smaller and better. And I think it's much cleaner
than this macro stuff.
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists