From: George Spelvin <lkml@sdf.org>
To: linux-kernel@vger.kernel.org, lkml@sdf.org
Cc: Aruna-Hewapathirane <aruna.hewapathirane@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org
Subject: [RFC PATCH v1 17/50] net/802/{garp,mrp}.c: Use prandom_u32_max instead of manual equivalent
Date: Fri, 29 Nov 2019 17:44:31 -0500 [thread overview]
Message-ID: <202003281643.02SGhDXl006621@sdf.org> (raw)
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
reply other threads:[~2020-03-28 16:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202003281643.02SGhDXl006621@sdf.org \
--to=lkml@sdf.org \
--cc=aruna.hewapathirane@gmail.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®