[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LSU.2.21.2111081925580.1710@pobox.suse.cz>
Date: Mon, 8 Nov 2021 19:31:05 +0100 (CET)
From: Miroslav Benes <mbenes@...e.cz>
To: Jiasheng Jiang <jiasheng@...as.ac.cn>
cc: jeyu@...nel.org, ast@...nel.org, daniel@...earbox.net,
andrii@...nel.org, kafai@...com, songliubraving@...com, yhs@...com,
john.fastabend@...il.com, kpsingh@...nel.org, nathan@...nel.org,
ndesaulniers@...gle.com, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org, bpf@...r.kernel.org,
clang-built-linux@...glegroups.com, mcgrof@...nel.org
Subject: Re: [PATCH] module: Fix implicit type conversion
[CCing Luis]
Hi,
On Fri, 29 Oct 2021, Jiasheng Jiang wrote:
> The variable 'cpu' is defined as unsigned int.
> However in the for_each_possible_cpu, its values is assigned to -1.
> That doesn't make sense and in the cpumask_next() it is implicitly
> type conversed to int.
> It is universally accepted that the implicit type conversion is
> terrible.
> Also, having the good programming custom will set an example for
> others.
> Thus, it might be better to change the definition of 'cpu' from
> unsigned int to int.
Frankly, I don't see a benefit of changing this. It seems fine to me.
Moreover this is not, by far, the only place in the kernel with the same
pattern.
Miroslav
> Fixes: 10fad5e ("percpu, module: implement and use is_kernel/module_percpu_address()")
> Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
> ---
> kernel/module.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/module.c b/kernel/module.c
> index 927d46c..f10d611 100644
> --- a/kernel/module.c
> +++ b/kernel/module.c
> @@ -632,7 +632,7 @@ static void percpu_modcopy(struct module *mod,
> bool __is_module_percpu_address(unsigned long addr, unsigned long *can_addr)
> {
> struct module *mod;
> - unsigned int cpu;
> + int cpu;
>
> preempt_disable();
>
> --
> 2.7.4
>
Powered by blists - more mailing lists