autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: avoid some more warnings in tests


From: Paul Eggert
Subject: Re: avoid some more warnings in tests
Date: Sun, 24 Sep 2006 23:31:57 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Ralf Wildenhues <address@hidden> writes:

>       * lib/autoconf/functions.m4 (AC_FUNC_OBSTACK): Avoid `gcc -Wall'
>       warnings (uninitialized value).
>       (AC_FUNC_UTIME_NULL): Likewise, test for and include <utime.h> if
>       present.
>       * lib/autoconf/types.m4 (AC_TYPE_LONG_LONG_INT): Likewise, add
>       parentheses.
>       (AC_STRUCT_TM): Likewise, avoid unused variables.

How about the following patch instead?  It checks tm_sec a bit more
tightly, and adds some parentheses for the ll check.  And it
should work even if gcc gets smarter about obstack_free.

Index: lib/autoconf/functions.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/functions.m4,v
retrieving revision 1.109
diff -p -u -r1.109 functions.m4
--- lib/autoconf/functions.m4   15 Sep 2006 14:53:43 -0000      1.109
+++ lib/autoconf/functions.m4   25 Sep 2006 06:30:06 -0000
@@ -1340,7 +1340,9 @@ AC_DEFUN([AC_FUNC_OBSTACK],
 AC_CACHE_CHECK([for obstacks], ac_cv_func_obstack,
 [AC_LINK_IFELSE(
     [AC_LANG_PROGRAM(address@hidden:@include "obstack.h"]],
-                    [[struct obstack *mem; obstack_free(mem,(char *) 0)]])],
+                    [[struct obstack mem;
+                      obstack_init (&mem);
+                      obstack_free (&mem, 0);]])],
                [ac_cv_func_obstack=yes],
                [ac_cv_func_obstack=no])])
 if test $ac_cv_func_obstack = yes; then
@@ -1758,10 +1760,14 @@ AU_ALIAS([AC_STRCOLL], [AC_FUNC_STRCOLL]
 # ------------------
 AN_FUNCTION([utime], [AC_FUNC_UTIME_NULL])
 AC_DEFUN([AC_FUNC_UTIME_NULL],
-[AC_CACHE_CHECK(whether utime accepts a null argument, ac_cv_func_utime_null,
+[AC_CHECK_HEADERS_ONCE(utime.h)
+AC_CACHE_CHECK(whether utime accepts a null argument, ac_cv_func_utime_null,
 [rm -f conftest.data; >conftest.data
 # Sequent interprets utime(file, 0) to mean use start of epoch.  Wrong.
-AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
+AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
+              #ifdef HAVE_UTIME_H
+              # include <utime.h>
+              #endif],
 [[struct stat s, t;
   return ! (stat ("conftest.data", &s) == 0
            && utime ("conftest.data", 0) == 0
Index: lib/autoconf/types.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/types.m4,v
retrieving revision 1.44
diff -p -u -r1.44 types.m4
--- lib/autoconf/types.m4       2 Sep 2006 05:37:08 -0000       1.44
+++ lib/autoconf/types.m4       25 Sep 2006 06:30:06 -0000
@@ -479,7 +479,7 @@ AC_DEFUN([AC_TYPE_LONG_LONG_INT],
                           ? 1 : -1)];
            int i = 63;]],
          [[long long int llmax = 9223372036854775807ll;
-           return (ll << 63 | ll >> 63 | ll < i | ll > i
+           return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i)
                    | llmax / ll | llmax % ll);]])],
        [ac_cv_type_long_long_int=yes],
        [ac_cv_type_long_long_int=no])])
@@ -919,7 +919,9 @@ AC_DEFUN([AC_STRUCT_TM],
 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
 #include <time.h>
 ],
-                                   [struct tm *tp; tp->tm_sec;])],
+                                   [struct tm tm;
+                                    int *p = &tm.tm_sec;
+                                    return !p;])],
                   [ac_cv_struct_tm=time.h],
                   [ac_cv_struct_tm=sys/time.h])])
 if test $ac_cv_struct_tm = sys/time.h; then




reply via email to

[Prev in Thread] Current Thread [Next in Thread]