Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp773568ybb; Sat, 28 Mar 2020 09:44:03 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtsCYG+Bveqe/C6loVW1vc7NGFat4uvgjWL4CkEO+axCFHH0AD9ypHAU9lAtLeo69bA9CFU X-Received: by 2002:a05:6830:1413:: with SMTP id v19mr3070202otp.41.1585413843659; Sat, 28 Mar 2020 09:44:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585413843; cv=none; d=google.com; s=arc-20160816; b=C8q673Kibgdbk/dVebKSPvIH3EW65UQypzKZyv2KnqgbBA23n1H3dmx4m+hQpqhXVu XDk0pFWG2IznOQnNJfMM29EwlJYYyilwHGi5Mw1BofPmiqqYtFWSu+iEM9kAkYedOlox 5c47P9n4TkDAlYYrDnpbcByYMU14zbQKQAvS1cIn4/X90W9d4wB3DA3+5mBTSFl777kh 918Zx1BJeHbx0jHHINQLvoUjqhGCgXmqsPccZWTt0OO+i7Htgkg/lv9ATEkHRewhN8xy EqeOhtdSXW4p4GkPv0r4dg2Rir+MsY6XxzoNkGe0uw4fbPkum37y6zU9StVI4J6qFF88 WTwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:date:from:message-id; bh=num4eSTYZnqA//MetH8ne2JiIDm5yM1R23zO6/RPDp8=; b=VAtW9eqbCxmeVeyTMKeP0aYglOqq6BTKIpcW5/6Owt1HDMOUvymNvqoTiOgtehZTDH JgXw+oj77fkR5fERSqhsUgAs4ZWFxELdUOIVtfGLl7in/pvXZoI+D1m7VrQrLXCaBb0e bNQLUYCoNLimawu4BK/NZS+spngehqRrEtNXm3YBSI+6CLtA48FQDPEED2kU+aZBVOH6 f5DHYilftsdQ7n99gYnJgB8BKAurvNpxFXUrFQAhEriKj6ydYIfPuMr43gpEr/qHf1Lv Af8qCADVGcVyP0QGV4M7DyiNDo9lDA4ljqcbH+vGfM8FZVh+i3q+ryBOnxjkcRpArC6c rgpA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w85si3783945oif.88.2020.03.28.09.43.50; Sat, 28 Mar 2020 09:44:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727491AbgC1QnV (ORCPT + 99 others); Sat, 28 Mar 2020 12:43:21 -0400 Received: from mx.sdf.org ([205.166.94.20]:50209 "EHLO mx.sdf.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727406AbgC1QnU (ORCPT ); Sat, 28 Mar 2020 12:43:20 -0400 Received: from sdf.org (IDENT:lkml@sdf.lonestar.org [205.166.94.16]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 02SGhDDT006033 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO); Sat, 28 Mar 2020 16:43:13 GMT Received: (from lkml@localhost) by sdf.org (8.15.2/8.12.8/Submit) id 02SGhDXl006621; Sat, 28 Mar 2020 16:43:13 GMT Message-Id: <202003281643.02SGhDXl006621@sdf.org> From: George Spelvin Date: Fri, 29 Nov 2019 17:44:31 -0500 Subject: [RFC PATCH v1 17/50] net/802/{garp,mrp}.c: Use prandom_u32_max instead of manual equivalent To: linux-kernel@vger.kernel.org, lkml@sdf.org Cc: Aruna-Hewapathirane , "David S. Miller" , netdev@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The previous code was carefully written for efficiency, which is good, but the helper function is more legible. Signed-off-by: George Spelvin Cc: Aruna-Hewapathirane Cc: David S. Miller 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