Re: [PATCH 1/3] more: fix to exit codes and compiler warnings

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

 



On Sun, Jan 30, 2011 at 08:38:24PM +0100, Sami Kerola wrote:
> +usage() {
>  	fprintf(stderr,
>  		_("usage: %s [-dflpcsu] [+linenum | +/pattern] name1 name2 ...\n"),
> -		p ? p + 1 : s);
> +		program_invocation_short_name);
>  }

 It seems that usage() is always followed by exit(), so we can use 

    static void __attribute__((__noreturn__)) usage(void)

 and call exit() from the function.

[...]

>  	while (*s != '\0') {
> @@ -490,9 +519,9 @@ void argscan(char *s, char *argv0) {
>  			break;
>  		  default:
>  			fprintf(stderr,
> -				_("%s: unknown option \"-%c\"\n"), argv0, *s);
> -			usage(argv0);
> -			exit(1);
> +				_("%s: unknown option \"-%c\"\n"), program_invocation_short_name, *s);

    warnx(_("unknown option \"-%c\"));

> +			usage();
> +			exit(EXIT_FAILURE);
>  			break;

[...]

>  void onquit(int dummy) {

 void onquit(dummy __attribute__ ((__unused__)))

> +    /* to get rid of compiler warning 'unused parameter' */
> +    dummy = dummy;

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux