From ca516f4318100e93d8fa4a88e05f004bafd1dc91 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Mon, 24 Jan 2022 21:44:28 +0100 Subject: [PATCH] Refactor if-block in cli Several tests must be performed if opts->control is false. --- app/src/cli.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/cli.c b/app/src/cli.c index 21d13b44..57e02df8 100644 --- a/app/src/cli.c +++ b/app/src/cli.c @@ -1591,14 +1591,15 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[], } } - if (!opts->control && opts->turn_screen_off) { - LOGE("Could not request to turn screen off if control is disabled"); - return false; - } - - if (!opts->control && opts->stay_awake) { - LOGE("Could not request to stay awake if control is disabled"); - return false; + if (!opts->control) { + if (opts->turn_screen_off) { + LOGE("Could not request to turn screen off if control is disabled"); + return false; + } + if (opts->stay_awake) { + LOGE("Could not request to stay awake if control is disabled"); + return false; + } } return true;