bug-coreutils
[Top][All Lists]
Advanced

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

Re: maint: avoid usage(1)


From: Jim Meyering
Subject: Re: maint: avoid usage(1)
Date: Thu, 29 Oct 2009 13:50:44 +0100

Eric Blake wrote:
> I noticed this during my audit for stderr vs. exec.  We've made previous
> cleanups along these lines, but usages have crept back in.  OK to commit?
...
> Subject: [PATCH] maint: avoid exiting with magic number
>
> * cfg.mk (sc_prohibit_magic_number_exit)
> (sc_prohibit_error_success): New rules.
> * .x-sc_prohibit_magic_number_exit: Add exemptions.
> * Makefile.am (syntax_check_exceptions): Distribute it.
> * lib/euidaccess-stat.c (main): Fix culprits.
> * src/chcon.c (main): Likewise.
> * src/runcon.c (main): Likewise.
> * src/setuidgid.c (main): Likewise.

Nice!

...
> diff --git a/cfg.mk b/cfg.mk
> index 1e5108b..cce945a 100644
> --- a/cfg.mk
> +++ b/cfg.mk
> @@ -203,6 +203,18 @@ sc_prohibit_stat_macro_address:
>       msg='stat() and lstat() may be function-like macros'            \
>         $(_prohibit_regexp)
>
> +# Pass EXIT_*, not number, to usage, exit, and error
> +sc_prohibit_magic_number_exit:
> +     @re='\<(usage|exit) \([0-9]|\<error \([1-9][0-9]*,'             \

Please allow 0 or one space between the function name
and the opening parenthesis, so this rule will also be useful
to projects with different code formatting conventions.

> +     msg='use EXIT_* values rather than magic number'                \
> +       $(_prohibit_regexp)
> +
> +# error (0) is preferred over error (EXIT_SUCCESS), since it does not exit
> +sc_prohibit_error_success:
> +     @re='\<error \(EXIT_SUCCESS,'                                   \

same here

> +     msg='use error(0) rather than error(EXIT_SUCCESS)'              \

which means you'll want to obfuscate the above, e.g., to

        msg='use error''(0) rather than error(EXIT_SUCCESS)'            \

These seem generally useful enough for gnulib's maint.mk.




reply via email to

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