[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240320192715.22eeeba84c0fd3a8c2353c79@kernel.org>
Date: Wed, 20 Mar 2024 19:27:15 +0900
From: Masami Hiramatsu (Google) <mhiramat@...nel.org>
To: Thorsten Blum <thorsten.blum@...lux.com>
Cc: Steven Rostedt <rostedt@...dmis.org>, Mathieu Desnoyers
<mathieu.desnoyers@...icios.com>, linux-kernel@...r.kernel.org,
linux-trace-kernel@...r.kernel.org
Subject: Re: [PATCH] tracing: Explicitly cast divisor to fix Coccinelle
warning
On Mon, 18 Mar 2024 11:52:44 +0100
Thorsten Blum <thorsten.blum@...lux.com> wrote:
> Explicitly cast the divisor to u32 to fix a Coccinelle/coccicheck warning
> reported by do_div.cocci.
>
Hmm, strange, trace_do_benchmark() has another do_div(u64, u64).
do {
last_seed = seed;
seed = stddev;
if (!last_seed)
break;
do_div(seed, last_seed);
seed += last_seed;
do_div(seed, 2);
} while (i++ < 10 && last_seed != seed);
Didn't Coccinelle find that?
Thank you,
> Signed-off-by: Thorsten Blum <thorsten.blum@...lux.com>
> ---
> kernel/trace/trace_benchmark.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/trace/trace_benchmark.c b/kernel/trace/trace_benchmark.c
> index 54d5fa35c90a..218b40050629 100644
> --- a/kernel/trace/trace_benchmark.c
> +++ b/kernel/trace/trace_benchmark.c
> @@ -105,7 +105,7 @@ static void trace_do_benchmark(void)
> stddev = 0;
>
> delta = bm_total;
> - do_div(delta, bm_cnt);
> + do_div(delta, (u32)bm_cnt);
> avg = delta;
>
> if (stddev > 0) {
> --
> 2.44.0
>
--
Masami Hiramatsu (Google) <mhiramat@...nel.org>
Powered by blists - more mailing lists