coreutils
[Top][All Lists]
Advanced

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

[PATCH 1/2] build: --enable-gcc-warnings: disable some new warnings


From: Jim Meyering
Subject: [PATCH 1/2] build: --enable-gcc-warnings: disable some new warnings
Date: Wed, 23 Nov 2011 08:58:52 +0100

Updating from gnulib pulls in an updated manywarnings module,
which enables some new gcc warnings.  Those trigger many (of course)
warnings in gnulib and coreutils.  The configure.ac changes disable
the three offenders.  As noted, the -Wdouble-promotion option
should be easy to reenable, since it provoked only one warning.

>From da38f12d6f0cfcf0c990c2b8ca7e982f655540d8 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Tue, 22 Nov 2011 21:45:24 +0100
Subject: [PATCH 1/2] build: --enable-gcc-warnings: disable some new warnings

* configure.ac: Disable some new warning options pulled in via
an update to gnulib's manywarnings module: -Wformat-nonliteral,
-Wunsuffixed-float-constants, -Wdouble-promotion.
---
 configure.ac |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/configure.ac b/configure.ac
index 8241b55..3c4681c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -121,6 +121,8 @@ if test "$gl_gcc_warnings" = yes; then
   gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
   gl_WARN_ADD([-Wsuggest-attribute=const])
   gl_WARN_ADD([-Wsuggest-attribute=noreturn])
+  gl_WARN_ADD([-Wno-format-nonliteral])
+  gl_WARN_ADD([-Wno-unsuffixed-float-constants])

   # Enable this warning only with gcc-4.7 and newer.  With 4.6.1 20110824,
   # it suggests test.c's advance function may be pure, even though it
@@ -151,6 +153,9 @@ if test "$gl_gcc_warnings" = yes; then
   nw="$nw -Wunused-macros"
   nw="$nw -Wmissing-prototypes"
   nw="$nw -Wold-style-definition"
+  # FIXME: it may be easy to remove this, since it affects only one file:
+  # the snprintf call at ftoastr.c:132.
+  nw="$nw -Wdouble-promotion"
   # FIXME: remove/reenable the following two, once gnulib is adjusted.
   nw="$nw -Wsuggest-attribute=const"
   nw="$nw -Wsuggest-attribute=pure"
--
1.7.8.rc3.23.ge14d6


>From 3d213a17fac0a33d9845d1511d568a68ae2035ec Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Wed, 23 Nov 2011 08:43:18 +0100
Subject: [PATCH 2/2] build: update gnulib and tests/init.sh

* gnulib: Update.
* tests/init.sh: Update from gnulib.
---
 gnulib        |    2 +-
 tests/init.sh |   92 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 87 insertions(+), 7 deletions(-)

diff --git a/gnulib b/gnulib
index 17febe7..337977d 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 17febe7763c9ef38ed1ced5f08f022168e198929
+Subproject commit 337977d216e2759bc5b4dd3cbe223cbf8e6a9eb7
diff --git a/tests/init.sh b/tests/init.sh
index 373d9d4..e2f6119 100644
--- a/tests/init.sh
+++ b/tests/init.sh
@@ -221,16 +221,96 @@ export MALLOC_PERTURB_
 # a partition, or to undo any other global state changes.
 cleanup_ () { :; }

-if ( diff -u "$0" "$0" < /dev/null ) > /dev/null 2>&1; then
-  compare () { diff -u "$@"; }
-elif ( diff -c "$0" "$0" < /dev/null ) > /dev/null 2>&1; then
-  compare () { diff -c "$@"; }
+# Emit a header similar to that from diff -u;  Print the simulated "diff"
+# command so that the order of arguments is clear.  Don't bother with @@ lines.
+emit_diff_u_header_ ()
+{
+  printf '%s\n' "diff -u $*" \
+    "--- $1    1970-01-01" \
+    "+++ $2    1970-01-01"
+}
+
+# Arrange not to let diff or cmp operate on /dev/null,
+# since on some systems (at least OSF/1 5.1), that doesn't work.
+# When there are not two arguments, or no argument is /dev/null, return 2.
+# When one argument is /dev/null and the other is not empty,
+# cat the nonempty file to stderr and return 1.
+# Otherwise, return 0.
+compare_dev_null_ ()
+{
+  test $# = 2 || return 2
+
+  if test "x$1" = x/dev/null; then
+    test -s "$2" || return 0
+    { emit_diff_u_header_ "$@"; sed 's/^/+/' -- "$2"; } >&2
+    return 1
+  fi
+
+  if test "x$2" = x/dev/null; then
+    test -s "$1" || return 0
+    { emit_diff_u_header_ "$@"; sed 's/^/-/' -- "$1"; } >&2
+    return 1
+  fi
+
+  return 2
+}
+
+if diff_out_=`( diff -u "$0" "$0" < /dev/null ) 2>/dev/null`; then
+  if test -z "$diff_out_"; then
+    compare_ () { diff -u "$@"; }
+  else
+    compare_ ()
+    {
+      if diff -u "$@" > diff.out; then
+        # No differences were found, but Solaris 'diff' produces output
+        # "No differences encountered". Hide this output.
+        rm -f diff.out
+        true
+      else
+        cat diff.out
+        rm -f diff.out
+        false
+      fi
+    }
+  fi
+elif diff_out_=`( diff -c "$0" "$0" < /dev/null ) 2>/dev/null`; then
+  if test -z "$diff_out_"; then
+    compare_ () { diff -c "$@"; }
+  else
+    compare_ ()
+    {
+      if diff -c "$@" > diff.out; then
+        # No differences were found, but AIX and HP-UX 'diff' produce output
+        # "No differences encountered" or "There are no differences between the
+        # files.". Hide this output.
+        rm -f diff.out
+        true
+      else
+        cat diff.out
+        rm -f diff.out
+        false
+      fi
+    }
+  fi
 elif ( cmp --version < /dev/null 2>&1 | grep GNU ) > /dev/null 2>&1; then
-  compare () { cmp -s "$@"; }
+  compare_ () { cmp -s "$@"; }
 else
-  compare () { cmp "$@"; }
+  compare_ () { cmp "$@"; }
 fi

+# Usage: compare EXPECTED ACTUAL
+#
+# Given compare_dev_null_'s preprocessing, defer to compare_ if 2 or more.
+# Otherwise, propagate $? to caller: any diffs have already been printed.
+compare ()
+{
+  compare_dev_null_ "$@"
+  case $? in
+    0|1) return $?;;
+    *) compare_ "$@";;
+  esac
+}
+
 # An arbitrary prefix to help distinguish test directories.
 testdir_prefix_ () { printf gt; }

--
1.7.8.rc3.23.ge14d6



reply via email to

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