[v1,1/3] security: keys: don't use data type as variable name

Message ID 20230304041932.847133-2-wei.w.wang@intel.com
State New
Headers
Series Regarding using 'bool' appropriately |

Commit Message

Wang, Wei W March 4, 2023, 4:19 a.m. UTC
  'bool' is a specific name for the data type that is an alias for
the C99 _Bool type. It shoudn't be used as variable names as that causes
too much confusion either for the reader or the compilier.

CC: James.Bottomley@HansenPartnership.com
CC: jarkko@kernel.org
Fixes: f2219745250f ("security: keys: trusted: use ASN.1 TPM2 key format for the blobs")
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
---
 security/keys/trusted-keys/trusted_tpm2.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Comments

Jarkko Sakkinen March 11, 2023, 10:13 p.m. UTC | #1
On Sat, Mar 04, 2023 at 12:19:30PM +0800, Wei Wang wrote:
> 'bool' is a specific name for the data type that is an alias for
> the C99 _Bool type. It shoudn't be used as variable names as that causes
> too much confusion either for the reader or the compilier.
> 
> CC: James.Bottomley@HansenPartnership.com
> CC: jarkko@kernel.org
> Fixes: f2219745250f ("security: keys: trusted: use ASN.1 TPM2 key format for the blobs")
> Signed-off-by: Wei Wang <wei.w.wang@intel.com>
> ---
>  security/keys/trusted-keys/trusted_tpm2.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/security/keys/trusted-keys/trusted_tpm2.c b/security/keys/trusted-keys/trusted_tpm2.c
> index 2b2c8eb258d5..390d7314f5a6 100644
> --- a/security/keys/trusted-keys/trusted_tpm2.c
> +++ b/security/keys/trusted-keys/trusted_tpm2.c
> @@ -54,12 +54,13 @@ static int tpm2_key_encode(struct trusted_key_payload *payload,
>  			       asn1_oid_len(tpm2key_oid));
>  
>  	if (options->blobauth_len == 0) {
> -		unsigned char bool[3], *w = bool;
> +		unsigned char bool_val[3], *w = bool_val;
>  		/* tag 0 is emptyAuth */
>  		w = asn1_encode_boolean(w, w + sizeof(bool), true);
>  		if (WARN(IS_ERR(w), "BUG: Boolean failed to encode"))
>  			return PTR_ERR(w);
> -		work = asn1_encode_tag(work, end_work, 0, bool, w - bool);
> +		work = asn1_encode_tag(work, end_work, 0,
> +				       bool_val, w - bool_val);
>  	}
>  
>  	/*
> -- 
> 2.27.0
> 

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

BR, Jarkko
  

Patch

diff --git a/security/keys/trusted-keys/trusted_tpm2.c b/security/keys/trusted-keys/trusted_tpm2.c
index 2b2c8eb258d5..390d7314f5a6 100644
--- a/security/keys/trusted-keys/trusted_tpm2.c
+++ b/security/keys/trusted-keys/trusted_tpm2.c
@@ -54,12 +54,13 @@  static int tpm2_key_encode(struct trusted_key_payload *payload,
 			       asn1_oid_len(tpm2key_oid));
 
 	if (options->blobauth_len == 0) {
-		unsigned char bool[3], *w = bool;
+		unsigned char bool_val[3], *w = bool_val;
 		/* tag 0 is emptyAuth */
 		w = asn1_encode_boolean(w, w + sizeof(bool), true);
 		if (WARN(IS_ERR(w), "BUG: Boolean failed to encode"))
 			return PTR_ERR(w);
-		work = asn1_encode_tag(work, end_work, 0, bool, w - bool);
+		work = asn1_encode_tag(work, end_work, 0,
+				       bool_val, w - bool_val);
 	}
 
 	/*