build: Add -Werror=undef by default, fix fallout
authorColin Walters <walters@verbum.org>
Thu, 2 Nov 2017 15:50:12 +0000 (11:50 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Mon, 6 Nov 2017 15:30:14 +0000 (15:30 +0000)
The main thing here is that a ton of stuff has happened in gnulib since we
imported `parse-datetime.y`. I cherry-picked a little bit of it, but that
upstream doesn't seem to build with `-Wundef`, so I just deleted some hunks.

(Note I reindented the warnings consistently)

Update submodule: libglnx

Closes: #1320
Approved by: jlebon

configure.ac
libglnx
src/libostree/ostree-enumtypes.c.template
src/ostree/parse-datetime.y

index ea74a9ef708d9d3e1e05e486ca57ebd4cf0dc91c..6b095504ef0df966ff8747cea5a0e616c03f048e 100644 (file)
@@ -30,23 +30,24 @@ AC_SUBST([PACKAGE_VERSION], [package_version])
 
 AS_IF([echo "$CFLAGS" | grep -q -E -e '-Werror($| )'], [], [
 CC_CHECK_FLAGS_APPEND([WARN_CFLAGS], [CFLAGS], [\
-        -pipe \
-        -Wall \
-       -Werror=empty-body \
-       -Werror=strict-prototypes \
-       -Werror=missing-prototypes \
-       -Werror=implicit-function-declaration \
-        "-Werror=format=2 -Werror=format-security -Werror=format-nonliteral" \
-       -Werror=pointer-arith -Werror=init-self \
-        -Werror=missing-declarations \
-        -Werror=return-type \
-        -Werror=switch \
-        -Werror=overflow \
-        -Werror=int-conversion \
-        -Werror=parenthesis \
-        -Werror=incompatible-pointer-types \
-        -Werror=misleading-indentation \
-       -Werror=missing-include-dirs -Werror=aggregate-return \
+  -pipe \
+  -Wall \
+  -Werror=empty-body \
+  -Werror=strict-prototypes \
+  -Werror=missing-prototypes \
+  -Werror=implicit-function-declaration \
+  "-Werror=format=2 -Werror=format-security -Werror=format-nonliteral" \
+  -Werror=pointer-arith -Werror=init-self \
+  -Werror=missing-declarations \
+  -Werror=return-type \
+  -Werror=switch \
+  -Werror=overflow \
+  -Werror=int-conversion \
+  -Werror=parenthesis \
+  -Werror=undef \
+  -Werror=incompatible-pointer-types \
+  -Werror=misleading-indentation \
+  -Werror=missing-include-dirs -Werror=aggregate-return \
   -Werror=unused-result \
 ])])
 AC_SUBST(WARN_CFLAGS)
@@ -83,6 +84,9 @@ AC_SUBST([OSTREE_FEATURES])
 GLIB_TESTS
 LIBGLNX_CONFIGURE
 
+dnl These bits attempt to mirror https://github.com/coreutils/gnulib/blob/e369b04cca4da1534c98628b8ee4648bfca2bb3a/m4/parse-datetime.m4#L27
+AC_CHECK_FUNCS([nanotime clock_gettime])
+AC_STRUCT_TIMEZONE
 AC_CHECK_HEADER([sys/xattr.h],,[AC_MSG_ERROR([You must have sys/xattr.h from glibc])])
 
 AS_IF([test "$YACC" != "bison -y"], [AC_MSG_ERROR([bison not found but required])])
diff --git a/libglnx b/libglnx
index d15a3790074fd982f2611a5b450dea61052dfc0b..b36606b366d39c7ddb90ee21d622c0cb1da118ed 160000 (submodule)
--- a/libglnx
+++ b/libglnx
@@ -1 +1 @@
-Subproject commit d15a3790074fd982f2611a5b450dea61052dfc0b
+Subproject commit b36606b366d39c7ddb90ee21d622c0cb1da118ed
index f7eecf2430fb73b0547fcdbb7fd1101a54d6743b..751c458a9f9946af114a5f67516061b05ec2e9ca 100644 (file)
@@ -18,9 +18,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
+#include "config.h"
 #include <string.h>
 
 #include "ostree-enumtypes.h"
index 5091735457442e66348db74f341345a6b936e0fa..e1ce30574b98953caa29e3cd5003319dd17957ea 100644 (file)
@@ -38,6 +38,7 @@
 #include <stdlib.h>
 #include <sys/time.h>
 #include <glib.h>
+#include <stdint.h>
 
 /* There's no need to extend the stack, so there's no need to involve
    alloca.  */
@@ -54,11 +55,11 @@ xmemdup (void const *p, size_t s)
 static void
 gettime (struct timespec *ts)
  {
-#if HAVE_NANOTIME
+#ifdef HAVE_NANOTIME
    nanotime (ts);
 #else
 
-# if defined CLOCK_REALTIME && HAVE_CLOCK_GETTIME
+# if defined(CLOCK_REALTIME) && defined(HAVE_CLOCK_GETTIME)
    if (clock_gettime (CLOCK_REALTIME, ts) == 0)
      return;
 # endif
@@ -134,13 +135,6 @@ gettime (struct timespec *ts)
 
 #define HOUR(x) ((x) * 60)
 
-/* long_time_t is a signed integer type that contains all time_t values.  */
-#if TIME_T_FITS_IN_LONG_INT
-typedef long int long_time_t;
-#else
-typedef time_t long_time_t;
-#endif
-
 /* Convert a possibly-signed character to an unsigned character.  This is
    a bit safer than casting to unsigned char, since it catches some type
    errors that the cast doesn't.  */
@@ -180,15 +174,11 @@ typedef struct
   long int day;
   long int hour;
   long int minutes;
-  long_time_t seconds;
-  long int ns;
+  intmax_t seconds;
+  int ns;
 } relative_time;
 
-#if HAVE_COMPOUND_LITERALS
-# define RELATIVE_TIME_0 ((relative_time) { 0, 0, 0, 0, 0, 0, 0 })
-#else
-static relative_time const RELATIVE_TIME_0;
-#endif
+#define RELATIVE_TIME_0 ((relative_time) { 0, 0, 0, 0, 0, 0, 0 })
 
 /* Information passed to and from the parser.  */
 typedef struct
@@ -955,7 +945,8 @@ lookup_zone (parser_control const *pc, char const *name)
   return NULL;
 }
 
