Thread (11 messages) flat view 11 messages, 4 authors, 2007-08-27

Re: [PATCH net-2.6.24] introduce MAC_FMT/MAC_ARG

From: Johannes Berg <johannes@sipsolutions.net>
Date: 2007-08-27 10:53:04

On Sat, 2007-08-25 at 17:09 -0700, Joe Perches wrote:
quoted hunk ↗ jump to hunk
@@ -747,22 +741,15 @@ static int ariadne_rx(struct net_device *dev)
            skb_copy_to_linear_data(skb, (char *)priv->rx_buff[entry],
pkt_len);
            skb->protocol=eth_type_trans(skb,dev);
 #if 0
 (int)skb->len);
+{
+           printk(KERN_DEBUG "RX pkt type 0x%04x"
+                  " from " MAC_FMT " to " MAC_FMT
+                  " data 0x%08x len %d\n",
+                  ((u_short *)skb->data)[6],
+                  MAC_ARG(((u_char *)skb->data)+6),
+                  MAC_ARG((u_char *)skb->data),
+                  (int)skb->data, (int)skb->len);
+}
 #endif 
You could drop the braces since there are no variables there any more.

Thanks for this patch though, I'd have done it otherwise.

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?)

johannes

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help