Skip to contentSkip to conversation

LoongArch: Fix unsigned comparison with less than zero

PATCH In review Yang Li 2 participants 2 messages Jul 22, 2022 LoongArch

lore
Share & tools
lore

Yang Li

author
#0 lore raw

PATCH 1/1 LoongArch: Fix unsigned comparison with less than zero

The return from the call to get_timer_irq() is int, it can be a negative error code, however this is being assigned to an unsigned int variable 'irq', so making 'irq' an int.

Eliminate the following coccicheck warning:
./arch/loongarch/kernel/time.c:146:5-8: WARNING: Unsigned expression compared with zero: irq < 0

---
 arch/loongarch/kernel/time.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/loongarch/kernel/time.c +1 -1
index 79dc5eddf504..786735dcc8d6 100644
@@ -135,7 +135,7 @@ static int get_timer_irq(void)
 
 int constant_clockevent_init(void)
 {
-	unsigned int irq;
+	int irq;
 	unsigned int cpu = smp_processor_id();
 	unsigned long min_delta = 0x600;
 	unsigned long max_delta = (1UL << 48) - 1;
Signature · 1 line
2.20.1.7.g153144c
maintainer
#1 lore raw

Hi, Yang Li,

Thank you for your patch. This looks good to me and will be queued for 5.20, since Marc said he will not rebase his branch. :)

Huacai

Quoted 30 lines · Yang Li

The return from the call to get_timer_irq() is int, it can be a negative error code, however this is being assigned to an unsigned int variable 'irq', so making 'irq' an int.

Eliminate the following coccicheck warning:
./arch/loongarch/kernel/time.c:146:5-8: WARNING: Unsigned expression compared with zero: irq < 0

---
 arch/loongarch/kernel/time.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/loongarch/kernel/time.c +1 -2
index 79dc5eddf504..786735dcc8d6 100644
@@ -135,7 +135,7 @@ static int get_timer_irq(void)
 
 int constant_clockevent_init(void)
 {
-       unsigned int irq;
+       int irq;
        unsigned int cpu = smp_processor_id();
        unsigned long min_delta = 0x600;
        unsigned long max_delta = (1UL << 48) - 1;
--

2.20.1.7.g153144c