summaryrefslogtreecommitdiffstats
path: root/login-utils
diff options
context:
space:
mode:
Diffstat (limited to 'login-utils')
-rw-r--r--login-utils/chfn.c13
-rw-r--r--login-utils/chsh.c12
2 files changed, 15 insertions, 10 deletions
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] [<username>]\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;
diff --git a/login-utils/chsh.c b/login-utils/chsh.c
index 10b0bdcda..1083583b9 100644
--- a/login-utils/chsh.c
+++ b/login-utils/chsh.c
@@ -70,8 +70,9 @@ struct sinfo {
/* global due readline completion */
static char **global_shells;
-static void __attribute__((__noreturn__)) usage (FILE *fp)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *fp = stdout;
fputs(USAGE_HEADER, fp);
fprintf(fp, _(" %s [options] [<username>]\n"), program_invocation_short_name);
@@ -85,7 +86,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("chsh(1)"));
- exit(fp == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
/*
@@ -229,7 +230,7 @@ static void parse_argv(int argc, char **argv, struct sinfo *pinfo)
exit(EXIT_SUCCESS);
case 'u': /* deprecated */
case 'h':
- usage(stdout);
+ usage();
case 'l':
init_shells();
print_shells();
@@ -243,8 +244,9 @@ static void parse_argv(int argc, char **argv, struct sinfo *pinfo)
}
/* done parsing arguments. check for a username. */
if (optind < argc) {
- if (optind + 1 < argc)
- usage(stderr);
+ if (optind + 1 < argc) {
+ errx(EXIT_FAILURE, _("cannot handle multiple usernames"));
+ }
pinfo->username = argv[optind];
}
}