Make setsockopt replacement more typesafe.
authorSimon Josefsson <simon@josefsson.org>
Wed, 23 Apr 2008 06:09:44 +0000 (08:09 +0200)
committerSimon Josefsson <simon@josefsson.org>
Wed, 23 Apr 2008 06:09:44 +0000 (08:09 +0200)
ChangeLog
lib/sys_socket.in.h

index 2e0ac51..4b87fda 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2008-04-23  Simon Josefsson  <simon@josefsson.org>
 
+       * lib/sys_socket.in.h (setsockopt): Be more type safe by declaring
+       an inline function instead of a CPP macro.  Patch by Ben Pfaff
+       <blp@cs.stanford.edu>.
+
+2008-04-23  Simon Josefsson  <simon@josefsson.org>
+
        * lib/arpa_inet.in.h: New file.
 
        * modules/arpa_inet (Files): Add lib/arpa_inet.in.h.
index cb84220..d2a081f 100644 (file)
 # endif
 
 # if defined _WIN32 || defined __WIN32__
-#  define setsockopt(a,b,c,d,e) setsockopt(a,b,c,(const void*)(d),e)
+#  define setsockopt(a,b,c,d,e) rpl_setsockopt(a,b,c,d,e)
+static inline int
+rpl_setsockopt(int socket, int level, int optname, const void *optval,
+              socklen_t optlen)
+{
+  return (setsockopt)(socket, level, optname, optval, optlen);
+}
 # endif
 
 #endif /* HAVE_SYS_SOCKET_H */