tech-net archive

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

Re: sockaddr printing functions



In article <20141201215723.GA17280%panix.com@localhost>,
Thor Lancelot Simon  <tls%panix.com@localhost> wrote:
>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.

Sometimes you only have pointers not the whole structure available though.

christos



Home | Main Index | Thread Index | Old Index