* [PATCH v1] selftests: ktap_helpers: Fix uninitialized variable
@ 2024-11-27 16:03 Mickaël Salaün
2024-11-27 16:06 ` Mickaël Salaün
0 siblings, 1 reply; 2+ messages in thread
From: Mickaël Salaün @ 2024-11-27 16:03 UTC (permalink / raw)
To: Shuah Khan
Cc: Mickaël Salaün, linux-kselftest, linux-kernel,
linux-security-module, Kees Cook, Nícolas F. R. A. Prado
__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/20241112191858.162021-7-mic@digikod.net
Cc: Kees Cook <kees@kernel.org>
Cc: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Mickaël Salaün <mic@digikod.net>
---
tools/testing/selftests/kselftest/ktap_helpers.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kselftest/ktap_helpers.sh b/tools/testing/selftests/kselftest/ktap_helpers.sh
index 79a125eb24c2..14e7f3ec3f84 100644
--- a/tools/testing/selftests/kselftest/ktap_helpers.sh
+++ b/tools/testing/selftests/kselftest/ktap_helpers.sh
@@ -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"
--
2.47.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1] selftests: ktap_helpers: Fix uninitialized variable
2024-11-27 16:03 [PATCH v1] selftests: ktap_helpers: Fix uninitialized variable Mickaël Salaün
@ 2024-11-27 16:06 ` Mickaël Salaün
0 siblings, 0 replies; 2+ messages in thread
From: Mickaël Salaün @ 2024-11-27 16:06 UTC (permalink / raw)
To: Shuah Khan
Cc: linux-kselftest, linux-kernel, linux-security-module, Kees Cook,
Nícolas F. R. A. Prado
On Wed, Nov 27, 2024 at 05:03:40PM +0100, Mickaël Salaün wrote:
> __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/20241112191858.162021-7-mic@digikod.net
>
> Cc: Kees Cook <kees@kernel.org>
> Cc: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> Cc: Shuah Khan <skhan@linuxfoundation.org>
Please add this missing tag:
Fixes: 14571ab1ad21 ("kselftest: Add new test for detecting unprobed Devicetree devices")
> Signed-off-by: Mickaël Salaün <mic@digikod.net>
> ---
> tools/testing/selftests/kselftest/ktap_helpers.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/kselftest/ktap_helpers.sh b/tools/testing/selftests/kselftest/ktap_helpers.sh
> index 79a125eb24c2..14e7f3ec3f84 100644
> --- a/tools/testing/selftests/kselftest/ktap_helpers.sh
> +++ b/tools/testing/selftests/kselftest/ktap_helpers.sh
> @@ -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"
> --
> 2.47.1
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-11-27 16:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-27 16:03 [PATCH v1] selftests: ktap_helpers: Fix uninitialized variable Mickaël Salaün
2024-11-27 16:06 ` Mickaël Salaün
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).