]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests: ktap_helpers: Fix uninitialized variable
authorMickaël Salaün <mic@digikod.net>
Thu, 12 Dec 2024 17:42:21 +0000 (18:42 +0100)
committerKees Cook <kees@kernel.org>
Thu, 19 Dec 2024 01:00:29 +0000 (17:00 -0800)
__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 <kees@kernel.org>
Cc: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Fixes: 14571ab1ad21 ("kselftest: Add new test for detecting unprobed Devicetree devices")
Signed-off-by: Mickaël Salaün <mic@digikod.net>
Link: https://lore.kernel.org/r/20241212174223.389435-7-mic@digikod.net
Signed-off-by: Kees Cook <kees@kernel.org>
tools/testing/selftests/kselftest/ktap_helpers.sh

index 79a125eb24c2e8a0539a367a05f46d996d9164f0..14e7f3ec3f84c3026ffa14e79a0661fd3332263b 100644 (file)
@@ -40,7 +40,7 @@ ktap_skip_all() {
 __ktap_test() {
        result="$1"
        description="$2"
-       directive="$3" # optional
+       directive="${3:-}" # optional
 
        local directive_str=
        [ ! -z "$directive" ] && directive_str="# $directive"