summaryrefslogtreecommitdiffstats
path: root/schedutils
diff options
context:
space:
mode:
authorRuediger Meier2017-06-19 20:52:50 +0200
committerRuediger Meier2017-06-26 14:38:24 +0200
commit6e1eda6f229f87b77471ce6eb7cbf0ede7c8029e (patch)
tree5e74a0cd99493e934780db2b434c75e995a6bd17 /schedutils
parentmisc: never use usage(ERROR) (diff)
downloadkernel-qcow2-util-linux-6e1eda6f229f87b77471ce6eb7cbf0ede7c8029e.tar.gz
kernel-qcow2-util-linux-6e1eda6f229f87b77471ce6eb7cbf0ede7c8029e.tar.xz
kernel-qcow2-util-linux-6e1eda6f229f87b77471ce6eb7cbf0ede7c8029e.zip
misc: never use usage(stderr)
Here we fix all cases where we have usage(FILE*) functions. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Diffstat (limited to 'schedutils')
-rw-r--r--schedutils/ionice.c14
-rw-r--r--schedutils/taskset.c13
2 files changed, 16 insertions, 11 deletions
diff --git a/schedutils/ionice.c b/schedutils/ionice.c
index 1cbde8faa..9d0648bca 100644
--- a/schedutils/ionice.c
+++ b/schedutils/ionice.c
@@ -98,8 +98,9 @@ static void ioprio_setid(int which, int ioclass, int data, int who)
err(EXIT_FAILURE, _("ioprio_set failed"));
}
-static void __attribute__ ((__noreturn__)) usage(FILE * out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %1$s [options] -p <pid>...\n"
" %1$s [options] -P <pgid>...\n"
@@ -125,7 +126,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out)
fprintf(out, USAGE_MAN_TAIL("ionice(1)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
@@ -201,7 +202,7 @@ int main(int argc, char **argv)
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
case 'h':
- usage(stdout);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
@@ -258,9 +259,10 @@ int main(int argc, char **argv)
ioprio_setid(0, ioclass, data, IOPRIO_WHO_PROCESS);
execvp(argv[optind], &argv[optind]);
err(EXIT_FAILURE, _("failed to execute %s"), argv[optind]);
- } else
- usage(stderr);
-
+ } else {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
return EXIT_SUCCESS;
}
diff --git a/schedutils/taskset.c b/schedutils/taskset.c
index b117b1c85..9870040e7 100644
--- a/schedutils/taskset.c
+++ b/schedutils/taskset.c
@@ -45,8 +45,9 @@ struct taskset {
get_only:1; /* print the mask, but not modify */
};
-static void __attribute__((__noreturn__)) usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fprintf(out,
_("Usage: %s [options] [mask | cpu-list] [pid|cmd [args...]]\n\n"),
program_invocation_short_name);
@@ -78,7 +79,7 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
fprintf(out, USAGE_MAN_TAIL("taskset(1)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
static void print_affinity(struct taskset *ts, int isnew)
@@ -176,7 +177,7 @@ int main(int argc, char **argv)
printf(UTIL_LINUX_VERSION);
return EXIT_SUCCESS;
case 'h':
- usage(stdout);
+ usage();
break;
default:
errtryhelp(EXIT_FAILURE);
@@ -184,8 +185,10 @@ int main(int argc, char **argv)
}
if ((!pid && argc - optind < 2)
- || (pid && (argc - optind < 1 || argc - optind > 2)))
- usage(stderr);
+ || (pid && (argc - optind < 1 || argc - optind > 2))) {
+ warnx(_("bad usage"));
+ errtryhelp(EXIT_FAILURE);
+ }
ncpus = get_max_number_of_cpus();
if (ncpus <= 0)