Bug 13596 - arch/mips/sibyte/common/cfe_console.c: Incorrect use of #ifdefs
Summary: arch/mips/sibyte/common/cfe_console.c: Incorrect use of #ifdefs
Status: CLOSED CODE_FIX
Alias: None
Product: Platform Specific/Hardware
Classification: Unclassified
Component: MIPS (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: ralf
URL:
Keywords:
Depends on:
Blocks:
 
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
Subsystem:
Regression: No
Bisected commit-id:


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.