-#if ! HAVE_TM_GMTOFF
+// #if ! HAVE_TM_GMTOFF
+#if 1 // Always true for us
 /* Yield the difference between *A and *B,
    measured in seconds, ignoring leap seconds.
    The body of this function is taken directly from the GNU C Library;
@@ -1580,10 +1571,10 @@ parse_datetime (struct timespec *result, char const *p,
         time_t t1 = t0 + d1;
         long int d2 = 60 * pc.rel.minutes;
         time_t t2 = t1 + d2;
-        long_time_t d3 = pc.rel.seconds;
-        long_time_t t3 = t2 + d3;
+        intmax_t d3 = pc.rel.seconds;
+        intmax_t t3 = t2 + d3;
         long int d4 = (sum_ns - normalized_ns) / BILLION;
-        long_time_t t4 = t3 + d4;
+        intmax_t t4 = t3 + d4;
         time_t t5 = t4;
 
         if ((d1 / (60 * 60) ^ pc.rel.hour)
@@ -1611,39 +1602,3 @@ parse_datetime (struct timespec *result, char const *p,
     free (tz0);
   return ok;
 }
-
-#if TEST
-
-int
-main (int ac, char **av)
-{
-  char buff[BUFSIZ];
-
-  printf ("Enter date, or blank line to exit.\n\t> ");
-  fflush (stdout);
-
-  buff[BUFSIZ - 1] = '\0';
-  while (fgets (buff, BUFSIZ - 1, stdin) && buff[0])
-    {
-      struct timespec d;
-      struct tm const *tm;
-      if (! parse_datetime (&d, buff, NULL))
-        printf ("Bad format - couldn't convert.\n");
-      else if (! (tm = localtime (&d.tv_sec)))
-        {
-          long int sec = d.tv_sec;
-          printf ("localtime (%ld) failed\n", sec);
-        }
-      else
-        {
-          int ns = d.tv_nsec;
-          printf ("%04ld-%02d-%02d %02d:%02d:%02d.%09d\n",
-                  tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday,
-                  tm->tm_hour, tm->tm_min, tm->tm_sec, ns);
-        }
-      printf ("\t> ");
-      fflush (stdout);
-    }
-  return 0;
-}
-#endif /* TEST */