tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: sockaddr printing functions



On Mon, Dec 01, 2014 at 02:40:57PM -0500, Christos Zoulas wrote:
> On Dec 1,  8:12pm, agc%pkgsrc.org@localhost (Alistair Crooks) wrote:
> -- Subject: Re: sockaddr printing functions
> 
> | A few questions:
> | 
> | 1.  the xx_print calls sxx_snprintf internally with a local (stack)
> | buffer, and then prints that out?
> 
> Yes.
> 
> | 2. why have multiple sxx_snprintf functions, and then pass a void *sa in to
> | each? Is it one function with a void *sa, or many functions for each struct type?
> 
> I wanted to keep the sockaddr printing knowledge local to the stack. The
> void * argument is to avoid pointer aliasing gymnastics.

If available, perhaps we could use GCC's transparent union extension to do
this while maintaining type safety.  It's not 100% clear to me how to neatly
use that extension only if available, though.

Thor


Home | Main Index | Thread Index | Old Index