linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] random: remove unnecessary unlikely()
@ 2019-06-07 18:25 Yangtao Li
  2019-06-07 18:25 ` [PATCH 2/5] random: convert to ENTROPY_BITS Yangtao Li
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Yangtao Li @ 2019-06-07 18:25 UTC (permalink / raw)
  To: tytso, arnd, gregkh; +Cc: linux-kernel, Yangtao Li

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

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
---
 drivers/char/random.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 5d5ea4ce1442..bebf622c61c4 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -759,10 +759,9 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits)
 		} 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;
@@ -1465,10 +1464,9 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
 	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);
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2020-01-07 22:20 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-07 18:25 [PATCH 1/5] random: remove unnecessary unlikely() Yangtao Li
2019-06-07 18:25 ` [PATCH 2/5] random: convert to ENTROPY_BITS Yangtao Li
2020-01-07 21:37   ` Theodore Y. Ts'o
2019-06-07 18:25 ` [PATCH 3/5] random: Add and use pr_fmt() Yangtao Li
2019-06-10 19:12   ` Joe Perches
2020-01-07 21:45   ` Theodore Y. Ts'o
2019-06-07 18:25 ` [PATCH 4/5] random: fix typo in add_timer_randomness() Yangtao Li
2020-01-07 22:08   ` Theodore Y. Ts'o
2019-06-07 18:25 ` [PATCH 5/5] random: remove some dead code of poolinfo Yangtao Li
2020-01-07 22:20   ` Theodore Y. Ts'o
2019-07-11 14:49 ` [PATCH 1/5] random: remove unnecessary unlikely() Frank Lee
2019-10-29  7:14   ` Joe Perches
2019-11-09  0:54     ` Joe Perches
2019-12-14 18:15       ` Frank Lee
2020-01-07 21:10 ` Theodore Y. Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).