diff options
author | Thorsten Blum <thorsten.blum@toblux.com> | 2024-08-19 17:18:44 +0300 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2024-08-30 13:22:30 +0300 |
commit | 7f60adffe531c06bacab79dbf687f0ea85fb99e8 (patch) | |
tree | 4cdbc74ada0ea74183a90d23ee81f33df0faabc2 /crypto | |
parent | ce3d2d6b150ba8528f3218ebf0cee2c2c572662d (diff) | |
download | linux-7f60adffe531c06bacab79dbf687f0ea85fb99e8.tar.xz |
crypto: jitter - Use min() to simplify jent_read_entropy()
Use the min() macro to simplify the jent_read_entropy() function and
improve its readability.
Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/jitterentropy.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/crypto/jitterentropy.c b/crypto/jitterentropy.c index d7056de8c0d7..3b390bd6c119 100644 --- a/crypto/jitterentropy.c +++ b/crypto/jitterentropy.c @@ -146,6 +146,7 @@ struct rand_data { #define JENT_ENTROPY_SAFETY_FACTOR 64 #include <linux/fips.h> +#include <linux/minmax.h> #include "jitterentropy.h" /*************************************************************************** @@ -638,10 +639,7 @@ int jent_read_entropy(struct rand_data *ec, unsigned char *data, return -2; } - if ((DATA_SIZE_BITS / 8) < len) - tocopy = (DATA_SIZE_BITS / 8); - else - tocopy = len; + tocopy = min(DATA_SIZE_BITS / 8, len); if (jent_read_random_block(ec->hash_state, p, tocopy)) return -1; |