From: Thorsten Blum Date: Mon, 19 Aug 2024 14:18:44 +0000 (+0200) Subject: crypto: jitter - Use min() to simplify jent_read_entropy() X-Git-Tag: v6.12-rc1~231^2~38 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7f60adffe531c06bacab79dbf687f0ea85fb99e8;p=thirdparty%2Fkernel%2Flinux.git 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 Signed-off-by: Herbert Xu --- diff --git a/crypto/jitterentropy.c b/crypto/jitterentropy.c index d7056de8c0d7b..3b390bd6c1196 100644 --- a/crypto/jitterentropy.c +++ b/crypto/jitterentropy.c @@ -146,6 +146,7 @@ struct rand_data { #define JENT_ENTROPY_SAFETY_FACTOR 64 #include +#include #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;