summaryrefslogtreecommitdiffstats
path: root/schedutils
diff options
context:
space:
mode:
authorRuediger Meier2017-06-19 20:51:50 +0200
committerRuediger Meier2017-06-26 14:38:24 +0200
commit5118d1be2ade514079f5506bafdf028389ff362e (patch)
tree4c84d14033e431dff9ade15678136ae8b6f4b4ef /schedutils
parentmisc: cleanup and fix --unknownopt issues (diff)
downloadkernel-qcow2-util-linux-5118d1be2ade514079f5506bafdf028389ff362e.tar.gz
kernel-qcow2-util-linux-5118d1be2ade514079f5506bafdf028389ff362e.tar.xz
kernel-qcow2-util-linux-5118d1be2ade514079f5506bafdf028389ff362e.zip
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 <ruediger.meier@ga-group.nl>
Diffstat (limited to 'schedutils')
-rw-r--r--schedutils/chrt.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/schedutils/chrt.c b/schedutils/chrt.c
index b52aec137..d1abbe14e 100644
--- a/schedutils/chrt.c
+++ b/schedutils/chrt.c
@@ -128,9 +128,9 @@ struct chrt_ctl {
verbose : 1; /* verbose output */
};
-static void __attribute__((__noreturn__)) show_usage(int rc)
+static void __attribute__((__noreturn__)) usage(void)
{
- FILE *out = rc == EXIT_SUCCESS ? stdout : stderr;
+ FILE *out = stdout;
fputs(_("Show or change the real-time scheduling attributes of a process.\n"), out);
fputs(USAGE_SEPARATOR, out);
@@ -169,7 +169,7 @@ static void __attribute__((__noreturn__)) show_usage(int rc)
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("chrt(1)"));
- exit(rc);
+ exit(EXIT_SUCCESS);
}
static const char *get_policy_name(int policy)
@@ -494,15 +494,17 @@ int main(int argc, char **argv)
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
case 'h':
- show_usage(EXIT_SUCCESS);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
}
if (((ctl->pid > -1) && argc - optind < 1) ||
- ((ctl->pid == -1) && argc - optind < 2))
- show_usage(EXIT_FAILURE);
+ ((ctl->pid == -1) && argc - optind < 2)) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+}
if ((ctl->pid > -1) && (ctl->verbose || argc - optind == 1)) {
show_sched_info(ctl);