Skip to contentSkip to conversation

MIPS: ip27-timer: fix unsigned irq < 0

PATCH Applied Roel Kluin 3 participants 5 messages Apr 16, 2008 – Apr 17, 2008 MIPS

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 2/6 MIPS: ip27-timer: fix unsigned irq < 0

irq is unsigned, cast to signed to evaluate the allocate_irqno() return value,

---

arch/mips/sgi-ip27/ip27-timer.c +1 -1
index 25d3baf..3c08afd 100644
@@ -222,19 +222,19 @@ static void __init hub_rt_clock_event_global_init(void)
 	unsigned int irq;
 
 	do {
 		smp_wmb();
 		irq = rt_timer_irq;
 		if (irq)
 			break;
 
 		irq = allocate_irqno();
-		if (irq < 0)
+		if ((int) irq < 0)
 			panic("Allocation of irq number for timer failed");
 	} while (xchg(&rt_timer_irq, irq));
 
 	set_irq_chip_and_handler(irq, &rt_irq_type, handle_percpu_irq);
 	setup_irq(irq, &hub_rt_irqaction);
 }
 
 static cycle_t hub_rt_read(void)
 {
#1 lore raw
Quoted 10 lines · Roel Kluin

irq is unsigned, cast to signed to evaluate the allocate_irqno() return value,

---

arch/mips/sgi-ip27/ip27-timer.c +0 -0
index 25d3baf..3c08afd 100644
@@ -222,19 +222,19 @@ static void __init hub_rt_clock_event_global_init(void)
 	unsigned int irq;

arch/mips/sgi-ip27/ip27-timer.c static void __init hub_rt_clock_event_global_init(void) · line 231

Quoted 10 lines
arch/mips/sgi-ip27/ip27-timer.c +1 -1
 
 	do {
 		smp_wmb();
 		irq = rt_timer_irq;
 		if (irq)
 			break;
 
 		irq = allocate_irqno();
-		if (irq < 0)
+		if ((int) irq < 0)

Why don't you just make irq and rt_timer_irq an int ?

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                                [ RFC1925, 2.3 ]
author
#2 lore raw

PATCH v2 2/6 MIPS: ip27-timer: unsigned irq to evaluate allocate_irqno()

Quoted 6 lines · Thomas Bogendoerfer

Review

Quoted 3 lines · Roel Kluin

irq is unsigned, cast to signed to evaluate the allocate_irqno() return value,

(quoted diff) +1 -0
+		if ((int) irq < 0)

Why don't you just make irq and rt_timer_irq an int ?

Ok, thanks, It should be right, but I cannot test this (no hardware).
---
when allocate_irqno() returns a negative error value, but is stored in an unsigned variable 'irq', the test '(irq < 0)' won't work.

---

arch/mips/sgi-ip27/ip27-timer.c +2 -2
index 25d3baf..9cebc9e 100644
@@ -158,7 +158,7 @@ static void rt_set_mode(enum clock_event_mode mode,
 	}
 }
 
-unsigned int rt_timer_irq;
+int rt_timer_irq;
 
 static irqreturn_t hub_rt_counter_handler(int irq, void *dev_id)
 {
@@ -219,7 +219,7 @@ static void __cpuinit hub_rt_clock_event_init(void)
 
 static void __init hub_rt_clock_event_global_init(void)
 {
-	unsigned int irq;
+	int irq;
 
 	do {
 		smp_wmb();
maintainer Acked-by on v2 2/6
#3 lore raw

Re: [PATCH 2/6 v2] MIPS: ip27-timer: unsigned irq to evaluate allocate_irqno()

Quoted 9 lines · Roel Kluin
Quoted 6 lines · Thomas Bogendoerfer

Review

Quoted 3 lines · Roel Kluin

irq is unsigned, cast to signed to evaluate the allocate_irqno() return value,

(quoted diff) +1 -0
+		if ((int) irq < 0)

Why don't you just make irq and rt_timer_irq an int ?

Ok, thanks, It should be right, but I cannot test this (no hardware).

I've tested it on real hardware.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessary a
good idea.                                                [ RFC1925, 2.3 ]
Applied
#4 lore raw

Re: [PATCH 2/6 v2] MIPS: ip27-timer: unsigned irq to evaluate allocate_irqno()

Quoted 9 lines · Thomas Bogendoerfer
Quoted 8 lines · Roel Kluin
Quoted 6 lines · Thomas Bogendoerfer

Review

Quoted 3 lines · Roel Kluin

irq is unsigned, cast to signed to evaluate the allocate_irqno() return value,

(quoted diff) +1 -0
+		if ((int) irq < 0)

Why don't you just make irq and rt_timer_irq an int ?

Quoted 5 lines
Quoted 1 line

Ok, thanks, It should be right, but I cannot test this (no hardware).

I've tested it on real hardware.

Thanks, applied.

Ralf