I'm encountering a lot of exit(0)/exit(1) uses that trigger this new "syntax-check" rule, so I've taken the time to automate most of the clean-up process. The commands don't change usage(0)/usage(1), but those probably belong separate, since they won't be as numerous and you should verify that the usage function does indeed always call exit.
>From 00b2f10b68593189be4eb1affd88de33a8e92fb3 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyer...@redhat.com> Date: Fri, 20 Nov 2009 13:24:24 +0100 Subject: [PATCH] maint.mk: improve sc_prohibit_magic_number_exit * top/maint.mk (sc_prohibit_magic_number_exit): Tighten regexp so it does not match uses like System.exit(1). Add comments showing how to correct all offenders. --- ChangeLog | 7 +++++++ top/maint.mk | 11 ++++++++++- 2 files changed, 17 insertions(+), 1 deletions(-) diff --git a/ChangeLog b/ChangeLog index eacd8e0..51fe8ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-11-20 Jim Meyering <meyer...@redhat.com> + + maint.mk: improve sc_prohibit_magic_number_exit + * top/maint.mk (sc_prohibit_magic_number_exit): Tighten regexp + so it does not match uses like System.exit(1). + Add comments showing how to correct all offenders. + 2009-11-19 Eric Blake <e...@byu.net> xalloc-die-tests: add missing library diff --git a/top/maint.mk b/top/maint.mk index 34d66e1..3452a15 100644 --- a/top/maint.mk +++ b/top/maint.mk @@ -157,8 +157,17 @@ sc_prohibit_strcmp: 1>&2; exit 1; } || : # Pass EXIT_*, not number, to usage, exit, and error (when exiting) +# Convert all uses automatically, via these two commands: +# git grep -l '\<exit *(1)' \ +# | grep -vEf .x-sc_prohibit_magic_number_exit \ +# | xargs --no-run-if-empty \ +# perl -pi -e 's/(^|[^.])\b(exit ?)\(1\)/$1$2(EXIT_FAILURE)/' +# git grep -l '\<exit *(0)' \ +# | grep -vEf .x-sc_prohibit_magic_number_exit \ +# | xargs --no-run-if-empty \ +# perl -pi -e 's/(^|[^.])\b(exit ?)\(0\)/$1$2(EXIT_SUCCESS)/' sc_prohibit_magic_number_exit: - @re='\<(usage|exit) ?\([0-9]|\<error ?\([1-9][0-9]*,' \ + @re='(^|[^.])\<(usage|exit) ?\([0-9]|\<error ?\([1-9][0-9]*,' \ msg='use EXIT_* values rather than magic number' \ $(_prohibit_regexp) -- 1.6.5.3.433.g11067