summaryrefslogtreecommitdiffstats
path: root/sys-utils/tunelp.c
diff options
context:
space:
mode:
authorRuediger Meier2017-06-19 20:52:50 +0200
committerRuediger Meier2017-06-26 14:38:24 +0200
commit6e1eda6f229f87b77471ce6eb7cbf0ede7c8029e (patch)
tree5e74a0cd99493e934780db2b434c75e995a6bd17 /sys-utils/tunelp.c
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 'sys-utils/tunelp.c')
-rw-r--r--sys-utils/tunelp.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/sys-utils/tunelp.c b/sys-utils/tunelp.c
index 2749dd1c8..99da3f3f6 100644
--- a/sys-utils/tunelp.c
+++ b/sys-utils/tunelp.c
@@ -87,8 +87,9 @@ struct command {
struct command *next;
};
-static void __attribute__((__noreturn__)) print_usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] <device>\n"), program_invocation_short_name);
@@ -115,7 +116,7 @@ static void __attribute__((__noreturn__)) print_usage(FILE *out)
fputs(USAGE_VERSION, out);
fprintf(out, USAGE_MAN_TAIL("tunelp(8)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
@@ -148,8 +149,10 @@ int main(int argc, char **argv)
strutils_set_exitcode(EXIT_LP_BADVAL);
- if (argc < 2)
- print_usage(stderr);
+ if (argc < 2) {
+ warnx(_("not enough arguments"));
+ errtryhelp(EXIT_FAILURE);
+ }
cmdst = cmds = xmalloc(sizeof(struct command));
cmds->next = NULL;
@@ -158,7 +161,7 @@ int main(int argc, char **argv)
while ((c = getopt_long(argc, argv, "t:c:w:a:i:ho:C:sq:rT:vV", longopts, NULL)) != -1) {
switch (c) {
case 'h':
- print_usage(stdout);
+ usage();
break;
case 'i':
cmds->op = LPSETIRQ;
@@ -246,8 +249,10 @@ int main(int argc, char **argv)
}
}
- if (optind != argc - 1)
- print_usage(stderr);
+ if (optind != argc - 1) {
+ warnx(_("no device specified"));
+ errtryhelp(EXIT_FAILURE);
+ }
filename = xstrdup(argv[optind]);
fd = open(filename, O_WRONLY | O_NONBLOCK, 0);
@@ -263,7 +268,7 @@ int main(int argc, char **argv)
if (!S_ISCHR(statbuf.st_mode)) {
warnx(_("%s not an lp device"), filename);
- print_usage(stderr);
+ errtryhelp(EXIT_FAILURE);
}
/* Allow for binaries compiled under a new kernel to work on
* the old ones The irq argument to ioctl isn't touched by