[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1635478001-2572113-1-git-send-email-jiasheng@iscas.ac.cn>
Date: Fri, 29 Oct 2021 03:26:41 +0000
From: Jiasheng Jiang <jiasheng@...as.ac.cn>
To: tglx@...utronix.de
Cc: linux-kernel@...r.kernel.org, Jiasheng Jiang <jiasheng@...as.ac.cn>
Subject: [PATCH] genirq/matrix: Fix implicit type conversion
The variable 'cpu' is defined as unsigned int.
However in the for_each_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.
Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
---
kernel/irq/matrix.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/kernel/irq/matrix.c b/kernel/irq/matrix.c
index 578596e..825549a 100644
--- a/kernel/irq/matrix.c
+++ b/kernel/irq/matrix.c
@@ -129,7 +129,7 @@ static unsigned int matrix_alloc_area(struct irq_matrix *m, struct cpumap *cm,
static unsigned int matrix_find_best_cpu(struct irq_matrix *m,
const struct cpumask *msk)
{
- unsigned int cpu, best_cpu, maxavl = 0;
+ int cpu, best_cpu, maxavl = 0;
struct cpumap *cm;
best_cpu = UINT_MAX;
@@ -150,7 +150,7 @@ static unsigned int matrix_find_best_cpu(struct irq_matrix *m,
static unsigned int matrix_find_best_cpu_managed(struct irq_matrix *m,
const struct cpumask *msk)
{
- unsigned int cpu, best_cpu, allocated = UINT_MAX;
+ int cpu, best_cpu, allocated = UINT_MAX;
struct cpumap *cm;
best_cpu = UINT_MAX;
@@ -209,7 +209,7 @@ void irq_matrix_assign_system(struct irq_matrix *m, unsigned int bit,
*/
int irq_matrix_reserve_managed(struct irq_matrix *m, const struct cpumask *msk)
{
- unsigned int cpu, failed_cpu;
+ int cpu, failed_cpu;
for_each_cpu(cpu, msk) {
struct cpumap *cm = per_cpu_ptr(m->maps, cpu);
@@ -250,7 +250,7 @@ int irq_matrix_reserve_managed(struct irq_matrix *m, const struct cpumask *msk)
*/
void irq_matrix_remove_managed(struct irq_matrix *m, const struct cpumask *msk)
{
- unsigned int cpu;
+ int cpu;
for_each_cpu(cpu, msk) {
struct cpumap *cm = per_cpu_ptr(m->maps, cpu);
--
2.7.4
Powered by blists - more mailing lists