mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Miroslav Benes <mbenes@suse.cz>
To: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Cc: jeyu@kernel.org, ast@kernel.org, daniel@iogearbox.net,
	andrii@kernel.org, kafai@fb.com, songliubraving@fb.com,
	yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org,
	nathan@kernel.org, ndesaulniers@google.com,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	bpf@vger.kernel.org, clang-built-linux@googlegroups.com,
	mcgrof@kernel.org
Subject: Re: [PATCH] module: Fix implicit type conversion
Date: Mon, 8 Nov 2021 19:31:05 +0100 (CET)	[thread overview]
Message-ID: <alpine.LSU.2.21.2111081925580.1710@pobox.suse.cz> (raw)
In-Reply-To: <1635473169-1848729-1-git-send-email-jiasheng@iscas.ac.cn>

[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@iscas.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
> 


  reply	other threads:[~2021-11-08 18:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-29  2:06 Jiasheng Jiang
2021-11-08 18:31 ` Miroslav Benes [this message]
2021-11-09 20:56   ` Luis Chamberlain
2021-11-09 21:25     ` Peter Zijlstra
2021-11-10  0:04       ` Luis Chamberlain

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=alpine.LSU.2.21.2111081925580.1710@pobox.suse.cz \
    --to=mbenes@suse.cz \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=clang-built-linux@googlegroups.com \
    --cc=daniel@iogearbox.net \
    --cc=jeyu@kernel.org \
    --cc=jiasheng@iscas.ac.cn \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /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®