From: Kevin Day Date: Thu, 10 Aug 2023 04:31:26 +0000 (-0500) Subject: Cleanup: Change structure of fll_execute_program() checks. X-Git-Tag: 0.6.7~11 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=f6725366474492f1b7baabba7938854f6e6412eb;p=fll 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. --- 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);