summaryrefslogtreecommitdiff
path: root/libs/ardouralsautil
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2019-08-15 01:07:41 +0200
committerRobin Gareus <robin@gareus.org>2019-08-15 01:09:26 +0200
commit316880b9cf9eca5b2607458d123a0b9dbf0fee69 (patch)
treed146fdaf4b5b342810631e15102f47b1a415d472 /libs/ardouralsautil
parent4aedf9c3ea03b40a2166bbff4d9561d05c5b6d31 (diff)
Don't print usage to stdout for invalid parameters
Diffstat (limited to 'libs/ardouralsautil')
-rw-r--r--libs/ardouralsautil/request_device.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/libs/ardouralsautil/request_device.c b/libs/ardouralsautil/request_device.c
index 4166e74d22..94bbbd63ec 100644
--- a/libs/ardouralsautil/request_device.c
+++ b/libs/ardouralsautil/request_device.c
@@ -56,17 +56,17 @@ static int stdin_available(void) {
return errno != EBADF;
}
-static void print_version(int status) {
+static void print_version () {
printf (ARD_PROG_NAME " " VERSION "\n\n");
printf (
"Copyright (C) 2014 Robin Gareus <robin@gareus.org>\n"
"This is free software; see the source for copying conditions. There is NO\n"
"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
);
- exit (status);
+ exit (EXIT_SUCCESS);
}
-static void usage(int status) {
+static void usage () {
printf (ARD_PROG_NAME " - DBus Audio Reservation Utility.\n");
printf ("Usage: " ARD_PROG_NAME " [ OPTIONS ] <Audio-Device-ID>\n");
printf ("Options:\n\
@@ -103,7 +103,7 @@ Examples:\n\
\n");
printf ("Report bugs to Robin Gareus <robin@gareus.org>\n");
- exit (status);
+ exit (EXIT_SUCCESS);
}
static struct option const long_options[] =
@@ -163,7 +163,7 @@ int main(int argc, char **argv) {
switch (c) {
case 'h':
free(name);
- usage(EXIT_SUCCESS);
+ usage ();
break;
case 'n':
free(name);
@@ -178,21 +178,23 @@ int main(int argc, char **argv) {
break;
case 'V':
free(name);
- print_version(EXIT_SUCCESS);
+ print_version ();
break;
case 'w':
release_wait_for_signal = 1;
break;
default:
free(name);
- usage(EXIT_FAILURE);
+ fprintf (stderr, "Error: unrecognized option. See --help for usage information.\n");
+ exit (EXIT_FAILURE);
break;
}
}
if (optind + 1 != argc) {
+ fprintf (stderr, "Error: Missing parameter. See --help for usage information.\n");
free(name);
- usage(EXIT_FAILURE);
+ return EXIT_FAILURE;
}
const char *device_name = argv[optind];