random: simplify arithmetic function flow in account()
authorJason A. Donenfeld <Jason@zx2c4.com>
Mon, 17 Jan 2022 17:43:02 +0000 (18:43 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Jun 2022 09:46:32 +0000 (11:46 +0200)
commit5c539eee39b2d922a339690edec2f715fb4f1cc1
tree9a04047961bdd154cd540da5c35e6be7110cd8ff
parent166f9970b82af96899566d30a1ef199e09c46b71
random: simplify arithmetic function flow in account()

commit a254a0e4093fce8c832414a83940736067eed515 upstream.

Now that have_bytes is never modified, we can simplify this function.
First, we move the check for negative entropy_count to be first. That
ensures that subsequent reads of this will be non-negative. Then,
have_bytes and ibytes can be folded into their one use site in the
min_t() function.

Suggested-by: Dominik Brodowski <linux@dominikbrodowski.net>
Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/random.c