Skip to content

Commit

Permalink
selftests: ktap_helpers: Fix uninitialized variable
Browse files Browse the repository at this point in the history
__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: 14571ab ("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>
  • Loading branch information
Mickaël Salaün authored and Kees Cook committed Dec 19, 2024
1 parent faf2d88 commit 3e707b0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/testing/selftests/kselftest/ktap_helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 3e707b0

Please sign in to comment.