Bug 13476

Summary: wrong #endif
Product: Platform Specific/Hardware Reporter: Martin Ettl (ettl.martin)
Component: OtherAssignee: Jesper Nilsson (jesper.nilsson)
Status: RESOLVED CODE_FIX    
Severity: normal CC: jesper.nilsson
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.29.4 Subsystem:
Regression: No Bisected commit-id:

Description Martin Ettl 2009-06-07 14:02:49 UTC
Hello,

i've detected a wrong #ifdef ...#endif sequence. This was detected by cppcheck, a static code analysis tool.

At file :
linux-2.6.29.4/arch/cris/arch-v32/kernel/irq.c

Take a look at the code, to function 
void crisv32_do_multiple(struct pt_regs* regs)
{
	int cpu;
	int mask;
	int masked[NBR_REGS];
	int bit;
	int i;

	cpu = smp_processor_id();

	/* An extra irq_enter here to prevent softIRQs to run after
         * each do_IRQ. This will decrease the interrupt latency.
	 */
	irq_enter();

	for (i = 0; i < NBR_REGS; i++) {
		/* Get which IRQs that happend. */
		masked[i] = REG_RD_INT_VECT(intr_vect, irq_regs[cpu],
			r_masked_vect, i);

		/* Calculate new IRQ mask with these IRQs disabled. */
		mask = REG_RD_INT_VECT(intr_vect, irq_regs[cpu], rw_mask, i);
		mask &= ~masked[i];

	/* Timer IRQ is never masked */
#ifdef TIMER_VECT1
		if ((i == 1) && (masked[0] & TIMER_MASK))
			mask |= TIMER_MASK;
#else
		if ((i == 0) && (masked[0] & TIMER_MASK))
			mask |= TIMER_MASK;
#endif
		/* Block all the IRQs */
		REG_WR_INT_VECT(intr_vect, irq_regs[cpu], rw_mask, i, mask);

	/* Check for timer IRQ and handle it special. */
#ifdef TIMER_VECT1
		if ((i == 1) && (masked[i] & TIMER_MASK)) {
			masked[i] &= ~TIMER_MASK;
			do_IRQ(TIMER0_INTR_VECT, regs);
		}
#else
		if ((i == 0) && (masked[i] & TIMER_MASK)) {
			 masked[i] &= ~TIMER_MASK;
			 do_IRQ(TIMER0_INTR_VECT, regs);
		}
	}
#endif

.....

Here, the last #endif is at the wrong place. It has to be before the bracket is closed. This is the corrected version:

#ifdef TIMER_VECT1
		if ((i == 1) && (masked[i] & TIMER_MASK)) {
			masked[i] &= ~TIMER_MASK;
			do_IRQ(TIMER0_INTR_VECT, regs);
		}
#else
		if ((i == 0) && (masked[i] & TIMER_MASK)) {
			 masked[i] &= ~TIMER_MASK;
			 do_IRQ(TIMER0_INTR_VECT, regs);
		}
#endif
	}


Best regards

Martin Ettl
Comment 1 Jesper Nilsson 2009-06-11 19:21:16 UTC
Fixed in local repository and will be pushed in the next merge window.