[PATCH] crypto: rng - Combine two seq_printf() calls into one in crypto_rng_show()

Markus Elfring posted 1 patch 2 months, 4 weeks ago
crypto/rng.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] crypto: rng - Combine two seq_printf() calls into one in crypto_rng_show()
Posted by Markus Elfring 2 months, 4 weeks ago
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 10 Nov 2025 16:45:13 +0100

A bit of data was put into a sequence by two separate function calls.
Print the same data by a single function call instead.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 crypto/rng.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/crypto/rng.c b/crypto/rng.c
index ee1768c5a400..479c4ac6fb6c 100644
--- a/crypto/rng.c
+++ b/crypto/rng.c
@@ -81,8 +81,7 @@ static void crypto_rng_show(struct seq_file *m, struct crypto_alg *alg)
 	__maybe_unused;
 static void crypto_rng_show(struct seq_file *m, struct crypto_alg *alg)
 {
-	seq_printf(m, "type         : rng\n");
-	seq_printf(m, "seedsize     : %u\n", seedsize(alg));
+	seq_printf(m, "type         : rng\nseedsize     : %u\n", seedsize(alg));
 }
 
 static const struct crypto_type crypto_rng_type = {
-- 
2.51.1
Re: [PATCH] crypto: rng - Combine two seq_printf() calls into one in crypto_rng_show()
Posted by Herbert Xu 2 months, 2 weeks ago
On Mon, Nov 10, 2025 at 04:56:10PM +0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 10 Nov 2025 16:45:13 +0100
> 
> A bit of data was put into a sequence by two separate function calls.
> Print the same data by a single function call instead.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  crypto/rng.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/crypto/rng.c b/crypto/rng.c
> index ee1768c5a400..479c4ac6fb6c 100644
> --- a/crypto/rng.c
> +++ b/crypto/rng.c
> @@ -81,8 +81,7 @@ static void crypto_rng_show(struct seq_file *m, struct crypto_alg *alg)
>  	__maybe_unused;
>  static void crypto_rng_show(struct seq_file *m, struct crypto_alg *alg)
>  {
> -	seq_printf(m, "type         : rng\n");
> -	seq_printf(m, "seedsize     : %u\n", seedsize(alg));
> +	seq_printf(m, "type         : rng\nseedsize     : %u\n", seedsize(alg));

This makes the code look worse and appears to be an optimisation
that isn't really needed.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Re: [PATCH] crypto: rng - Combine two seq_printf() calls into one in crypto_rng_show()
Posted by Markus Elfring 2 months, 2 weeks ago
…>> +++ b/crypto/rng.c
>> @@ -81,8 +81,7 @@ static void crypto_rng_show(struct seq_file *m, struct crypto_alg *alg)
>>  	__maybe_unused;
>>  static void crypto_rng_show(struct seq_file *m, struct crypto_alg *alg)
>>  {
>> -	seq_printf(m, "type         : rng\n");
>> -	seq_printf(m, "seedsize     : %u\n", seedsize(alg));
>> +	seq_printf(m, "type         : rng\nseedsize     : %u\n", seedsize(alg));
> 
> This makes the code look worse and appears to be an optimisation
> that isn't really needed.

Would you expect to specify still two string literals at such a source code place?

Regards,
Markus