Re: sys/socket.h: make sstosa() available to everyone
On Tue, May 30, 2017 at 01:29:07PM -0600, Theo de Raadt wrote: > I don't think this trivial thing should be pushed into the public > namespace. > > Personally I think this construct is really contrived. ok. Another downside might be that it can negatively impact portability. Thanks, Job
Re: sys/socket.h: make sstosa() available to everyone
I don't think this trivial thing should be pushed into the public namespace. Personally I think this construct is really contrived. > Might be out of my depth here, but would be nice if the sstosa() is > available to everyone, not just _KERNEL > > If accepted, 'define sstosa' can to be removed from > usr.sbin/ftp-proxy/ftp-proxy.c. > > Kind regards, > > Job > > --- > sys/sys/socket.h | 16 ++-- > 1 file changed, 10 insertions(+), 6 deletions(-) > > diff --git a/sys/sys/socket.h b/sys/sys/socket.h > index 27cd9b5962e..48cd94e072a 100644 > --- a/sys/sys/socket.h > +++ b/sys/sys/socket.h > @@ -229,6 +229,16 @@ struct sockaddr_storage { > unsigned char __ss_pad3[240]; /* pad to a total of 256 bytes */ > }; > > +/* > + * inline function to convert struct sockaddr_storage to struct sockaddr > + * in a typesafe manner instead of sprinkling casts everywhere. > + */ > +static inline struct sockaddr * > +sstosa(struct sockaddr_storage *ss) > +{ > +return ((struct sockaddr *)(ss)); > +} > + > #ifdef _KERNEL > /* > * Structure used by kernel to pass protocol > @@ -535,12 +545,6 @@ __END_DECLS > > void pfctlinput(int, struct sockaddr *); > > -static inline struct sockaddr * > -sstosa(struct sockaddr_storage *ss) > -{ > - return ((struct sockaddr *)(ss)); > -} > - > #endif /* !_KERNEL */ > > #endif /* !_SYS_SOCKET_H_ */ >
sys/socket.h: make sstosa() available to everyone
Hi, Might be out of my depth here, but would be nice if the sstosa() is available to everyone, not just _KERNEL If accepted, 'define sstosa' can to be removed from usr.sbin/ftp-proxy/ftp-proxy.c. Kind regards, Job --- sys/sys/socket.h | 16 ++-- 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sys/sys/socket.h b/sys/sys/socket.h index 27cd9b5962e..48cd94e072a 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -229,6 +229,16 @@ struct sockaddr_storage { unsigned char __ss_pad3[240]; /* pad to a total of 256 bytes */ }; +/* + * inline function to convert struct sockaddr_storage to struct sockaddr + * in a typesafe manner instead of sprinkling casts everywhere. + */ +static inline struct sockaddr * +sstosa(struct sockaddr_storage *ss) +{ +return ((struct sockaddr *)(ss)); +} + #ifdef _KERNEL /* * Structure used by kernel to pass protocol @@ -535,12 +545,6 @@ __END_DECLS void pfctlinput(int, struct sockaddr *); -static inline struct sockaddr * -sstosa(struct sockaddr_storage *ss) -{ - return ((struct sockaddr *)(ss)); -} - #endif /* !_KERNEL */ #endif /* !_SYS_SOCKET_H_ */