mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH v1 17/50] net/802/{garp,mrp}.c: Use prandom_u32_max instead of manual equivalent
@ 2019-11-29 22:44 George Spelvin
  0 siblings, 0 replies; only message in thread
From: George Spelvin @ 2019-11-29 22:44 UTC (permalink / raw)
  To: linux-kernel, lkml; +Cc: Aruna-Hewapathirane, David S. Miller, netdev

The previous code was carefully written for efficiency, which is
good, but the helper function is more legible.

Signed-off-by: George Spelvin <lkml@sdf.org>
Cc: Aruna-Hewapathirane <aruna.hewapathirane@gmail.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
---
 net/802/garp.c | 2 +-
 net/802/mrp.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/802/garp.c b/net/802/garp.c
index 400bd857e5f57..84a82d1b9ed59 100644
--- a/net/802/garp.c
+++ b/net/802/garp.c
@@ -394,7 +394,7 @@ static void garp_join_timer_arm(struct garp_applicant *app)
 {
 	unsigned long delay;
 
-	delay = (u64)msecs_to_jiffies(garp_join_time) * prandom_u32() >> 32;
+	delay = prandom_u32_max(msecs_to_jiffies(garp_join_time));
 	mod_timer(&app->join_timer, jiffies + delay);
 }
 
diff --git a/net/802/mrp.c b/net/802/mrp.c
index bea6e43d45a0d..bed550772aeb5 100644
--- a/net/802/mrp.c
+++ b/net/802/mrp.c
@@ -579,7 +579,7 @@ static void mrp_join_timer_arm(struct mrp_applicant *app)
 {
 	unsigned long delay;
 
-	delay = (u64)msecs_to_jiffies(mrp_join_time) * prandom_u32() >> 32;
+	delay = prandom_u32_max(msecs_to_jiffies(mrp_join_time));
 	mod_timer(&app->join_timer, jiffies + delay);
 }
 
-- 
2.26.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-03-28 16:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-29 22:44 [RFC PATCH v1 17/50] net/802/{garp,mrp}.c: Use prandom_u32_max instead of manual equivalent George Spelvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®