]> git.baikalelectronics.ru Git - kernel.git/commit
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>
Mon, 30 May 2022 07:29:03 +0000 (09:29 +0200)
commit7b6d074d86dcb906c5618f2d18f28d79f8c1b0ac
treeaa6a1bbb04f330419e43771df4e6116d6744d89b
parent61e9d99bbdd13e2cb88c191101c2e5faf681fdce
random: simplify arithmetic function flow in account()

commit 9fb3f12485080455a5b6ebc1166206f2b5f5b40f 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