* [PATCH] KEYS: encrypted: Simplify determining 'format_len'
@ 2025-10-15 23:21 Thorsten Blum
0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2025-10-15 23:21 UTC (permalink / raw)
To: Mimi Zohar, David Howells, Jarkko Sakkinen, Paul Moore,
James Morris, Serge E. Hallyn
Cc: Thorsten Blum, linux-integrity, keyrings, linux-security-module,
linux-kernel
Don't unnecessarily negate 'format' and simplify the calculation of
'format_len' in encrypted_key_alloc() and __ekey_init().
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
security/keys/encrypted-keys/encrypted.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/security/keys/encrypted-keys/encrypted.c b/security/keys/encrypted-keys/encrypted.c
index aef438d18da8..d70f71d37f5f 100644
--- a/security/keys/encrypted-keys/encrypted.c
+++ b/security/keys/encrypted-keys/encrypted.c
@@ -581,7 +581,7 @@ static struct encrypted_key_payload *encrypted_key_alloc(struct key *key,
if (ret < 0 || dlen < MIN_DATA_SIZE || dlen > MAX_DATA_SIZE)
return ERR_PTR(-EINVAL);
- format_len = (!format) ? strlen(key_format_default) : strlen(format);
+ format_len = strlen(format ?: key_format_default);
decrypted_datalen = dlen;
payload_datalen = decrypted_datalen;
@@ -704,7 +704,7 @@ static void __ekey_init(struct encrypted_key_payload *epayload,
{
unsigned int format_len;
- format_len = (!format) ? strlen(key_format_default) : strlen(format);
+ format_len = strlen(format ?: key_format_default);
epayload->format = epayload->payload_data + epayload->payload_datalen;
epayload->master_desc = epayload->format + format_len + 1;
epayload->datalen = epayload->master_desc + strlen(master_desc) + 1;
--
2.51.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-10-15 23:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-15 23:21 [PATCH] KEYS: encrypted: Simplify determining 'format_len' Thorsten Blum
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).