linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests: tpm2: Fix ill defined assertions
@ 2025-11-23 11:18 Maurice Hieronymus
  2025-11-25 15:36 ` Jarkko Sakkinen
  0 siblings, 1 reply; 2+ messages in thread
From: Maurice Hieronymus @ 2025-11-23 11:18 UTC (permalink / raw)
  To: peterhuewe, jarkko
  Cc: linux-integrity, linux-kselftest, linux-kernel,
	Maurice Hieronymus

Remove parentheses around assert statements in Python. With parentheses,
assert always evaluates to True, making the checks ineffective.

Signed-off-by: Maurice Hieronymus <mhi@mailbox.org>
---
 tools/testing/selftests/tpm2/tpm2.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/tpm2/tpm2.py b/tools/testing/selftests/tpm2/tpm2.py
index bba8cb54548e..3d130c30bc7c 100644
--- a/tools/testing/selftests/tpm2/tpm2.py
+++ b/tools/testing/selftests/tpm2/tpm2.py
@@ -437,7 +437,7 @@ class Client:
 
     def extend_pcr(self, i, dig, bank_alg = TPM2_ALG_SHA1):
         ds = get_digest_size(bank_alg)
-        assert(ds == len(dig))
+        assert ds == len(dig)
 
         auth_cmd = AuthCommand()
 
@@ -589,7 +589,7 @@ class Client:
     def seal(self, parent_key, data, auth_value, policy_dig,
              name_alg = TPM2_ALG_SHA1):
         ds = get_digest_size(name_alg)
-        assert(not policy_dig or ds == len(policy_dig))
+        assert not policy_dig or ds == len(policy_dig)
 
         attributes = 0
         if not policy_dig:

base-commit: 821e6e2a328bb907d40f8d1141d8b6c079aa7340
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] selftests: tpm2: Fix ill defined assertions
  2025-11-23 11:18 [PATCH] selftests: tpm2: Fix ill defined assertions Maurice Hieronymus
@ 2025-11-25 15:36 ` Jarkko Sakkinen
  0 siblings, 0 replies; 2+ messages in thread
From: Jarkko Sakkinen @ 2025-11-25 15:36 UTC (permalink / raw)
  To: Maurice Hieronymus
  Cc: peterhuewe, linux-integrity, linux-kselftest, linux-kernel

On Sun, Nov 23, 2025 at 12:18:09PM +0100, Maurice Hieronymus wrote:
> Remove parentheses around assert statements in Python. With parentheses,
> assert always evaluates to True, making the checks ineffective.
> 
> Signed-off-by: Maurice Hieronymus <mhi@mailbox.org>
> ---
>  tools/testing/selftests/tpm2/tpm2.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/tpm2/tpm2.py b/tools/testing/selftests/tpm2/tpm2.py
> index bba8cb54548e..3d130c30bc7c 100644
> --- a/tools/testing/selftests/tpm2/tpm2.py
> +++ b/tools/testing/selftests/tpm2/tpm2.py
> @@ -437,7 +437,7 @@ class Client:
>  
>      def extend_pcr(self, i, dig, bank_alg = TPM2_ALG_SHA1):
>          ds = get_digest_size(bank_alg)
> -        assert(ds == len(dig))
> +        assert ds == len(dig)
>  
>          auth_cmd = AuthCommand()
>  
> @@ -589,7 +589,7 @@ class Client:
>      def seal(self, parent_key, data, auth_value, policy_dig,
>               name_alg = TPM2_ALG_SHA1):
>          ds = get_digest_size(name_alg)
> -        assert(not policy_dig or ds == len(policy_dig))
> +        assert not policy_dig or ds == len(policy_dig)
>  
>          attributes = 0
>          if not policy_dig:
> 
> base-commit: 821e6e2a328bb907d40f8d1141d8b6c079aa7340
> -- 
> 2.50.1
> 


Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>

BR, Jarkko

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-11-25 15:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-23 11:18 [PATCH] selftests: tpm2: Fix ill defined assertions Maurice Hieronymus
2025-11-25 15:36 ` Jarkko Sakkinen

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).