bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#6087: maint: extend the always_defined_macros syntax-check


From: Jim Meyering
Subject: bug#6087: maint: extend the always_defined_macros syntax-check
Date: Mon, 03 May 2010 12:30:45 +0200

Three files in coreutils defined WIFSIGNALED and WTERMSIG macros
to accommodate systems that lack them.  However, now that gnulib's
sys/wait.h guarantees those, there's no point.  I've removed them.

    maint: remove now-redundant definitions provided by sys/wait.h
    * src/timeout.c (WIFSIGNALED, WTERMSIG): Remove definitions,
    now that gnulib guarantees they are defined in <sys/wait.h>.
    * src/operand2sig.c: Likewise.
    * src/kill.c: Likewise.

As usual, I want to ensure no regressions and remembered
my always_defined_macros check (currently in coreutils' cfg.mk).

I've extended that check to use not just its few listed .h files,
but all 50+ that are now generated by gnulib.  The result uncovered
some now-useless signal.h-provided macros, too.  I removed those in
the next change set:

    maint: remove now-redundant definitions provided by signal.h
    * src/dd.c (SA_NODEFER, SA_RESETHAND): Remove definitions,
    now that gnulib guarantees they are defined in <signal.h>.
    * src/ls.c (SA_RESTART): Likewise.

Finally, the 3rd change-set does this:

    maint: extend the always_defined_macros syntax-check
    * cfg.mk (gl_generated_headers_): Define.
    (headers_with_interesting_macro_defs): Remove headers covered
    by the above.
    (.re-defmac): Extract symbol names from many more files.
    (sc_always_defined_macros): Use VC_LIST_EXCEPT, not VC_LIST, so
    that we can use the usual exception mechanism.
    * .x-sc_always_defined_macros: New file.  Exempt src/seq.c.
    * Makefile.am (syntax_check_exceptions): Add it here.

I'll probably migrate this rule to gnulib after generalizing it some
more (e.g., removing the system.h check).


>From a9c542e416ffcd29dbe44845197442cc550e5370 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 3 May 2010 10:45:47 +0200
Subject: [PATCH 1/3] maint: remove now-redundant definitions provided by 
sys/wait.h

* src/timeout.c (WIFSIGNALED, WTERMSIG): Remove definitions,
now that gnulib guarantees they are defined in <sys/wait.h>.
* src/operand2sig.c: Likewise.
* src/kill.c: Likewise.
---
 src/kill.c        |    7 -------
 src/operand2sig.c |    7 -------
 src/timeout.c     |    7 -------
 3 files changed, 0 insertions(+), 21 deletions(-)

diff --git a/src/kill.c b/src/kill.c
index 09d2808..4210c37 100644
--- a/src/kill.c
+++ b/src/kill.c
@@ -21,14 +21,7 @@
 #include <getopt.h>
 #include <sys/types.h>
 #include <signal.h>
-
 #include <sys/wait.h>
-#ifndef WIFSIGNALED
-# define WIFSIGNALED(s) (((s) & 0xFFFF) - 1 < (unsigned int) 0xFF)
-#endif
-#ifndef WTERMSIG
-# define WTERMSIG(s) ((s) & 0x7F)
-#endif

 #include "system.h"
 #include "error.h"
diff --git a/src/operand2sig.c b/src/operand2sig.c
index d0500cd..8c1e780 100644
--- a/src/operand2sig.c
+++ b/src/operand2sig.c
@@ -24,14 +24,7 @@
 #include <config.h>
 #include <stdio.h>
 #include <sys/types.h>
-
 #include <sys/wait.h>
-#ifndef WIFSIGNALED
-# define WIFSIGNALED(s) (((s) & 0xFFFF) - 1 < (unsigned int) 0xFF)
-#endif
-#ifndef WTERMSIG
-# define WTERMSIG(s) ((s) & 0x7F)
-#endif

 #include "system.h"
 #include "error.h"
diff --git a/src/timeout.c b/src/timeout.c
index c6f6525..e2234c3 100644
--- a/src/timeout.c
+++ b/src/timeout.c
@@ -51,13 +51,6 @@
 #include <signal.h>
 #include <sys/wait.h>

-#ifndef WIFSIGNALED
-# define WIFSIGNALED(s) (((s) & 0xFFFF) - 1 < (unsigned int) 0xFF)
-#endif
-#ifndef WTERMSIG
-# define WTERMSIG(s) ((s) & 0x7F)
-#endif
-
 #include "system.h"
 #include "xstrtol.h"
 #include "sig2str.h"
--
1.7.1.335.g6845a


>From c0e784b92338b26b28c0194b86ff59f23f37eb44 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 3 May 2010 10:50:23 +0200
Subject: [PATCH 2/3] maint: remove now-redundant definitions provided by 
signal.h

* src/dd.c (SA_NODEFER, SA_RESETHAND): Remove definitions,
now that gnulib guarantees they are defined in <signal.h>.
* src/ls.c (SA_RESTART): Likewise.
---
 src/dd.c |    6 ------
 src/ls.c |    3 ---
 2 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/src/dd.c b/src/dd.c
index 3f54cc7..1d8cfe0 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -57,12 +57,6 @@ static void process_signals (void);
 #  define siginterrupt(sig, flag) /* empty */
 # endif
 #endif
-#ifndef SA_NODEFER
-# define SA_NODEFER 0
-#endif
-#ifndef SA_RESETHAND
-# define SA_RESETHAND 0
-#endif

 #ifndef SIGINFO
 # define SIGINFO SIGUSR1
diff --git a/src/ls.c b/src/ls.c
index ca09ead..aa9fb6c 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -76,9 +76,6 @@
 #  define siginterrupt(sig, flag) /* empty */
 # endif
 #endif
-#ifndef SA_RESTART
-# define SA_RESTART 0
-#endif

 #include "system.h"
 #include <fnmatch.h>
--
1.7.1.335.g6845a


>From fb04dca6ae907b648b570c426f4a8d3ee122efec Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Mon, 3 May 2010 12:05:14 +0200
Subject: [PATCH 3/3] maint: extend the always_defined_macros syntax-check

* cfg.mk (gl_generated_headers_): Define.
(headers_with_interesting_macro_defs): Remove headers covered
by the above.
(.re-defmac): Extract symbol names from many more files.
(sc_always_defined_macros): Use VC_LIST_EXCEPT, not VC_LIST, so
that we can use the usual exception mechanism.
* .x-sc_always_defined_macros: New file.  Exempt src/seq.c.
* Makefile.am (syntax_check_exceptions): Add it here.
---
 .x-sc_always_defined_macros |    1 +
 Makefile.am                 |    1 +
 cfg.mk                      |   22 +++++++++++++---------
 3 files changed, 15 insertions(+), 9 deletions(-)
 create mode 100644 .x-sc_always_defined_macros

diff --git a/.x-sc_always_defined_macros b/.x-sc_always_defined_macros
new file mode 100644
index 0000000..8c96958
--- /dev/null
+++ b/.x-sc_always_defined_macros
@@ -0,0 +1 @@
+src/seq.c
diff --git a/Makefile.am b/Makefile.am
index 83c28b3..f1417a4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -41,6 +41,7 @@ changelog_etc =                               \

 syntax_check_exceptions =              \
   .x-sc_GPL_version                    \
+  .x-sc_always_defined_macros          \
   .x-sc_error_message_uppercase                \
   .x-sc_file_system                    \
   .x-sc_obsolete_symbols               \
diff --git a/cfg.mk b/cfg.mk
index 3983608..2eb7f3d 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -106,24 +106,28 @@ sc_x_sc_dist_check:
                   ) | sort | uniq -u)"                                 \
          && { echo 'Makefile.am: $(sce) mismatch' >&2; exit 1; } || :;

