keys/trusted/tpm2: rename "bool" to "boolean"
Subsystems (4)
PATCH 1/1 keys/trusted/tpm2: rename "bool" to "boolean"
In C23, "bool" is a keyword so rename this array from bool[] to boolean[] to avoid a conflict.
--- security/keys/trusted-keys/trusted_tpm2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
security/keys/trusted-keys/trusted_tpm2.c +3 -3
@@ -59,13 +59,13 @@ static int tpm2_key_encode(struct trusted_key_payload *payload, asn1_oid_len(tpm2key_oid));if (private->blobauth_len ==0 ) { -unsigned char bool[3 ], *w = bool; +unsigned char boolean[3 ], *w = boolean;/* tag 0 is emptyAuth */ - w =asn1_encode_boolean (w, w +sizeof (bool ), true); + w =asn1_encode_boolean (w, w +sizeof (boolean), 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 , boolean, w - boolean); }/*
Signature · 1 line
2.53.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 4 lines
In C23, "bool" is a keyword so rename this array from bool[] to boolean[] to avoid a conflict.
Signed-off-by Dan Carpenter <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Jarkko Sakkinen
maintainerQuoted 32 lines · Dan Carpenter
In C23, "bool" is a keyword so rename this array from bool[] to boolean[] to avoid a conflict.
Signed-off-by Dan Carpenter <[email protected]>--- security/keys/trusted-keys/trusted_tpm2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)security/keys/trusted-keys/trusted_tpm2.c +3
-3@@ -59,13 +59,13 @@ static int tpm2_key_encode(struct trusted_key_payload *payload, asn1_oid_len(tpm2key_oid));if (private->blobauth_len ==0 ) { -unsigned char bool[3 ], *w = bool; +unsigned char boolean[3 ], *w = boolean;/* tag 0 is emptyAuth */ - w =asn1_encode_boolean (w, w +sizeof (bool ), true); + w =asn1_encode_boolean (w, w +sizeof (boolean), 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 , boolean, w - boolean); }/* Signature · 1 line
2.53.0
Are we migrating to C23? I've not followed this too closely.
Br, Jarkko
Quoted 2 lines · Jarkko Sakkinen
Are we migrating to C23? I've not followed this too closely.
Google AI says that we will adopt C23 next year or the year after. I argued that it would be would be after 2030 but AI said, "No, there is too much juicy stuff in C23 for kernel developers to wait so long."
I don't have a pressing need for this patch to be merged. I was just playing with some compiler related tools noticed this. It's the only place in the kernel which uses "bool" as a variable name.
regards,
dan carpenter
Jarkko Sakkinen
maintainerQuoted 11 lines · Dan Carpenter
Quoted 2 lines · Jarkko Sakkinen
Are we migrating to C23? I've not followed this too closely.
Google AI says that we will adopt C23 next year or the year after. I argued that it would be would be after 2030 but AI said, "No, there is too much juicy stuff in C23 for kernel developers to wait so long."
I don't have a pressing need for this patch to be merged. I was just playing with some compiler related tools noticed this. It's the only place in the kernel which uses "bool" as a variable name.
I do think that bool is not great choice for a variable name; in fact it is quite horrible choice. But since there is no other force than being horrible name, I think I'll pass...
Quoted 4 lines
regards,
dan carpenter
Br, Jarkko
Jarkko Sakkinen
maintainerQuoted 9 lines · Jarkko Sakkinen
Quoted 8 lines · Dan Carpenter
Quoted 2 lines · Jarkko Sakkinen
Are we migrating to C23? I've not followed this too closely.
Google AI says that we will adopt C23 next year or the year after. I argued that it would be would be after 2030 but AI said, "No, there is too much juicy stuff in C23 for kernel developers to wait so long."
Quoted 7 lines
Quoted 3 lines
I don't have a pressing need for this patch to be merged. I was just playing with some compiler related tools noticed this. It's the only place in the kernel which uses "bool" as a variable name.
I do think that bool is not great choice for a variable name; in fact it is quite horrible choice. But since there is no other force than being horrible name, I think I'll pass...
In order to put this in a proper context, I meant that bad variable names are common. I'm not blaming patch author in particular, especially since it is a local variable. It is just something that happens all the time; occasionally.
We could merge a billion patches like this with no other effect than causing extra merge conflicts in backports. So the net-effect is more harm than good.
Br, Jarkko
Quoted 13 lines · On Mon, 9 Nov 2026 08:39:24 +0300 Dan Carpenter <[email protected]> wrote:
In C23, "bool" is a keyword so rename this array from bool[] to boolean[] to avoid a conflict.
Signed-off-by Dan Carpenter <[email protected]>--- security/keys/trusted-keys/trusted_tpm2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)security/keys/trusted-keys/trusted_tpm2.c +0
-0
security/keys/trusted-keys/trusted_tpm2.c static int tpm2_key_encode(struct trusted_key_payload *payload, · line 66
Quoted 10 lines
security/keys/trusted-keys/trusted_tpm2.c +2
-2@@ -59,13 +59,13 @@ static int tpm2_key_encode(struct trusted_key_payload *payload, asn1_oid_len(tpm2key_oid));if (private->blobauth_len ==0 ) { -unsigned char bool[3 ], *w = bool; +unsigned char boolean[3 ], *w = boolean;/* tag 0 is emptyAuth */ - w =asn1_encode_boolean (w, w +sizeof (bool ), true); + w =asn1_encode_boolean (w, w +sizeof (boolean), true);if (WARN (IS_ERR (w),"BUG: Boolean failed to encode" ))return PTR_ERR (w);
Hmmm... how can that fail?
bool[] is just "\1\1\1".
I bet asn1_encode_bool() isn't inlined - where the compiler would optimise most of it away.
It is a horrid variable name, asn1_bool_true[] would be better.
David
Quoted 6 lines
security/keys/trusted-keys/trusted_tpm2.c +1
-1- work =asn1_encode_tag (work, end_work,0 , bool, w - bool); + work =asn1_encode_tag (work, end_work,0 , boolean, w - boolean); }/*
Jarkko Sakkinen
maintainerQuoted 8 lines · David Laight
Hmmm... how can that fail?
bool[] is just "\1\1\1".
I betasn1_encode_bool()isn't inlined - where the compiler would optimise most of it away.It is a horrid variable name, asn1_bool_true[] would be better.
David
Agreed.
ASN.1 deocoder (scripts/asn1_compiler.c) is ugly but elegant (it is) ;-)
Encoding side, well... It would for sure could benefit from some fresh thinking but more like a turnover than fixing up few variable names here and there, or addressing other cosmetic/minor details.
I'll put a remark on this to my personal TODO list. I'm doing a couple of such turnovers for keyrings ATM [1][2], which will keep me busy still for a while. This is my "post-LLM" strategy now at its core: "when you see a bug, fix the vector".
If you have a great "big picture" idea on how to do encoding better overall, I'm happy to look at such patches.
[1] https://lore.kernel.org/keyrings/[email protected]/
[2] https://lore.kernel.org/keyrings/[email protected]/
Br, Jarkko