From 5118d1be2ade514079f5506bafdf028389ff362e Mon Sep 17 00:00:00 2001 From: Ruediger Meier Date: Mon, 19 Jun 2017 20:51:50 +0200 Subject: misc: never use usage(ERROR) We are using better/shorter error messages and somtimes also errtryhelp(). Here we fix all cases where the usage function took an int argument for exit_code. Signed-off-by: Ruediger Meier --- sys-utils/ldattach.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'sys-utils/ldattach.c') diff --git a/sys-utils/ldattach.c b/sys-utils/ldattach.c index 5d6dc0ba0..9a3915b1c 100644 --- a/sys-utils/ldattach.c +++ b/sys-utils/ldattach.c @@ -188,9 +188,9 @@ static int parse_iflag(char *str, int *set_iflag, int *clr_iflag) } -static void __attribute__ ((__noreturn__)) usage(int exitcode) +static void __attribute__((__noreturn__)) usage(void) { - FILE *out = exitcode == EXIT_SUCCESS ? stdout : stderr; + FILE *out = stdout; fputs(USAGE_HEADER, out); fprintf(out, _(" %s [options] \n"), program_invocation_short_name); @@ -224,7 +224,7 @@ static void __attribute__ ((__noreturn__)) usage(int exitcode) print_table(out, ld_iflags); fprintf(out, USAGE_MAN_TAIL("ldattach(8)")); - exit(exitcode); + exit(EXIT_SUCCESS); } static int my_cfsetspeed(struct termios *ts, int speed) @@ -315,7 +315,8 @@ int main(int argc, char **argv) /* parse options */ if (argc == 0) - usage(EXIT_SUCCESS); + errx(EXIT_FAILURE, _("bad usage")); + while ((optc = getopt_long(argc, argv, "dhV78neo12s:i:c:p:", opttbl, NULL)) >= 0) { @@ -354,15 +355,16 @@ int main(int argc, char **argv) printf(UTIL_LINUX_VERSION); return EXIT_SUCCESS; case 'h': - usage(EXIT_SUCCESS); + usage(); default: errtryhelp(EXIT_FAILURE); } } - if (argc - optind != 2) - usage(EXIT_FAILURE); - + if (argc - optind != 2) { + warnx(_("not enough arguments")); + errtryhelp(EXIT_FAILURE); + } /* parse line discipline specification */ ldisc = lookup_table(ld_discs, argv[optind]); if (ldisc < 0) -- cgit v1.2.3-55-g7522