From d31725f07708908ced7a71ea53a4d8a3e6bbb4b6 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Thu, 25 Nov 2021 21:48:05 +0100 Subject: [PATCH] Reorder cli sanity checks Check unexpected additional arguments before other sanity checks. --- app/src/cli.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/cli.c b/app/src/cli.c index 7da3b904..791d3c43 100644 --- a/app/src/cli.c +++ b/app/src/cli.c @@ -1394,6 +1394,12 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[], } } + int index = optind; + if (index < argc) { + LOGE("Unexpected additional argument: %s", argv[index]); + return false; + } + #ifdef HAVE_V4L2 if (!opts->display && !opts->record_filename && !opts->v4l2_device) { LOGE("-N/--no-display requires either screen recording (-r/--record)" @@ -1425,12 +1431,6 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[], opts->force_adb_forward = true; } - int index = optind; - if (index < argc) { - LOGE("Unexpected additional argument: %s", argv[index]); - return false; - } - if (opts->record_format && !opts->record_filename) { LOGE("Record format specified without recording"); return false;