]> granicus.if.org Git - libevent/commitdiff
Build with the -fno-strict-aliasing flag on GCC.
authorNick Mathewson <nickm@torproject.org>
Sat, 31 Jan 2009 07:31:47 +0000 (07:31 +0000)
committerNick Mathewson <nickm@torproject.org>
Sat, 31 Jan 2009 07:31:47 +0000 (07:31 +0000)
You do not want to know about the 2 hours I just spent tracking down
an evdns bug that only affected me on some platforms to the way we
were using sockaddr* and sockaddr_in*.  Suffice it to say that I do
not think this is the only C99-aliasing-dubiousness in our code, nor
that I am smart enough to keep my code correct with the GCC's strict
aliasing optimizations in place.

svn:r1079

configure.in
evdns.c

index 503e4b49fc31a9031ee2cc50f3c72f4383a132ee..6b084582b2890ea8dd3dd6c8ceb0dd7ab34e74d1 100644 (file)
@@ -19,7 +19,11 @@ AC_PROG_LN_S
 
 AC_PROG_GCC_TRADITIONAL
 if test "$GCC" = yes ; then
+        # Enable many gcc warnings by default...
         CFLAGS="$CFLAGS -Wall"
+       # And disable the strict-aliasing optimization, since it breaks
+       # our sockaddr-handling code in strange ways.
+       CFLAGS="$CFLAGS -fno-strict-aliasing"
 fi
 
 AC_ARG_ENABLE(gcc-warnings,
@@ -433,13 +437,13 @@ if test x$enable_gcc_warnings = xyes; then
   CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wmissing-declarations -Wredundant-decls -Wnested-externs -Wbad-function-cast -Wswitch-enum -Werror"
   CFLAGS="$CFLAGS -Wno-unused-parameter -Wno-sign-compare -Wstrict-aliasing"
 
-  if test x$have_gcc4 = xyes ; then 
+  if test x$have_gcc4 = xyes ; then
     # These warnings break gcc 3.3.5 and work on gcc 4.0.2
     CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement"
     #CFLAGS="$CFLAGS -Wold-style-definition"
   fi
 
-  if test x$have_gcc42 = xyes ; then 
+  if test x$have_gcc42 = xyes ; then
     # These warnings break gcc 4.0.2 and work on gcc 4.2
     CFLAGS="$CFLAGS -Waddress -Wnormalized=id -Woverride-init"
   fi
diff --git a/evdns.c b/evdns.c
index d86d52a064fba8e53bd7ed43e02861183670695d..aad21e277bd23fab80e2648d5c931964714ef619 100644 (file)
--- a/evdns.c
+++ b/evdns.c
@@ -3468,6 +3468,7 @@ main(int c, char **v) {
                ++idx;
        }
        event_init();
+       evdns_init();
        if (verbose)
                evdns_set_log_fn(logfn);
        evdns_resolv_conf_parse(DNS_OPTION_NAMESERVERS, "/etc/resolv.conf");