Re: /proc/net/arp silliness

From: Andrew Morton (
Date: Wed Apr 26 2000 - 07:18:40 EST

Olaf Titz wrote:
> > > v.s. in_ntoa2 which is(was) used three times in all of net/*
> >
> > Lots of functions are used once, by the way.
> >
> > Code split to functions not to reuse it, but mainly to avoid
> > silly problems with text readability.
> And in_ntoa or any of its variants is a perfect example of a function
> which is both designed for reuse and has a need for reuse.

But it's not reentrant. It would have to be changed to have usage like:

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

which gets unwieldy.

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

The problem with this is that gcc will warn about either an unrecognised
conversion token or a wrong number of arguments, unless you use the
following patent pending trick:

        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.

Of course, it would be macrofied:

        printk("IP address is " IPV4_CONV " on Tuesdays\n", in_addr);

(I can't believe I'm about to hit send).

- 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