summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Youngman <jay@gnu.org>2011-06-11 20:58:59 +0100
committerJames Youngman <jay@gnu.org>2011-06-12 02:38:09 +0100
commit28e02ca086250fb8dfdf55a33ebc661f7fa7613d (patch)
tree8b523150198872ec9e2d9d6e0c196e00ce850ecc
parent0558bb105471d746a7c1a4d6585e3917438c7a42 (diff)
downloadfindutils-28e02ca086250fb8dfdf55a33ebc661f7fa7613d.tar.gz
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.
-rw-r--r--ChangeLog14
-rw-r--r--cfg.mk13
-rw-r--r--find/defs.h4
-rw-r--r--find/find.c2
-rw-r--r--find/parser.c13
-rw-r--r--find/pred.c4
-rw-r--r--lib/buildcmd.c2
-rw-r--r--lib/fdleak.c4
-rw-r--r--lib/qmark.c16
-rw-r--r--xargs/xargs.c2
10 files changed, 44 insertions, 30 deletions
diff --git a/ChangeLog b/ChangeLog
index 149d430c..c1af90dc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,20 @@
2011-06-11 James Youngman <jay@gnu.org>
+ 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 4cb14aa5..a7990499 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 9ecfb73e..0801ad2d 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 ffb6b08b..9dcfbd5d 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 53cb975b..7b82ae7a 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 1ebb36db..3b15a6e5 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 160e7091..f05167e7 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 bug-findutils@gnu.org to tell us about your system."
#define ARG_MAX NCARGS
diff --git a/lib/fdleak.c b/lib/fdleak.c
index f3666662..fa3007a1 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 b55f134f..d7d567c4 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 2907fc50..1b668a97 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