From 6e1eda6f229f87b77471ce6eb7cbf0ede7c8029e Mon Sep 17 00:00:00 2001 From: Ruediger Meier Date: Mon, 19 Jun 2017 20:52:50 +0200 Subject: misc: never use usage(stderr) Here we fix all cases where we have usage(FILE*) functions. Signed-off-by: Ruediger Meier --- login-utils/chfn.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'login-utils/chfn.c') diff --git a/login-utils/chfn.c b/login-utils/chfn.c index 3a951a193..7a57e9169 100644 --- a/login-utils/chfn.c +++ b/login-utils/chfn.c @@ -89,8 +89,9 @@ struct chfn_control { /* we do not accept gecos field sizes longer than MAX_FIELD_SIZE */ #define MAX_FIELD_SIZE 256 -static void __attribute__((__noreturn__)) usage(FILE *fp) +static void __attribute__((__noreturn__)) usage(void) { + FILE *fp = stdout; fputs(USAGE_HEADER, fp); fprintf(fp, _(" %s [options] []\n"), program_invocation_short_name); @@ -106,7 +107,7 @@ static void __attribute__((__noreturn__)) usage(FILE *fp) fputs(_(" -u, --help display this help and exit\n"), fp); fputs(_(" -v, --version output version information and exit\n"), fp); fprintf(fp, USAGE_MAN_TAIL("chfn(1)")); - exit(fp == stderr ? EXIT_FAILURE : EXIT_SUCCESS); + exit(EXIT_SUCCESS); } /* @@ -178,7 +179,7 @@ static void parse_argv(struct chfn_control *ctl, int argc, char **argv) printf(UTIL_LINUX_VERSION); exit(EXIT_SUCCESS); case 'u': - usage(stdout); + usage(); default: errtryhelp(EXIT_FAILURE); } @@ -189,8 +190,10 @@ static void parse_argv(struct chfn_control *ctl, int argc, char **argv) exit(EXIT_FAILURE); /* done parsing arguments. check for a username. */ if (optind < argc) { - if (optind + 1 < argc) - usage(stderr); + if (optind + 1 < argc) { + warnx(_("cannot handle multiple usernames")); + errtryhelp(EXIT_FAILURE); + } ctl->username = argv[optind]; } return; -- cgit v1.2.3-55-g7522