[PATCH 0/4] maint: minor fixes

Bernhard Voelker <[email protected]>
Newsgroups gmane.comp.gnu.findutils.bugs,gmane.comp.gnu.findutils.patches
Message-ID <[email protected]>
The recent gnulib update came with some new or changed syntax-check rules,
and also the new test-sigusr source needs some love to pass 'make syntax-check':

* [PATCH 1/4] build: avoid spurious failures due to lack of EGREP definition
* [PATCH 2/4] maint: avoid gnulib sc_prefer_angle_bracket_headers failure
* [PATCH 3/4] xargs: avoid sc_useless_cpp_parens failure
* [PATCH 4/4] tests: avoid various syntax-check failures wrt/

Have a nice day,
Berny
0001-build-avoid-spurious-failures-due-to-lack-of-EGREP-d.patch (text/x-patch, 1.3 KB)
From 8d48e1ee65adc79cb7c71df23c2fa7e645cdef60 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <[email protected]>
Date: Tue, 14 May 2024 16:09:08 +0200
Subject: [PATCH 1/4] build: avoid spurious failures due to lack of EGREP
 definition

Similar to Jim Meyering's commit in coreutils:
http://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=d73ca62c4fa3

* configure.ac: Use AC_PROG_EGREP, since many doc and test rules
use $EGREP.
* cfg.mk (sc_tests_list_consistency): Use grep -E, not $(EGREP) here.
---
 cfg.mk       | 2 +-
 configure.ac | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/cfg.mk b/cfg.mk
index c6b3f5c3..fdbeef38 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -112,7 +112,7 @@ sc_tests_list_consistency:
 	  cd $(top_srcdir);						\
 	  $(SHELL) build-aux/vc-list-files tests			\
 	    | grep -Ev '^tests/init\.sh$$'				\
-	    | $(EGREP) "$$test_extensions_rx\$$";			\
+	    | grep -E "$$test_extensions_rx\$$";			\
 	} | sort | uniq -u | grep . && exit 1; :
 
 # Ensure that all version-controlled test scripts are executable.
diff --git a/configure.ac b/configure.ac
index 94fe4090..8ad4b21f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -89,6 +89,7 @@ fi
 dnl Checks for programs.
 AC_PROG_CC
 AC_PROG_CPP
+AC_PROG_EGREP
 
 dnl for gnulib
 gl_EARLY
-- 
2.45.1
0002-maint-avoid-gnulib-sc_prefer_angle_bracket_headers-f.patch (text/x-patch, 2.9 KB)
From b9c9310eecc6f6d98703619490f31ebda17ebabe Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <[email protected]>
Date: Mon, 20 May 2024 07:41:40 +0200
Subject: [PATCH 2/4] maint: avoid gnulib sc_prefer_angle_bracket_headers
 failure

The following syntax-check rule fails:

  $ make syntax-check
  ...
  maint.mk: Use #include <hdr.h>, not #include "hdr.h" for the above
  make: *** [maint.mk:619: sc_prefer_angle_bracket_headers] Error 1

The rule suggests using '#include <header.h>' instead of
'#include "header.h"' for headers that override system headers.
See gnulib documentation, section "Style of #include statements".

