Bug 13596 - arch/mips/sibyte/common/cfe_console.c: Incorrect use of #ifdefs
arch/mips/sibyte/common/cfe_console.c: Incorrect use of #ifdefs
Status: CLOSED CODE_FIX
Product: Platform Specific/Hardware
Classification: Unclassified
Component: MIPS
All Linux
: P1 normal
Assigned To: ralf
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-06-21 20:39 UTC by dvice_null
Modified: 2012-06-08 15:38 UTC (History)
1 user (show)

See Also:
Kernel Version: Latest git: c277331d5fbaae5772ed19862feefa91f4e477d3
Tree: Mainline
Regression: No


Attachments

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/

Note You need to log in before you can comment on or make changes to this bug.