lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Mon, 26 Feb 2024 19:34:31 +0800
From: "Liao, Chang" <liaochang1@...wei.com>
To: Thorsten Blum <thorsten.blum@...lux.com>
CC: <anna-maria@...utronix.de>, <frederic@...nel.org>, <jstultz@...gle.com>,
	<linux-kernel@...r.kernel.org>, <peterz@...radead.org>, <tglx@...utronix.de>
Subject: Re: [PATCH v2] time: Use div64_ul() instead of do_div()



在 2024/2/26 17:03, Thorsten Blum 写道:
> Fixes Coccinelle/coccicheck warning reported by do_div.cocci.
> 
> Compared to do_div(), div64_ul() does not implicitly cast the divisor and
> does not unnecessarily calculate the remainder.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@...lux.com>
> ---
> Changes in v2:
> - s/div64_long/div64_ul/ as suggested by Chang Liao
> ---
>  kernel/time/jiffies.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/time/jiffies.c b/kernel/time/jiffies.c
> index bc4db9e5ab70..fccee15e94d5 100644
> --- a/kernel/time/jiffies.c
> +++ b/kernel/time/jiffies.c
> @@ -91,7 +91,7 @@ int register_refined_jiffies(long cycles_per_second)
>  	/* shift_hz stores hz<<8 for extra accuracy */
>  	shift_hz = (u64)cycles_per_second << 8;
>  	shift_hz += cycles_per_tick/2;
> -	do_div(shift_hz, cycles_per_tick);
> +	shift_hz = div64_ul(shift_hz, cycles_per_tick);

LGTM

Reviewed-by: Liao Chang <liaochang1@...wei.com>

>  	/* Calculate nsec_per_tick using shift_hz */
>  	nsec_per_tick = (u64)NSEC_PER_SEC << 8;
>  	nsec_per_tick += (u32)shift_hz/2;

-- 
BR
Liao, Chang

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