lkml.org 
[lkml]   [2000]   [Jul]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC] solution for the inet_ntoa problem, buffer allocator
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/

\
 
 \ /
  Last update: 2005-03-22 13:57    [W:0.093 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site