On Fri, 11 Apr 2014 14:08:16 +0200, Richard Cochran wrote:
> > +struct address {
> > +   socklen_t len;
> > +   union {
> > +           struct sockaddr_storage ss;
> > +           struct sockaddr_in sin;
> > +           struct sockaddr_in6 sin6;
> > +           struct sockaddr_un sun;
> > +           struct sockaddr sa;
> 
> Can't we use struct sockaddr_storage here?

It's the first member of the union. I originally had only struct
sockaddr_storage here but it led to horrible typecasting in the code
(which is quite error prone when you accidentally put an extra & before
the variable). In the end, I added the union here, which led to a
shorter and cleaner code, and the compiler being able to do type
checking as a bonus.

 Jiri

-- 
Jiri Benc

------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment 
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to