MIPS: ip27-timer: fix unsigned irq < 0
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
@@ -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 ) {
Thomas Bogendoerfer
maintainerQuoted 10 lines · Roel Kluin
irq is unsigned, cast to signed to evaluate the
allocate_irqno()return value,Signed-off-by Roel Kluin <[email protected]>---
arch/mips/sgi-ip27/ip27-timer.c +0
-0@@ -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
-1do { 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 ]
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_irqan 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
@@ -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();
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_irqan 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 ]
Ralf Baechle
AppliedRe: [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_irqan 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