After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 320930 - Incorrect socklen_t test results
Incorrect socklen_t test results
Status: RESOLVED FIXED
Product: gdm
Classification: Core
Component: general
2.8.x
Other Mac OS
: Normal normal
: ---
Assigned To: GDM maintainers
GDM maintainers
Depends on:
Blocks:
 
 
Reported: 2005-11-08 01:55 UTC by Daniel Macks
Modified: 2005-11-11 23:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add #include <sys/socket.h> (if it exists) to socklen_t test. (716 bytes, patch)
2005-11-08 07:37 UTC, Daniel Macks
none Details | Review

Description Daniel Macks 2005-11-08 01:55:34 UTC
Version details: 2.8.0.5 (also CVS HEAD)
Distribution/Version: 10.3 and 10.4

During the ./configure test added in response to bug #79373, I get:

checking for socklen_t... no

and config.log says:

configure:22644: checking for socklen_t
configure:22668: gcc -c -g -O2  conftest.c >&5
conftest.c: In function `main':
conftest.c:62: error: `socklen_t' undeclared (first use in this function)
conftest.c:62: error: (Each undeclared identifier is reported only once
conftest.c:62: error: for each function it appears in.)
conftest.c:62: error: parse error before ')' token
configure:22674: $? = 1

In fact I *do* have socklen_t, but it is declared in <sys/socket.h>, which is
not #included by the config test. This means I get
  /* Define to `size_t' if <sys/types.h> does not define. */
  #define socklen_t size_t
which may not be the correct typedef. Looking at the source, socklen_t is used
in daemon/gdm-net.c *after* a sys/socket.h is #included, which is why having the
test fail is a problem.

A quick fix might be to enhance the current AC_CHECK_TYPE(socklen_t,size_t) test
(NB: that's a deprecated syntax anyway) to #include the header I need and that
is assumed to exist on all other machines as well? The following works for me,
not sure it doesn't break others for whom the current does work (i.e., have
socklen_t but the two #includes I give aren't sufficient and/or don't compile):

AC_CHECK_TYPE(socklen_t,,AC_DEFINE(socklen_t,size_t,Compatibility type),
[
#include <sys/types.h>
#include <sys/socket.h>
])

OTOH, instead of trying to design a configure test that has to devine the
#include set that might be used, why not scrap the test altogether and just put

#ifndef socklen_t
#define socklen_t size_t
#endif

in daemon/gdm-net.c?
Comment 1 Brian Cameron 2005-11-08 04:02:17 UTC
I'd prefer not to hack socklen_t by just #defining it in daemon/gdm-net.c if it
isn't found.  What would be nice would be to do the following:

1) Fix the current AC_CHECK_TYPE macro so it isn't using the deprecated syntax.
2) If that fails, use AC_COMPILE_IFELSE to try and compile a little c program that
   just includes <sys/socket.h>.  If that passes, it can set a macro that will
   cause the #include <sys/socket.h> to be added to daemon/gdm-net.c  

Is this reasonable?  Could you provide a patch?  I'm also open to discussion if
you think this isn't a good way to go.  It just seems better to rely on the
header files to define the sizes of things rather than trying to hack it.  While
it might fix the problem on your platform, it might cause problems on other
platforms.
Comment 2 Daniel Macks 2005-11-08 07:35:26 UTC
Yeah, I've got a nonstandard-for-gnome platform...hacks are Generally Bad Things:)

Here's more info about the obsolete autoconf stuff:
http://www.gnu.org/software/autoconf/manual/autoconf-2.57/html_node/autoconf_154.html

But anyway, seems like the simplest nonhackish enhancement for the current
implementation is simply to have the AC_CHECK_TYPE for socklen_t do an #include
sys/socket.h, if such a header file exists, as part of its conftest.c? If you
pass some #includes in the fourth parameter of the new AC_CHECK_TYPE syntax,
they replace the default set that is used for conftest, so just pass "defaults +
maybe sys/socket.h".
Comment 3 Daniel Macks 2005-11-08 07:37:22 UTC
Created attachment 54454 [details] [review]
Add #include <sys/socket.h> (if it exists) to socklen_t test.
Comment 4 Brian Cameron 2005-11-11 23:12:46 UTC
Fixed in CVS head and 2.12 branch.  What platform does this fix the configure
for, by the way?  Thanks for the patch, looks good.
Comment 5 Daniel Macks 2005-11-11 23:28:37 UTC
I'm on Mac OS X. The underlying darwin kernel is substantially based on some
*BSD flavors, and the definition of socklen_t being in <sys/socket.h> also
appears in FreeBSD.