I spotted an unnecessary inclusion of signal.h, and then wrote the code to add signal.h to the list of headers "make syntax-check" tells you about when they're included without a use.
Figuring out how to use $(subst with a space as an argument (aka how to set _sp to a space in a GNU makefile) was interesting. This would have done it, too, but seems more obtuse. _sp = _sp += >From 5be50ebb55ac284566dd0b15e26171edefe20929 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@redhat.com> Date: Tue, 24 Feb 2009 21:44:51 +0100 Subject: [PATCH 1/2] maint: remove an unnecessary inclusion of <signal.h> * src/operand2sig.c: Don't include <signal.h>. --- src/operand2sig.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) diff --git a/src/operand2sig.c b/src/operand2sig.c index 228db40..23f44bc 100644 --- a/src/operand2sig.c +++ b/src/operand2sig.c @@ -1,5 +1,5 @@ /* operand2sig.c -- common function for parsing signal specifications - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,7 +24,6 @@ #include <config.h> #include <stdio.h> #include <sys/types.h> -#include <signal.h> #if HAVE_SYS_WAIT_H # include <sys/wait.h> -- 1.6.2.rc1.285.gc5f54 >From 731c71dfe7da23b753f68309f56800e3f413f98a Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@redhat.com> Date: Tue, 24 Feb 2009 21:43:26 +0100 Subject: [PATCH 2/2] maint: detect unnecessary inclusion of signal.h * maint.mk (sc_prohibit_signal_without_use): New rule. --- maint.mk | 37 +++++++++++++++++++++++++++++++++++++ 1 files changed, 37 insertions(+), 0 deletions(-) diff --git a/maint.mk b/maint.mk index f1c1e8a..63b4c88 100644 --- a/maint.mk +++ b/maint.mk @@ -289,6 +289,43 @@ ctype_re = isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islower\ sc_prohibit_c_ctype_without_use: @h='[<"]c-ctype.h[">]' re='\<c_($(ctype_re)) *\(' $(_header_without_use) +_empty = +_sp = $(_empty) $(_empty) +# The following list was generated by running: +# man signal.h|col -b|perl -ne '/bsd_signal.*;/.../sigwaitinfo.*;/ and print' \ +# | perl -lne '/^\s+(?:int|void).*?(\w+).*/ and print $1' | fmt +_sig_functions = \ + bsd_signal kill killpg pthread_kill pthread_sigmask raise sigaction \ + sigaddset sigaltstack sigdelset sigemptyset sigfillset sighold sigignore \ + siginterrupt sigismember signal sigpause sigpending sigprocmask sigqueue \ + sigrelse sigset sigsuspend sigtimedwait sigwait sigwaitinfo +_sig_function_re = $(subst $(_sp),|,$(strip $(_sig_functions))) +# The following were extracted from "man signal.h" manually. +_sig_types_and_consts = \ + MINSIGSTKSZ SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK \ + SA_RESETHAND SA_RESTART SA_SIGINFO SIGEV_NONE SIGEV_SIGNAL \ + SIGEV_THREAD SIGSTKSZ SIG_BLOCK SIG_SETMASK SIG_UNBLOCK SS_DISABLE \ + SS_ONSTACK mcontext_t pid_t sig_atomic_t sigevent siginfo_t sigset_t \ + sigstack sigval stack_t ucontext_t +# generated via this: +# perl -lne '/^#ifdef (SIG\w+)/ and print $1' lib/sig2str.c|sort -u|fmt -70 +_sig_names = \ + SIGABRT SIGALRM SIGALRM1 SIGBUS SIGCANCEL SIGCHLD SIGCLD SIGCONT \ + SIGDANGER SIGDIL SIGEMT SIGFPE SIGFREEZE SIGGRANT SIGHUP SIGILL \ + SIGINFO SIGINT SIGIO SIGIOT SIGKAP SIGKILL SIGKILLTHR SIGLOST SIGLWP \ + SIGMIGRATE SIGMSG SIGPHONE SIGPIPE SIGPOLL SIGPRE SIGPROF SIGPWR \ + SIGQUIT SIGRETRACT SIGSAK SIGSEGV SIGSOUND SIGSTKFLT SIGSTOP SIGSYS \ + SIGTERM SIGTHAW SIGTRAP SIGTSTP SIGTTIN SIGTTOU SIGURG SIGUSR1 \ + SIGUSR2 SIGVIRT SIGVTALRM SIGWAITING SIGWINCH SIGWIND SIGWINDOW \ + SIGXCPU SIGXFSZ +_sig_syms_re = $(subst $(_sp),|,$(strip $(_sig_names) $(_sig_types_and_consts))) + +# Prohibit the inclusion of signal.h without an actual use. +sc_prohibit_signal_without_use: + @h='<signal.h>' \ + re='\<($(_sig_function_re)) *\(|\<($(_sig_syms_re))\>' \ + $(_header_without_use) + sc_obsolete_symbols: @re='\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \ msg='do not use HAVE''_FCNTL_H or O'_NDELAY \ -- 1.6.2.rc1.285.gc5f54 _______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils