selftests: ktap_helpers: Fix uninitialized variable
Subsystems (2)
PATCH 1/1 selftests: ktap_helpers: Fix uninitialized variable
__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 was discovered while developing tests for script control execution:
https://lore.kernel.org/r/[email protected]
--- tools/testing/selftests/kselftest/ktap_helpers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kselftest/ktap_helpers.sh +1 -1
@@ -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"
Signature · 1 line
2.47.1
Quoted 7 lines · Mickaël Salaün
__ktap_test()may be called without the optional third argument which is an issue for scripts usingset -uto detect uninitialized variables and potential bugs.Fix this optional "directive" argument by either using the third argument or an empty string.
Quoted 6 lines
This was discovered while developing tests for script control execution:
https://lore.kernel.org/r/[email protected]Cc Kees Cook <[email protected]>Cc Nícolas F. R. A. Prado <[email protected]>Cc Shuah Khan <[email protected]>
Please add this missing tag:
Quoted 22 lines
Signed-off-by Mickaël Salaün <[email protected]>--- tools/testing/selftests/kselftest/ktap_helpers.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/kselftest/ktap_helpers.sh +1
-1@@ -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"Signature · 1 line
2.47.1