From patchwork Wed Nov 27 16:03:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= X-Patchwork-Id: 13887180 Received: from smtp-42ae.mail.infomaniak.ch (smtp-42ae.mail.infomaniak.ch [84.16.66.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A17DD200139 for ; Wed, 27 Nov 2024 16:03:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=84.16.66.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732723442; cv=none; b=mfzQkI9AQXW7zc4KM15kTg8vayDYrKJkDVq92k7zFaWF5fG2GkgaxzlJYOoBinz3aBumfRLyTPKYqypdBto+UTYtyxLl1KgVHl4qR+2c9B0GzmUy+EOkUDrsvgJGLUraC6vaXtE3sWHJKivG/vVlYRLM7YX0Xv/zF0eYVZo8x1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732723442; c=relaxed/simple; bh=hBFtJ6s2jOqV2rXG7eIIWHv7Ge6GEyLU7TIqXyReM9U=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=h7jf/looIoN3Vpnsojday8PelnnOrYk/L+FTv7pOXRzwylG5BIbY87lpPPv4+kx8nvdRiyEXamCeUirl2i9RLpRBLl37nP6WyxA6vpwMeEAqpQisHkjXka3LgnRjZSQ5Ddk/sWwlV7MlcnjdAoFVUa7khsmt9FTzpS6raFlu3Ck= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net; spf=pass smtp.mailfrom=digikod.net; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b=kYHq6Ita; arc=none smtp.client-ip=84.16.66.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=digikod.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="kYHq6Ita" Received: from smtp-3-0001.mail.infomaniak.ch (unknown [IPv6:2001:1600:4:17::246c]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4Xz44Q6W3vzN2L; Wed, 27 Nov 2024 17:03:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=digikod.net; s=20191114; t=1732723430; bh=W6hzVPG//NzKaEDwe3OCRcoZxhvanii6b6apGJF7EoA=; h=From:To:Cc:Subject:Date:From; b=kYHq6Itaao1g8uVRz9HxfhYc7KPh2gVv4htwOEF1q2dqx9roDEaGCViGJ42M+R+3o 9r5kftxFTCuIjLHEd7BwE+wuzHLAUVuFmH8zxA+VJ/B2KMb65k7igSb4G7nDC8O+fw aM3kvkypLHVRYjE2ojzwqm1cTynpiW2zUAFsq75s= Received: from unknown by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4Xz44Q0jPdzwFB; Wed, 27 Nov 2024 17:03:49 +0100 (CET) From: =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= To: Shuah Khan Cc: =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Kees Cook , =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= Subject: [PATCH v1] selftests: ktap_helpers: Fix uninitialized variable Date: Wed, 27 Nov 2024 17:03:40 +0100 Message-ID: <20241127160342.31472-1-mic@digikod.net> Precedence: bulk X-Mailing-List: linux-security-module@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Infomaniak-Routing: alpha __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 Cc: Nícolas F. R. A. Prado Cc: Shuah Khan Signed-off-by: Mickaël Salaün --- 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"