* find/parser.c (#include "fnmatch.h": Change from "..." to <...> style.
* find/pred.c (#include "fnmatch.h"): Likewise.
* find/tree.c (#include "fnmatch.h"): Likewise.
* lib/system.h (#include "error.h"): Likewise.
* locate/locate.c (#include "fnmatch.h"): Likewise.
* tests/xargs/test-sigusr.c (#include "error.h"): Likewise.
---
 find/parser.c             | 2 +-
 find/pred.c               | 2 +-
 find/tree.c               | 2 +-
 lib/system.h              | 3 +--
 locate/locate.c           | 2 +-
 tests/xargs/test-sigusr.c | 2 +-
 6 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/find/parser.c b/find/parser.c
index f95adfc7..e2c19e26 100644
--- a/find/parser.c
+++ b/find/parser.c
@@ -32,7 +32,7 @@
 
 
 /* gnulib headers. */
-#include "fnmatch.h"
+#include <fnmatch.h>
 #include "intprops.h"
 #include "modechange.h"
 #include "mountlist.h"
diff --git a/find/pred.c b/find/pred.c
index 8312f6e2..b2ca071b 100644
--- a/find/pred.c
+++ b/find/pred.c
@@ -38,7 +38,7 @@
 #include "areadlink.h"
 #include "dirname.h"
 #include "fcntl--.h"
-#include "fnmatch.h"
+#include <fnmatch.h>
 #include "stat-size.h"
 #include "stat-time.h"
 #include "yesno.h"
diff --git a/find/tree.c b/find/tree.c
index c42eb9e0..ba85107b 100644
--- a/find/tree.c
+++ b/find/tree.c
@@ -23,7 +23,7 @@
 #include <stdlib.h>
 
 /* gnulib headers. */
-#include "fnmatch.h"
+#include <fnmatch.h>
 #include "xalloc.h"
 
 /* find headers. */
diff --git a/lib/system.h b/lib/system.h
index c716cff7..911557d5 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -19,8 +19,7 @@
 # define SYSTEM_H
 
 # include <locale.h>
-
-# include "error.h"
+# include <error.h>
 
 /* Take care of NLS matters.  */
 
diff --git a/locate/locate.c b/locate/locate.c
index 643cf002..aefb3793 100644
--- a/locate/locate.c
+++ b/locate/locate.c
@@ -80,7 +80,7 @@
 #include <xstrtol.h>
 
 /* gnulib headers. */
-#include "fnmatch.h"
+#include <fnmatch.h>
 #include "progname.h"
 #include "xalloc.h"
 #include "fcntl--.h"
diff --git a/tests/xargs/test-sigusr.c b/tests/xargs/test-sigusr.c
index 616e06bd..7e20500c 100644
--- a/tests/xargs/test-sigusr.c
+++ b/tests/xargs/test-sigusr.c
@@ -29,7 +29,7 @@
 #include <unistd.h>
 
 /* Gnulib modules */
-#include "error.h"
+#include <error.h>
 
 
 enum { FLAGFILE_MAX = 128 };
-- 
2.45.1
0003-xargs-avoid-sc_useless_cpp_parens-failure.patch (text/x-patch, 1.2 KB)
From a76e5e1f028557a24fe4ffb4e56a142d521efbdd Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <[email protected]>
Date: Mon, 20 May 2024 09:13:33 +0200
Subject: [PATCH 3/4] xargs: avoid sc_useless_cpp_parens failure

$ make syntax-check
...
xargs/xargs.c:674:#if !(defined(SIGUSR1) && defined(SIGUSR2))
maint.mk: found useless parentheses in cpp directive
make: *** [maint.mk:924: sc_useless_cpp_parens] Error 1

* xargs/xargs.c (main): Simplify -P #if conditional to avoid the
above syntax-check failure.
---
 xargs/xargs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/xargs/xargs.c b/xargs/xargs.c
index 0f1d0227..e231223a 100644
--- a/xargs/xargs.c
+++ b/xargs/xargs.c
@@ -671,11 +671,11 @@ main (int argc, char **argv)
 	case 'P':
 	  /* Allow only up to MAX_PROC_MAX child processes. */
 	  proc_max = parse_num (optarg, 'P', 0L, MAX_PROC_MAX, 1);
-#if !(defined(SIGUSR1) && defined(SIGUSR2))
+#if defined SIGUSR1 && defined SIGUSR2
+	  catch_usr_signals = true;
+#else
 	  error (0, 0, _("SIGUSR1 and SIGUSR2 are not both defined, so the -P option does nothing."));
 	  proc_max = 1;
-#else
-	  catch_usr_signals = true;
 #endif
 	  break;
 
-- 
2.45.1
0004-tests-avoid-various-syntax-check-failures-wrt-test-s.patch (text/x-patch, 5.1 KB)
From 32132e9749813253250b2603757d44faa322666f Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <[email protected]>
Date: Mon, 20 May 2024 10:00:25 +0200
Subject: [PATCH 4/4] tests: avoid various syntax-check failures wrt/
 test-sigusr

The syntax-check complains:
  $ make syntax-check -k
  ...
  maint.mk: the above files do not call bindtextdomain
  make: *** [maint.mk:869: sc_bindtextdomain] Error 1
  ...
  maint.mk: the above files do not include <config.h>
  make: *** [maint.mk:509: sc_require_config_h] Error 1
  ...
  maint.mk: use EXIT_* values rather than magic number
  make: *** [maint.mk:411: sc_prohibit_magic_number_exit] Error 1
  ...
  maint.mk: found unmarked diagnostic(s)
  make: *** [maint.mk:916: sc_unmarked_diagnostics] Error 1
  ...
  make: *** [cfg.mk:111: sc_tests_list_consistency] Error 1
  ...
  maint.mk: Please make test executable: tests/xargs/test-sigusr.c
  make: *** [cfg.mk:124: sc_tests_executable] Error 1

* cfg.mk (exclude_file_name_regexp--sc_bindtextdomain): Add test-sigusr.
(exclude_file_name_regexp--sc_unmarked_diagnostics): Define with the
pattern of the test-sigusr source file.
(sc_tests_list_consistency): Strip off ".c" suffix.
(sc_tests_executable): Exempt C source from this rule.
* tests/local.mk (TEST_EXTENSIONS): Add .c sources, needed also for
sc_tests_list_consistency to work.
* tests/xargs/test-sigusr.c (#include <config.h>): Add to avoid
sc_require_config_h failure.
(verify_signal_ignored): Call exit with EXIT_FAILURE instead of 1 to
avoid sc_prohibit_magic_number_exit failure.
(verify_signal_is_fatal): Likewise.
(verify_signal_is_nonfatal_with_p): Likewise.
* tests/.gitignore (/xargs/test-sigusr): While at it, add an entry
for the built test program here.
---
 cfg.mk                    | 10 ++++++++--
 tests/.gitignore          |  1 +
 tests/local.mk            |  2 +-
 tests/xargs/test-sigusr.c | 10 ++++++----
 4 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/cfg.mk b/cfg.mk
index fdbeef38..60bc8cd5 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -86,7 +86,11 @@ exclude_file_name_regexp--sc_texinfo_acronym = doc/perm\.texi
 
 # List syntax-check exemptions.
 exclude_file_name_regexp--sc_bindtextdomain = \
-  ^(locate/frcode|lib/regexprops|lib/test_splitstring|find/getlimits)\.c$$
+  ^(locate/frcode|lib/regexprops|lib/test_splitstring|find/getlimits|tests/xargs/test-sigusr)\.c$$
+
+# sc_unmarked_diagnostics: exempt internal programs.
+exclude_file_name_regexp--sc_unmarked_diagnostics = \
+  ^(tests/xargs/test-sigusr)\.c$$
 
 # sc_prohibit_strcmp is broken because it gives false positives for
 # cases where neither argument is a string literal.
@@ -112,7 +116,8 @@ sc_tests_list_consistency:
 	  cd $(top_srcdir);						\
 	  $(SHELL) build-aux/vc-list-files tests			\
 	    | grep -Ev '^tests/init\.sh$$'				\
-	    | grep -E "$$test_extensions_rx\$$";			\
+	    | grep -E "$$test_extensions_rx\$$"				\
+	    | sed 's/\.c$$//';						\
 	} | sort | uniq -u | grep . && exit 1; :
 
 # Ensure that all version-controlled test scripts are executable.
@@ -122,6 +127,7 @@ sc_tests_executable:
 	find $(srcdir)/tests \( $$find_ext \) \! -perm -u+x -print	   \
 	  | { sed "s|^$(srcdir)/||"; git ls-files $(srcdir)/tests/; }	   \
 	  | sort | uniq -d						   \
+	  | grep -Ev '^tests/.*\.c$$'					   \
 	  | sed -e "s/^/$(ME): Please make test executable: /" | grep .	   \
 	    && exit 1; :
 
diff --git a/tests/.gitignore b/tests/.gitignore
index 702a9418..46240f57 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,3 +1,4 @@
 /*/*.log
 /*/*.trs
 /test-suite.log
+/xargs/test-sigusr
diff --git a/tests/local.mk b/tests/local.mk
index 7a7e0aa8..4b96eed1 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -25,7 +25,7 @@ root_tests = $(all_root_tests)
 
 EXTRA_DIST += $(all_tests)
 
-TEST_EXTENSIONS = .sh
+TEST_EXTENSIONS = .sh .c
 
 SH_LOG_COMPILER = $(SHELL)
 
diff --git a/tests/xargs/test-sigusr.c b/tests/xargs/test-sigusr.c
index 7e20500c..3815c2ff 100644
--- a/tests/xargs/test-sigusr.c
+++ b/tests/xargs/test-sigusr.c
@@ -16,6 +16,8 @@
 
    Written by James Youngman <[email protected]>
 */
+/* config.h must be included first. */
+#include <config.h>
 
 /* System headers */
 #include <assert.h>
@@ -285,12 +287,12 @@ verify_signal_ignored(int signum)
   if (status.fatalsig)
     {
       fprintf(stderr, "xargs should not have exited fatally on receipt of signal %d\n", signum);
-      exit(1);
+      exit(EXIT_FAILURE);
     }
   if (status.retval)
     {
       fprintf(stderr, "xargs should not have returned a nonzero exit status %d\n", status.retval);
-      exit(1);
+      exit(EXIT_FAILURE);
     }
   fputs("OK\n", stdout);
 }
@@ -306,7 +308,7 @@ verify_signal_is_fatal(int signum)
   if (!status.fatalsig)
     {
       fprintf(stderr, "xargs should have exited fatally on receipt of signal %d\n", signum);
-      exit(1);
+      exit(EXIT_FAILURE);
     }
   fputs("OK\n", stdout);
 }
@@ -322,7 +324,7 @@ verify_signal_is_nonfatal_with_p(int signum)
   if (status.fatalsig)
     {
       fprintf(stderr, "xargs -P should not have exited fatally on receipt of signal %d\n", signum);
-      exit(1);
+      exit(EXIT_FAILURE);
     }
   fputs("OK\n", stdout);
 }
-- 
2.45.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.