Thread (2 messages) flat view 2 messages, 2 authors, 2021-10-26
STALE1787d

[PATCH] md/raid5: Fix implicit type conversion

From: Jiasheng Jiang <hidden>
Date: 2021-10-26 08:13:05
Also in: lkml
Subsystem: software raid (multiple disks) support, the rest · Maintainers: Song Liu, Yu Kuai, Linus Torvalds

The variable 'cpu' is defined as ULONG.
However in the for_each_present_cpu, its value 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 UINT
to INT.

Fixes: 738a273 ("md/raid5: fix allocation of 'scribble' array.")
Signed-off-by: Jiasheng Jiang <redacted>
---
 drivers/md/raid5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 7d4ff8a..c7b88eb 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2425,7 +2425,7 @@ static int scribble_alloc(struct raid5_percpu *percpu,
 
 static int resize_chunks(struct r5conf *conf, int new_disks, int new_sectors)
 {
-	unsigned long cpu;
+	int cpu;
 	int err = 0;
 
 	/*
-- 
2.7.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help