Bug 13596

Summary: arch/mips/sibyte/common/cfe_console.c: Incorrect use of #ifdefs
Product: Platform Specific/Hardware Reporter: dvice_null
Component: MIPSAssignee: ralf
Status: CLOSED CODE_FIX    
Severity: normal CC: alan
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: Latest git: c277331d5fbaae5772ed19862feefa91f4e477d3 Subsystem:
Regression: No Bisected commit-id:

Description dvice_null 2009-06-21 20:39:03 UTC
In file arch/mips/sibyte/common/cfe_console.c

There is function:
static int cfe_console_setup(struct console *cons, char *str)
{
	char consdev[32];
	/* XXXKW think about interaction with 'console=' cmdline arg */
	/* If none of the console options are configured, the build will break. */
	if (cfe_getenv("BOOT_CONSOLE", consdev, 32) >= 0) {
#ifdef CONFIG_SERIAL_SB1250_DUART
		if (!strcmp(consdev, "uart0")) {
			setleds("u0cn");
		} else if (!strcmp(consdev, "uart1")) {
			setleds("u1cn");
#endif
#ifdef CONFIG_VGA_CONSOLE
		} else if (!strcmp(consdev, "pcconsole0")) {
			setleds("pccn");
#endif
		} else
			return -ENODEV;
	}
	return 0;
}

If CONFIG_SERIAL_SB1250_DUART is not defined, the code will be:
static int cfe_console_setup(struct console *cons, char *str)
{
	char consdev[32];
	/* XXXKW think about interaction with 'console=' cmdline arg */
	/* If none of the console options are configured, the build will break. */
	if (cfe_getenv("BOOT_CONSOLE", consdev, 32) >= 0) {
#ifdef CONFIG_VGA_CONSOLE
		} else if (!strcmp(consdev, "pcconsole0")) {
			setleds("pccn");
#endif
		} else
			return -ENODEV;
	}
	return 0;
}

As you can see, it won't even compile, because the "return 0; }" is left outside the function. 

This bug was found using Cppcheck: http://cppcheck.wiki.sourceforge.net/