I've adjusted warning options to accommodate changes in gcc: >From 50ca12c28d2f0b3df73a026a1fecea294c4cb42c Mon Sep 17 00:00:00 2001 From: Jim Meyering <[email protected]> Date: Sun, 17 May 2009 11:43:21 +0200 Subject: [PATCH 1/6] build: turn off -Wlong-long
* configure.ac: With --enable-gcc-warnings, -Wlong-long would cause compilation failure due to inclusion of lib/gethrxtime.h. Initialize "nw". --- configure.ac | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/configure.ac b/configure.ac index 8b05b11..b738d4a 100644 --- a/configure.ac +++ b/configure.ac @@ -60,9 +60,11 @@ if test "$gl_gcc_warnings" = yes; then gl_WARN_ADD([-Werror], [WERROR_CFLAGS]) AC_SUBST([WERROR_CFLAGS]) - # Add many warnings, except some... + nw= + # This, $nw, is the list of warnings we disable. nw="$nw -Wdeclaration-after-statement" # too useful to forbid nw="$nw -Waggregate-return" # anachronistic + nw="$nw -Wlong-long" # C90 is anachronistic (lib/gethrxtime.h) nw="$nw -Wc++-compat" # We don't care about C++ compilers nw="$nw -Wundef" # Warns on '#if GNULIB_FOO' etc in gnulib nw="$nw -Wtraditional" # Warns on #elif which we use often -- 1.6.3.1.83.g37eb7 >From 9b54961b13af78c4805076c6b6739cc282b53c5e Mon Sep 17 00:00:00 2001 From: Jim Meyering <[email protected]> Date: Sun, 17 May 2009 13:01:37 +0200 Subject: [PATCH 2/6] maint: define ARRAY_CARDINALITY in system.h * src/system.h (ARRAY_CARDINALITY): Define if not already defined. --- src/system.h | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/src/system.h b/src/system.h index 5bc23b3..74d86bb 100644 --- a/src/system.h +++ b/src/system.h @@ -702,3 +702,7 @@ io_blksize (struct stat sb) } void usage (int status) ATTRIBUTE_NORETURN; + +#ifndef ARRAY_CARDINALITY +# define ARRAY_CARDINALITY(Array) (sizeof (Array) / sizeof *(Array)) +#endif -- 1.6.3.1.83.g37eb7 >From 65ed4ca07bd18c2038b5863ed1e18d3bfc8e696d Mon Sep 17 00:00:00 2001 From: Jim Meyering <[email protected]> Date: Sun, 17 May 2009 12:47:24 +0200 Subject: [PATCH 3/6] build: tr: avoid a warning due to newer gcc's -Wenum-compare * src/tr.c (N_CHAR_CLASSES): Remove anonymous enum definition. (look_up_char_class): Use ARRAY_CARDINALITY, rather than N_CHAR_CLASSES. --- src/tr.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/tr.c b/src/tr.c index f4b5317..e9338d4 100644 --- a/src/tr.c +++ b/src/tr.c @@ -1,5 +1,5 @@ /* tr -- a filter to translate characters - Copyright (C) 91, 1995-2008 Free Software Foundation, Inc. + Copyright (C) 91, 1995-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -246,7 +246,6 @@ static char const *const char_class_name[] = "alnum", "alpha", "blank", "cntrl", "digit", "graph", "lower", "print", "punct", "space", "upper", "xdigit" }; -enum { N_CHAR_CLASSES = sizeof char_class_name / sizeof char_class_name[0] }; /* Array of boolean values. A character `c' is a member of the squeeze set if and only if in_squeeze_set[c] is true. The squeeze @@ -547,7 +546,7 @@ look_up_char_class (char const *class_str, size_t len) { enum Char_class i; - for (i = 0; i < N_CHAR_CLASSES; i++) + for (i = 0; i < ARRAY_CARDINALITY (char_class_name); i++) if (strncmp (class_str, char_class_name[i], len) == 0 && strlen (char_class_name[i]) == len) return i; -- 1.6.3.1.83.g37eb7 >From 9593a3d8e78ece58deab5a30632021322bbc16d0 Mon Sep 17 00:00:00 2001 From: Jim Meyering <[email protected]> Date: Sun, 17 May 2009 13:02:25 +0200 Subject: [PATCH 4/6] maint: use ARRAY_CARDINALITY more * src/sort.c (main): Use ARRAY_CARDINALITY, rather than open-coding it. * src/factor.c (WHEEL_END): Likewise. * src/csplit.c (main): Likewise. * src/od.c: Likewise, * src/ls.c (main): Likewise. (N_ENTRIES): Remove definition. Use ARRAY_CARDINALITY instead. * src/dircolors.c: Likewise. (array_len): Remove definition. --- src/csplit.c | 2 +- src/dircolors.c | 5 ++--- src/factor.c | 2 +- src/ls.c | 6 +++--- src/od.c | 7 +++---- src/sort.c | 2 +- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/csplit.c b/src/csplit.c index 4f0beb6..b2892c9 100644 --- a/src/csplit.c +++ b/src/csplit.c @@ -1403,7 +1403,7 @@ main (int argc, char **argv) SIGXFSZ, #endif }; - enum { nsigs = sizeof sig / sizeof sig[0] }; + enum { nsigs = ARRAY_CARDINALITY (sig) }; struct sigaction act; diff --git a/src/dircolors.c b/src/dircolors.c index 7dad7fd..f01d557 100644 --- a/src/dircolors.c +++ b/src/dircolors.c @@ -1,5 +1,5 @@ /* dircolors - output commands to set the LS_COLOR environment variable - Copyright (C) 1996-2008 Free Software Foundation, Inc. + Copyright (C) 1996-2009 Free Software Foundation, Inc. Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000 H. Peter Anvin This program is free software: you can redistribute it and/or modify @@ -73,8 +73,7 @@ static const char *const ls_codes[] = "so", "bd", "bd", "cd", "cd", "do", "ex", "lc", "lc", "rc", "rc", "ec", "ec", "su", "su", "sg", "sg", "st", "ow", "ow", "tw", "tw", "ca", "hl", "cl", NULL }; -#define array_len(Array) (sizeof (Array) / sizeof *(Array)) -verify (array_len (slack_codes) == array_len (ls_codes)); +verify (ARRAY_CARDINALITY (slack_codes) == ARRAY_CARDINALITY (ls_codes)); static struct option const long_options[] = { diff --git a/src/factor.c b/src/factor.c index 47273a2..9ac703c 100644 --- a/src/factor.c +++ b/src/factor.c @@ -282,7 +282,7 @@ static const unsigned char wheel_tab[] = }; #define WHEEL_START (wheel_tab + WHEEL_SIZE) -#define WHEEL_END (wheel_tab + (sizeof wheel_tab / sizeof wheel_tab[0])) +#define WHEEL_END (wheel_tab + ARRAY_CARDINALITY (wheel_tab)) /* FIXME: comment */ diff --git a/src/ls.c b/src/ls.c index 795d1ed..838431c 100644 --- a/src/ls.c +++ b/src/ls.c @@ -1223,7 +1223,7 @@ main (int argc, char **argv) SIGXFSZ, #endif }; - enum { nsigs = sizeof sig / sizeof sig[0] }; + enum { nsigs = ARRAY_CARDINALITY (sig) }; #if ! SA_NOCLDSTOP bool caught_sig[nsigs]; @@ -1238,8 +1238,8 @@ main (int argc, char **argv) initialize_exit_failure (LS_FAILURE); atexit (close_stdout); -#define N_ENTRIES(Array) (sizeof Array / sizeof *(Array)) - assert (N_ENTRIES (color_indicator) + 1 == N_ENTRIES (indicator_name)); + assert (ARRAY_CARDINALITY (color_indicator) + 1 + == ARRAY_CARDINALITY (indicator_name)); exit_status = EXIT_SUCCESS; print_dir_name = true; diff --git a/src/od.c b/src/od.c index 2dcb398..56585bd 100644 --- a/src/od.c +++ b/src/od.c @@ -1,5 +1,5 @@ /* od -- dump files in octal and other formats - Copyright (C) 92, 1995-2008 Free Software Foundation, Inc. + Copyright (C) 92, 1995-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -148,8 +148,7 @@ static unsigned int const bytes_to_hex_digits[] = /* It'll be a while before we see integral types wider than 16 bytes, but if/when it happens, this check will catch it. Without this check, a wider type would provoke a buffer overrun. */ -verify (MAX_INTEGRAL_TYPE_SIZE - < sizeof bytes_to_hex_digits / sizeof *bytes_to_hex_digits); +verify (MAX_INTEGRAL_TYPE_SIZE < ARRAY_CARDINALITY (bytes_to_hex_digits)); /* Make sure the other arrays have the same length. */ verify (sizeof bytes_to_oct_digits == sizeof bytes_to_signed_dec_digits); @@ -172,7 +171,7 @@ static const int width_bytes[] = /* Ensure that for each member of `enum size_spec' there is an initializer in the width_bytes array. */ -verify (sizeof width_bytes / sizeof width_bytes[0] == N_SIZE_SPECS); +verify (ARRAY_CARDINALITY (width_bytes) == N_SIZE_SPECS); /* Names for some non-printing characters. */ static char const charname[33][4] = diff --git a/src/sort.c b/src/sort.c index f48d727..6dea2ff 100644 --- a/src/sort.c +++ b/src/sort.c @@ -3104,7 +3104,7 @@ main (int argc, char **argv) SIGXFSZ, #endif }; - enum { nsigs = sizeof sig / sizeof sig[0] }; + enum { nsigs = ARRAY_CARDINALITY (sig) }; #if SA_NOCLDSTOP struct sigaction act; -- 1.6.3.1.83.g37eb7 >From 2726826c720d9387f631c35e9c8401abd75a1087 Mon Sep 17 00:00:00 2001 From: Jim Meyering <[email protected]> Date: Sun, 17 May 2009 13:47:39 +0200 Subject: [PATCH 5/6] build: avoid new warnings from gcc 4.5.0 20090517 * configure.ac: Add an explicit -Wno-logical-op, now that not listing -Wlogical-op is insufficient. --- configure.ac | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/configure.ac b/configure.ac index b738d4a..68a940c 100644 --- a/configure.ac +++ b/configure.ac @@ -99,6 +99,11 @@ if test "$gl_gcc_warnings" = yes; then gl_WARN_ADD([-Wno-sign-compare]) # Too many warnings for now gl_WARN_ADD([-Wno-pointer-sign]) # Too many warnings for now gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now + + # In spite of excluding -Wlogical-op above, it is enabled, as of + # gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c + gl_WARN_ADD([-Wno-logical-op]) + gl_WARN_ADD([-fdiagnostics-show-option]) AC_SUBST([WARN_CFLAGS]) -- 1.6.3.1.83.g37eb7 >From 564622fbeab39ff9532657a2bff61be542bf0227 Mon Sep 17 00:00:00 2001 From: Jim Meyering <[email protected]> Date: Sun, 17 May 2009 15:22:11 +0200 Subject: [PATCH 6/6] build: avoid new "make distcheck" failure with gcc 4.5.0 20090517 * dist-check.mk (warn_cflags): Add -Wno-enum-compare. --- dist-check.mk | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/dist-check.mk b/dist-check.mk index 16f3859..9a32d17 100644 --- a/dist-check.mk +++ b/dist-check.mk @@ -1,6 +1,12 @@ # Most of this is probably too coreutils-centric to be useful to other packages. warn_cflags = -Dlint -O -Werror -Wall -Wformat -Wshadow -Wpointer-arith + +# anonymous 'enum's are too useful to forbid. Without this, we'd get: +# utimecmp.c:193: error: comparison between 'enum <anonymous>' and \ +# 'enum <anonymous>' when using gcc-4.5.0-20090517. +warn_cflags += -Wno-enum-compare + bin=bin-$$$$ write_loser = printf '\#!%s\necho $$0: bad path 1>&2; exit 1\n' '$(SHELL)' -- 1.6.3.1.83.g37eb7 _______________________________________________ Bug-coreutils mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-coreutils