+gl_generated_headers_ = \
+  $$(cd $(gnulib_dir)/lib && echo *.in.h|sed 's,sys_,sys/,g;s/\.in\.h/.h/g')
+
 headers_with_interesting_macro_defs = \
   exit.h       \
-  fcntl_.h     \
-  fnmatch_.h   \
   intprops.h   \
-  inttypes_.h  \
   lchown.h     \
   openat.h     \
-  stat-macros.h        \
-  stdint_.h
+  stat-macros.h
+
+gl_extract_significant_defines_ = \
+  /^\# *define ([^_ (][^ (]*)\s*(\(|\w+)/ && $$2 !~ /(?:rpl_|_used_without_)/ \
+    and print $$1

 # Create a list of regular expressions matching the names
 # of macros that are guaranteed by parts of gnulib to be defined.
 .re-defmac:
-       @(cd $(srcdir)/lib;                                             \
-         for f in $(headers_with_interesting_macro_defs); do           \
+       @gen_h=$(gl_generated_headers_);                                \
+       (cd $(srcdir)/lib;                                              \
+         for f in $(headers_with_interesting_macro_defs) $$gen_h; do   \
            test -f $$f &&                                              \
-             sed -n '/^# *define \([^_ (][^ (]*\)[ (].*/s//\1/p' $$f;  \
+             perl -lne '$(gl_extract_significant_defines_)' $$f;       \
           done;                                                        \
         ) | sort -u                                                    \
           | grep -Ev 'ATTRIBUTE_NORETURN|SIZE_MAX'                     \
@@ -138,7 +142,7 @@ sc_always_defined_macros: .re-defmac
          am__exit='(exit $rc); exit $rc';                              \
          trap "rc=129; $$am__exit" 1; trap "rc=130; $$am__exit" 2;     \
          trap "rc=131; $$am__exit" 3; trap "rc=143; $$am__exit" 15;    \
-         grep -f .re-defmac $$($(VC_LIST))                             \
+         grep -f .re-defmac $$($(VC_LIST_EXCEPT))                      \
            && { echo '$(ME): define the above via some gnulib .h file' \
                  1>&2;  exit 1; } || :;                                \
        fi
--
1.7.1.335.g6845a







reply via email to

[Prev in Thread] Current Thread [Next in Thread]