Re: /proc/net/arp silliness

From: Olaf Titz (
Date: Wed Apr 26 2000 - 09:50:58 EST

> char buf[SQUIGGLE];
> printk("%s", inet_ntoa(buf, in_addr));

This is one example which could actually benefit greatly from
alloca(), even though purists will hate me for that :-)

extern char *__inet_ntoa(char *buf, __u32 x); /* returns buf */
#define inet_ntoa(x) __inet_ntoa(__builtin_alloca(16), (x))

would solve the reentrance problem. (I have no idea if this is allowed
in the kernel and if not, why.)

> The canonical, definitive, best way to do this is within printk()
> itself, with a one-level recursive call to sprintf() from within
> vsprintf().

Looks like this could be done more efficiently though.

> printk("IP address is %lu\001 on Tuesdays\n", in_addr);
> Then you teach vsprintf to recognise '%lu\001' as a conversion for ipv4
> addresses. This will satisfy (and indeed leverage) gcc's arg checking.

Unfortunately this can't be expanded to other address families. IPv6
needs an address printing routine even more.


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

This archive was generated by hypermail 2b29 : Sun Apr 30 2000 - 21:00:11 EST