* find/defs.h: Eliminate useless parentheses in #if. * find/find.c (safely_chdir): Likewise. * find/pred.c: Likewise. * lib/buildcmd.c: Likewise. * lib/fdleak.c: Likewise * xargs/xargs.c: Likewise. * find/parser.c: Likewise. (ISDIGIT): Simplify, and avoid undefining isascii. * cfg.mk (local-checks-to-skip): Remove sc_prohibit_cvs_keyword, since the test produces no hits anyway. Explain why we avoid sc_two_space_separator_in_usage. Enable the sc_useless_cpp_parens check. --- ChangeLog | 14 ++++++++++++++ cfg.mk | 13 ++++++++----- find/defs.h | 4 ++-- find/find.c | 2 +- find/parser.c | 13 +++++-------- find/pred.c | 4 ++-- lib/buildcmd.c | 2 +- lib/fdleak.c | 4 ++-- lib/qmark.c | 16 ++++++++-------- xargs/xargs.c | 2 +- 10 files changed, 44 insertions(+), 30 deletions(-)
diff --git a/ChangeLog b/ChangeLog index 149d430..c1af90d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,20 @@ 2011-06-11 James Youngman <[email protected]> + Enable more syntax checks, eliminate useless C preprocessor parentheses + * find/defs.h: Eliminate useless parentheses in #if. + * find/find.c (safely_chdir): Likewise. + * find/pred.c: Likewise. + * lib/buildcmd.c: Likewise. + * lib/fdleak.c: Likewise + * xargs/xargs.c: Likewise. + * find/parser.c: Likewise. + (ISDIGIT): Simplify, and avoid undefining isascii. + * cfg.mk (local-checks-to-skip): Remove sc_prohibit_cvs_keyword, + since the test produces no hits anyway. Explain why we avoid + sc_two_space_separator_in_usage. Enable the sc_useless_cpp_parens + check. + Use stat-size macros in pred.c also. * find/pred.c: Include stat-size. Eliminate definitions of DEV_BSIZE, ST_BLKSIZE, ST_NBLOCKS, ST_NBLOCKSIZE macros which are diff --git a/cfg.mk b/cfg.mk index 4cb14aa..a799049 100644 --- a/cfg.mk +++ b/cfg.mk @@ -26,17 +26,20 @@ local-checks-to-skip += sc_makefile_at_at_check # False positives I don't have a workaround for yet. # sc_space_tab: several .xo test output files contain this sequence # for testing xargs's handling of white space. -local-checks-to-skip += sc_obsolete_symbols sc_prohibit_cvs_keyword \ - sc_two_space_separator_in_usage \ +local-checks-to-skip += sc_obsolete_symbols \ sc_space_tab + + +# Skip sc_two_space_separator_in_usage because it reflects the requirements +# of help2man. It gets run on files that are not help2man inputs, and in +# any case we don't use help2man at all. +local-checks-to-skip += sc_two_space_separator_in_usage + # Problems that have some false positives and some real ones; tease # apart later. local-checks-to-skip += sc_trailing_blank -# Problems partly fixed in other patches which aren't merged yet. -local-checks-to-skip += sc_useless_cpp_parens - # Problems we can't esaily fixed because they apply to files which we need # to keep in sync, so can't easily make a local change to. # sc_texinfo_acronym: perms.texi from coreutils uses @acronym{GNU}. diff --git a/find/defs.h b/find/defs.h index 9ecfb73..0801ad2 100644 --- a/find/defs.h +++ b/find/defs.h @@ -20,10 +20,10 @@ #ifndef INC_DEFS_H #define INC_DEFS_H 1 -#if !defined(ALREADY_INCLUDED_CONFIG_H) +#if !defined ALREADY_INCLUDED_CONFIG_H /* * Savannah bug #20128: if we include some system header and it - * includes some othersecond system header, the second system header + * includes some other second system header, the second system header * may in fact turn out to be a file provided by gnulib. For that * situation, we need to have already included <config.h> so that the * Gnulib files have access to the information probed by their diff --git a/find/find.c b/find/find.c index ffb6b08..9dcfbd5 100644 --- a/find/find.c +++ b/find/find.c @@ -878,7 +878,7 @@ safely_chdir (const char *dest, */ complete_pending_execdirs (); -#if !defined(O_NOFOLLOW) +#if !defined O_NOFOLLOW options.open_nofollow_available = false; #endif if (options.open_nofollow_available) diff --git a/find/parser.c b/find/parser.c index 53cb975..7b82ae7 100644 --- a/find/parser.c +++ b/find/parser.c @@ -70,15 +70,12 @@ # define N_(String) String #endif -#if !defined (isascii) || defined (STDC_HEADERS) -#ifdef isascii -#undef isascii -#endif -#define isascii(c) 1 +#if defined STDC_HEADERS +# define ISDIGIT(c) isdigit ((unsigned char)c) +#else +# define ISDIGIT(c) (isascii ((unsigned char)c) && isdigit ((unsigned char)c)) #endif -#define ISDIGIT(c) (isascii ((unsigned char)c) && isdigit ((unsigned char)c)) - #ifndef HAVE_ENDGRENT #define endgrent () #endif @@ -1606,7 +1603,7 @@ parse_newerXY (const struct parser_table* entry, char **argv, int *arg_ptr) y = argv[*arg_ptr][7]; -#if !defined(HAVE_STRUCT_STAT_ST_BIRTHTIME) && !defined(HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC) && !defined(HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC) && !defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC +#if !defined HAVE_STRUCT_STAT_ST_BIRTHTIME && !defined HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC && !defined HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC && !defined HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC if ('B' == x || 'B' == y) { error (0, 0, diff --git a/find/pred.c b/find/pred.c index 1ebb36d..3b15a6e 100644 --- a/find/pred.c +++ b/find/pred.c @@ -68,8 +68,8 @@ # define N_(String) String #endif -#if !defined(SIGCHLD) && defined(SIGCLD) -#define SIGCHLD SIGCLD +#if defined SIGCLD && !defined SIGCHLD +# define SIGCHLD SIGCLD #endif diff --git a/lib/buildcmd.c b/lib/buildcmd.c index 160e709..f05167e 100644 --- a/lib/buildcmd.c +++ b/lib/buildcmd.c @@ -55,7 +55,7 @@ #ifndef _POSIX_SOURCE #include <sys/param.h> #endif -#if !defined(ARG_MAX) && defined(NCARGS) +#if defined NCARGS && !defined ARG_MAX /* We include sys/param.h in order to detect this case. */ #error "You have an unusual system. Once you remove this error message from buildcmd.c, it should work, but please make sure that DejaGnu is installed on your system and that 'make check' passes before using the findutils programs. Please mail [email protected] to tell us about your system." #define ARG_MAX NCARGS diff --git a/lib/fdleak.c b/lib/fdleak.c index f366666..fa3007a 100644 --- a/lib/fdleak.c +++ b/lib/fdleak.c @@ -19,7 +19,7 @@ #include <unistd.h> #include <poll.h> #include <fcntl.h> -#if defined (HAVE_SYS_RESOURCE_H) +#if defined HAVE_SYS_RESOURCE_H #include <sys/resource.h> #endif #include <limits.h> @@ -114,7 +114,7 @@ get_max_fd (void) open_max = _POSIX_OPEN_MAX; /* underestimate */ /* We assume if RLIMIT_NOFILE is defined, all the related macros are, too. */ -#if defined (HAVE_GETRUSAGE) && defined (RLIMIT_NOFILE) +#if defined HAVE_GETRUSAGE && defined RLIMIT_NOFILE if (0 == getrlimit (RLIMIT_NOFILE, &fd_limit)) { if (fd_limit.rlim_cur == RLIM_INFINITY) diff --git a/lib/qmark.c b/lib/qmark.c index b55f134..d7d567c 100644 --- a/lib/qmark.c +++ b/lib/qmark.c @@ -51,21 +51,21 @@ outside the range -1 <= c <= 255. One is tempted to write isupper(c) with c being of type `char', but this is wrong if c is an 8-bit character >= 128 which gets sign-extended to a negative value. - The macro ISUPPER protects against this as well." */ + The macro ISUPPER protects against this as well." + (Actually that rule of ISUPPER is now taken by to_uchar). +*/ - - -/* ISPRINT is defined in <sys/euc.h> on at least Solaris2.6 systems. */ -#undef ISPRINT -#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c)) - -#if STDC_HEADERS || (!defined (isascii) && !HAVE_ISASCII) +#if STDC_HEADERS # define IN_CTYPE_DOMAIN(c) 1 #else # define IN_CTYPE_DOMAIN(c) isascii(c) #endif +/* ISPRINT is defined in <sys/euc.h> on at least Solaris2.6 systems. */ +#undef ISPRINT +#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c)) + diff --git a/xargs/xargs.c b/xargs/xargs.c index 2907fc5..1b668a9 100644 --- a/xargs/xargs.c +++ b/xargs/xargs.c @@ -57,7 +57,7 @@ #include <wchar.h> #include <stdint.h> -#if !defined(SIGCHLD) && defined(SIGCLD) +#if defined SIGCLD && !defined SIGCHLD #define SIGCHLD SIGCLD #endif -- 1.7.2.5
