]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit
ACPI / power: Avoid maybe-uninitialized warning
authorArnd Bergmann <arnd@arndb.de>
Wed, 19 Apr 2017 17:47:04 +0000 (19:47 +0200)
committerThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Fri, 5 May 2017 13:13:47 +0000 (10:13 -0300)
commita1738160d9ef2c1b8d533529394e8122353fd887
tree88721f230886c8398c4113b0fe0c40b0ad20f64e
parentb0a2ee43b99a4c45b007b786fb8139ed4c281ebc
ACPI / power: Avoid maybe-uninitialized warning

BugLink: http://bugs.launchpad.net/bugs/1687638
commit fe8c470ab87d90e4b5115902dd94eced7e3305c3 upstream.

gcc -O2 cannot always prove that the loop in acpi_power_get_inferred_state()
is enterered at least once, so it assumes that cur_state might not get
initialized:

drivers/acpi/power.c: In function 'acpi_power_get_inferred_state':
drivers/acpi/power.c:222:9: error: 'cur_state' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This sets the variable to zero at the start of the loop, to ensure that
there is well-defined behavior even for an empty list. This gets rid of
the warning.

The warning first showed up when the -Os flag got removed in a bug fix
patch in linux-4.11-rc5.

I would suggest merging this addon patch on top of that bug fix to avoid
introducing a new warning in the stable kernels.

Fixes: 61b79e16c68d (ACPI: Fix incompatibility with mcount-based function graph tracing)
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
drivers/acpi/power.c