Re: [RFC] solution for the inet_ntoa problem, buffer allocator

From: Lincoln Dale (ltd@interlink.com.au)
Date: Wed Jul 05 2000 - 23:12:01 EST


At 23:41 05/07/00, Oliver Xymoron wrote:
> > > printk(KERN_DEBUG "foo: src=%a dst=%a\n", src, dst);
> >
> > I gather you've not been around long enough to know this was already done
> > and abandoned due the the lack of compiler type checking for the new type.
>
>I actually have, I'd just forgotten.

i've long-since used something like this:

         /* since inet_ntoa uses a 'fixed' buffer, and you therefore cannot
          * use more than one per printf, we've rolled our own ...
          * NOTE: only for intel platform
          */
         #define inet_int_ntoa(addr) \
                 (addr) & 0xff, \
                 (addr>>8) & 0xff, \
                 (addr>>16) & 0xff, \
                 (addr>>24) & 0xff

         ...

with the obvious printf / printk being something like:
         fprintf(stderr,"added interface %d '%s', ipaddr %d.%d.%d.%d
(netmask %d.%d.%d.%d) %s\n",
                 found,
                 config->iface[found]->name,
                 inet_int_ntoa(config->iface[found]->addr.s_addr),
                 inet_int_ntoa(config->iface[found]->netmask.s_addr),
                 (config->iface[found]->wccp_participant ?
"[wccp-participant-i/face]" : ""));

given that such a thing is typically used in debug-type printf's, i don't
see it as being too ugly.

cheers,

lincoln.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Jul 07 2000 - 21:00:18 EST