From 8b822a84c444f074d493bb3314c741a9bb03134c Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 26 Mar 2021 08:37:30 +1000 Subject: [PATCH] tools/record: de-duplicate an error message Signed-off-by: Peter Hutterer --- tools/libinput-record.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/tools/libinput-record.c b/tools/libinput-record.c index f493e784..1566b10e 100644 --- a/tools/libinput-record.c +++ b/tools/libinput-record.c @@ -2782,17 +2782,17 @@ main(int argc, char **argv) ctx.outfile = safe_strdup(output_arg); + if (output_arg == NULL && (all || ndevices > 1)) { + fprintf(stderr, + "Recording multiple devices requires an output file\n"); + rc = EXIT_INVALID_USAGE; + goto out; + } + if (all) { char **devices; /* NULL-terminated */ char **d; - if (output_arg == NULL) { - fprintf(stderr, - "Option --all requires an output file\n"); - rc = EXIT_INVALID_USAGE; - goto out; - } - devices = all_devices(); d = devices; @@ -2806,13 +2806,6 @@ main(int argc, char **argv) strv_free(devices); } else if (ndevices > 1) { - if (ndevices > 1 && output_arg == NULL) { - fprintf(stderr, - "Recording multiple devices requires an output file\n"); - rc = EXIT_INVALID_USAGE; - goto out; - } - for (int i = ndevices; i > 0; i -= 1) { char *devnode = safe_strdup(argv[optind + i - 1]);