From f6725366474492f1b7baabba7938854f6e6412eb Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 9 Aug 2023 23:31:26 -0500 Subject: [PATCH] Cleanup: Change structure of fll_execute_program() checks. This is a follow up to the commit 1b43ceefc20836137ed95e19d275dda44d8a678d. The previous commit is passing NULL to strrchr(). This should be fine, but does produce a warning. Clean up the code and play it safe by changing the design to only call strrchr() when the value passed would be non-NULL. --- level_2/fll_execute/c/execute.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/level_2/fll_execute/c/execute.c b/level_2/fll_execute/c/execute.c index b202acb..759fb9a 100644 --- a/level_2/fll_execute/c/execute.c +++ b/level_2/fll_execute/c/execute.c @@ -278,15 +278,11 @@ extern "C" { f_string_t fixed_arguments[arguments.used + 2]; f_string_static_t program_name = f_string_static_t_initialize; - const f_string_t last_slash = (f_string_t) strrchr( - (program.used - ? program.string - : arguments.used && arguments.array[0].used - ? arguments.array[0].string - : 0 - ), - (char) f_path_separator_s.string[0] - ); + const f_string_t last_slash = program.used + ? (f_string_t) strrchr(program.string, (char) f_path_separator_s.string[0]) + : arguments.used && arguments.array[0].used + ? (f_string_t) strrchr(arguments.array[0].string, (char) f_path_separator_s.string[0]) + : 0; if (last_slash) { program_name.used = strnlen((last_slash + 1), F_path_length_max_d); -- 1.8.3.1