From c6abc5f63b1d4c612146b0371393c6269f89b19a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= Date: Thu, 12 Dec 2024 18:42:21 +0100 Subject: [PATCH] selftests: ktap_helpers: Fix uninitialized variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BugLink: https://bugs.launchpad.net/bugs/2111953 [ Upstream commit 3e707b07f582c12ed78fa5516a97bf701bf0634c ] __ktap_test() may be called without the optional third argument which is an issue for scripts using `set -u` to detect uninitialized variables and potential bugs. Fix this optional "directive" argument by either using the third argument or an empty string. This is required for the next commit to properly test script execution control. Cc: Kees Cook Cc: Nícolas F. R. A. Prado Cc: Shuah Khan Fixes: 14571ab1ad21 ("kselftest: Add new test for detecting unprobed Devicetree devices") Signed-off-by: Mickaël Salaün Link: https://lore.kernel.org/r/20241212174223.389435-7-mic@digikod.net Signed-off-by: Kees Cook Signed-off-by: Sasha Levin Signed-off-by: Manuel Diewald Signed-off-by: Mehmet Basaran --- tools/testing/selftests/dt/ktap_helpers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/dt/ktap_helpers.sh b/tools/testing/selftests/dt/ktap_helpers.sh index 8dfae51bb4e2..9faa892a8845 100644 --- a/tools/testing/selftests/dt/ktap_helpers.sh +++ b/tools/testing/selftests/dt/ktap_helpers.sh @@ -27,7 +27,7 @@ ktap_skip_all() { __ktap_test() { result="$1" description="$2" - directive="$3" # optional + directive="${3:-}" # optional local directive_str= [[ ! -z "$directive" ]] && directive_str="# $directive"