Bug 25022

Summary: [cppcheck] function returns not intialized variable in linux-2.6/arch/arm/mach-omap2/pm44xx.c
Product: Platform Specific/Hardware Reporter: Martin Ettl (ettl.martin)
Component: ARMAssignee: linux-arm-kernel (linux-arm-kernel)
Status: CLOSED CODE_FIX    
Severity: normal CC: alan, florian, menon.nishanth
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6-git head Subsystem:
Regression: No Bisected commit-id:

Description Martin Ettl 2010-12-16 21:00:42 UTC
during a check of the current git head of the linux kernel with the static code
analysis tool cppcheck (http://sourceforge.net/apps/mediawiki/cppcheck/index.php?title=Main_Page) the tool discovered a not initialized variable in linux-2.6/arch/arm/mach-omap2/pm44xx.c. This happens if the preprocessor command -DCONFIG_PM and -DCONFIG_SUSPEND is not set!


Here is the code snippet to illustrate:

static int __init omap4_pm_init(void)
{
	int ret;

	if (!cpu_is_omap44xx())
		return -ENODEV;

	pr_err("Power Management for TI OMAP4.\n");

#ifdef CONFIG_PM
	ret = pwrdm_for_each(pwrdms_setup, NULL);
	if (ret) {
		pr_err("Failed to setup powerdomains\n");
		goto err2;
	}
#endif

#ifdef CONFIG_SUSPEND
	suspend_set_ops(&omap_pm_ops);
#endif /* CONFIG_SUSPEND */

err2:
	return ret;
}


Best regards

Ettl Martin
Comment 1 Nishanth Menon 2011-03-13 03:40:32 UTC
posted patch - http://marc.info/?l=linux-omap&m=129998746402420&w=2
Comment 2 Florian Mickler 2011-05-30 08:09:24 UTC
A patch referencing this bug report has been merged in v3.0-rc1:

commit 34549009a1a48e9212508aa32a90281e682c52b1
Author: Nishanth Menon <nm@ti.com>
Date:   Wed Apr 27 06:13:05 2011 -0700

    OMAP4: PM: remove redundant #ifdef CONFIG_PM