Commit 7f60adff authored by Thorsten Blum's avatar Thorsten Blum Committed by Herbert Xu

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: default avatarThorsten Blum <thorsten.blum@toblux.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent ce3d2d6b
...@@ -146,6 +146,7 @@ struct rand_data { ...@@ -146,6 +146,7 @@ struct rand_data {
#define JENT_ENTROPY_SAFETY_FACTOR 64 #define JENT_ENTROPY_SAFETY_FACTOR 64
#include <linux/fips.h> #include <linux/fips.h>
#include <linux/minmax.h>
#include "jitterentropy.h" #include "jitterentropy.h"
/*************************************************************************** /***************************************************************************
...@@ -638,10 +639,7 @@ int jent_read_entropy(struct rand_data *ec, unsigned char *data, ...@@ -638,10 +639,7 @@ int jent_read_entropy(struct rand_data *ec, unsigned char *data,
return -2; return -2;
} }
if ((DATA_SIZE_BITS / 8) < len) tocopy = min(DATA_SIZE_BITS / 8, len);
tocopy = (DATA_SIZE_BITS / 8);
else
tocopy = len;
if (jent_read_random_block(ec->hash_state, p, tocopy)) if (jent_read_random_block(ec->hash_state, p, tocopy))
return -1; return -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment