random: remove unnecessary unlikely()
authorYangtao Li <tiny.windzz@gmail.com>
Tue, 7 Jan 2020 21:10:28 +0000 (16:10 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Jun 2022 09:46:28 +0000 (11:46 +0200)
commit 870e05b1b18814911cb2703a977f447cb974f0f9 upstream.

WARN_ON() already contains an unlikely(), so it's not necessary to use
unlikely.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
Link: https://lore.kernel.org/r/20190607182517.28266-1-tiny.windzz@gmail.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/random.c

index 9b988b21402757e1e94122af788afd3b9c991514..f8e5709cd7937c0fa46bf3c4584201d1fbe20d4e 100644 (file)
@@ -738,10 +738,9 @@ retry:
                } while (unlikely(entropy_count < pool_size-2 && pnfrac));
        }
 
-       if (unlikely(entropy_count < 0)) {
+       if (WARN_ON(entropy_count < 0)) {
                pr_warn("random: negative entropy/overflow: pool %s count %d\n",
                        r->name, entropy_count);
-               WARN_ON(1);
                entropy_count = 0;
        } else if (entropy_count > pool_size)
                entropy_count = pool_size;
@@ -1380,10 +1379,9 @@ retry:
        if (ibytes < min)
                ibytes = 0;
 
-       if (unlikely(entropy_count < 0)) {
+       if (WARN_ON(entropy_count < 0)) {
                pr_warn("random: negative entropy count: pool %s count %d\n",
                        r->name, entropy_count);
-               WARN_ON(1);
                entropy_count = 0;
        }
        nfrac = ibytes << (ENTROPY_SHIFT + 3);