* configure.ac: Turn on -Wall warnings. * find/find.c (process_dir): Print unsigned values of unspecified width as uintmax_t. * xargs/xargs.c: Include <inttypes.h> and <stdint.h>, but without the include guards (since we assume an ISO C platform anyway). * import-gnulib.config (modules): Add modules inttypes and stdint.
Signed-off-by: James Youngman <[email protected]> --- ChangeLog | 10 +++++++++ configure.ac | 1 + find/find.c | 6 ++-- import-gnulib.config | 2 + xargs/xargs.c | 51 ++++++++++++++----------------------------------- 5 files changed, 31 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index dc58f8f..4af5f4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-03-08 James Youngman <[email protected]> + + Enable -Wall compiler warnings and fix them. + * configure.ac: Turn on -Wall warnings. + * find/find.c (process_dir): Print unsigned values of unspecified + width as uintmax_t. + * xargs/xargs.c: Include <inttypes.h> and <stdint.h>, but without + the include guards (since we assume an ISO C platform anyway). + * import-gnulib.config (modules): Add modules inttypes and stdint. + 2009-03-06 James Youngman <[email protected]> Change suffix for non-release versions from -CVS to -git. diff --git a/configure.ac b/configure.ac index ce8b7d8..5904ab2 100644 --- a/configure.ac +++ b/configure.ac @@ -90,6 +90,7 @@ gl_INIT dnl Enable various GCC warnings. gl_WARN_ADD([-Wdeclaration-after-statement]) +gl_WARN_ADD([-Wall]) dnl Older versions of gnulib/m4/nls.m4 provide AM_MKINSTALLDIRS. diff --git a/find/find.c b/find/find.c index fbd0db8..450f835 100644 --- a/find/find.c +++ b/find/find.c @@ -1420,10 +1420,10 @@ process_dir (char *pathname, char *name, int pathlen, const struct stat *statp, * doesn't really handle hard links with Unix semantics. * In the latter case, -noleaf should be used routinely. */ - error(0, 0, _("WARNING: Hard link count is wrong for %s (saw only st_nlink=%d but we already saw %d subdirectories): this may be a bug in your file system driver. Automatically turning on find's -noleaf option. Earlier results may have failed to include directories that should have been searched."), + error(0, 0, _("WARNING: Hard link count is wrong for %s (saw only st_nlink=%" PRIuMAX " but we already saw %" PRIuMAX " subdirectories): this may be a bug in your file system driver. Automatically turning on find's -noleaf option. Earlier results may have failed to include directories that should have been searched."), safely_quote_err_filename(0, pathname), - statp->st_nlink, - dircount); + (uintmax_t) statp->st_nlink, + (uintmax_t) dircount); state.exit_status = 1; /* We know the result is wrong, now */ options.no_leaf_check = true; /* Don't make same mistake again */ diff --git a/import-gnulib.config b/import-gnulib.config index 1591b61..cf9912e 100644 --- a/import-gnulib.config +++ b/import-gnulib.config @@ -48,6 +48,7 @@ gpl-3.0 human idcache inline +inttypes lstat malloc mbscasestr @@ -64,6 +65,7 @@ rpmatch savedir stat-macros stat-time +stdint stpcpy strcasestr strdup-posix diff --git a/xargs/xargs.c b/xargs/xargs.c index 895c280..d3b1969 100644 --- a/xargs/xargs.c +++ b/xargs/xargs.c @@ -51,9 +51,13 @@ #define ISSPACE(c) (ISBLANK (c) || (c) == '\n' || (c) == '\r' \ || (c) == '\f' || (c) == '\v') -#include <sys/types.h> #include <stdio.h> #include <errno.h> +#include <limits.h> +#include <stdint.h> +#include <inttypes.h> + +#include <sys/types.h> #include <getopt.h> #include <fcntl.h> @@ -71,13 +75,7 @@ #define memcpy(dest, source, count) (bcopy((source), (dest), (count))) #endif -#ifndef _POSIX_SOURCE #include <sys/param.h> -#endif - -#ifdef HAVE_LIMITS_H -#include <limits.h> -#endif #ifndef LONG_MAX #define LONG_MAX (~(1 << (sizeof (long) * 8 - 1))) @@ -665,42 +663,23 @@ main (int argc, char **argv) argv = &default_cmd; } - /* We want to be able to print size_t values as unsigned long, so if - * the cast isn't value-preserving, we have a problem. This isn't a - * problem in C89, because size_t was known to be no wider than - * unsigned long. In C99 this is no longer the case, but there are - * special C99 ways to print such values. Unfortunately this - * program tries to work on both C89 and C99 systems. - */ -#if defined SIZE_MAX -# if SIZE_MAX > ULONG_MAX -# error "I'm not sure how to print size_t values on your system" -# endif -#else - /* Without SIZE_MAX (i.e. limits.h) this is probably - * close to the best we can do. - */ - verify_true (sizeof(size_t) <= sizeof(unsigned long)); -#endif - if (show_limits) { fprintf(stderr, - _("Your environment variables take up %lu bytes\n"), - (unsigned long)bc_size_of_environment()); + _("Your environment variables take up %" PRIuMAX " bytes\n"), + (uintmax_t)bc_size_of_environment()); fprintf(stderr, - _("POSIX upper limit on argument length (this system): %lu\n"), - (unsigned long)bc_ctl.posix_arg_size_max); + _("POSIX upper limit on argument length (this system): %" PRIuMAX "\n"), + (uintmax_t)bc_ctl.posix_arg_size_max); fprintf(stderr, - _("POSIX smallest allowable upper limit on argument length (all systems): %lu\n"), - (unsigned long)bc_ctl.posix_arg_size_min); + _("POSIX smallest allowable upper limit on argument length (all systems): %" PRIuMAX "\n"), + (uintmax_t)bc_ctl.posix_arg_size_min); fprintf(stderr, - _("Maximum length of command we could actually use: %ld\n"), - (unsigned long)(bc_ctl.posix_arg_size_max - - bc_size_of_environment())); + _("Maximum length of command we could actually use: %" PRIuMAX "\n"), + (uintmax_t)(bc_ctl.posix_arg_size_max - bc_size_of_environment())); fprintf(stderr, - _("Size of command buffer we are actually using: %lu\n"), - (unsigned long)bc_ctl.arg_max); + _("Size of command buffer we are actually using: %" PRIuMAX "\n"), + (uintmax_t)bc_ctl.arg_max); if (isatty(STDIN_FILENO)) { -- 1.5.6.5
