<URL: http://bugs.freeciv.org/Ticket/Display.html?id=39597 >

Specifically, for all BSD systems!

socklen_t was originally created and defined for BSD, belongs in
sys/socket.h, and is always 32-bits (as a field in a struct).

Apparently, some other systems toss it in the wrong place, and are not
compatible with the original definition.

Re-defining it as int doesn't work.  Perhaps int32_t would work.  On some
systems, it's size_t or uint32_t instead.

===

A quick Google finds:

# This affects the XMMS plugin.  configure.in has this test:
#
#   AC_CHECK_TYPES(socklen_t, [], [])
#
# And src/plugin_xmms/http.c is the only consumer:
#
#   #ifndef HAVE_SOCKLEN_T
#   typedef unsigned int socklen_t;
#   #endif
#
# Together this looks bogus to me.  The configure check looks for
# socklen_t in the default headers.  If it isn't found there, socklen_t
# will be typedef'ed.
#
# However, at least on FreeBSD socklen_t is defined in <sys/socket.h>,
# which is not checked by AC_CHECK_TYPES() but which is included in
# http.c.  This can result in such errors:
#
# http.c:48: redefinition of `socklen_t'
# /usr/include/sys/socket.h:54: `socklen_t' previously declared here
#

The correct test in configure.ac should be (taken from gdb):
AC_CHECK_TYPES(socklen_t, [], [],
[#include <sys/types.h>
#include <sys/socket.h>
])

===

In S2_1, it's hardly ever tested (only the new broken netintf.h);
apparently the other tests were deleted by the patch:

client/servers.c:639:    socklen_t fromlen;
server/sernet.c:807:    socklen_t fromlen;
utility/netintf.c:87:  int my_connect(int sockfd, const struct sockaddr 
*serv_addr, socklen_t addrlen)
utility/netintf.h:63:  #ifndef HAVE_SOCKLEN_T
utility/netintf.h:64:  typedef int socklen_t;
utility/netintf.h:72:  int my_connect(int sockfd, const struct sockaddr 
*serv_addr, socklen_t addrlen);


Originally, it's tested each time it's used:

client/servers.c:639:  #ifdef HAVE_SOCKLEN_T
client/servers.c:640:    socklen_t fromlen;
server/sernet.c:807:  #ifdef HAVE_SOCKLEN_T
server/sernet.c:808:    socklen_t fromlen;
server/sernet.c:809:  #else /* HAVE_SOCKLEN_T */
server/sernet.c:811:  #endif /* HAVE_SOCKLEN_T */



_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to