public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] module: Fix implicit type conversion
@ 2021-10-29  2:06 Jiasheng Jiang
  2021-11-08 18:31 ` Miroslav Benes
  0 siblings, 1 reply; 5+ messages in thread
From: Jiasheng Jiang @ 2021-10-29  2:06 UTC (permalink / raw)
  To: jeyu, ast, daniel, andrii, kafai, songliubraving, yhs,
	john.fastabend, kpsingh, nathan, ndesaulniers
  Cc: linux-kernel, netdev, bpf, clang-built-linux, Jiasheng Jiang

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.

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-11-10  0:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-29  2:06 [PATCH] module: Fix implicit type conversion Jiasheng Jiang
2021-11-08 18:31 ` Miroslav Benes
2021-11-09 20:56   ` Luis Chamberlain
2021-11-09 21:25     ` Peter Zijlstra
2021-11-10  0:04       ` Luis Chamberlain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox