From patchwork Wed Apr 19 17:47:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9688489 X-Patchwork-Delegate: rjw@sisk.pl Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E278F602DC for ; Wed, 19 Apr 2017 17:47:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8A7F28354 for ; Wed, 19 Apr 2017 17:47:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD6AC283E2; Wed, 19 Apr 2017 17:47:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1041528387 for ; Wed, 19 Apr 2017 17:47:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S968753AbdDSRrn (ORCPT ); Wed, 19 Apr 2017 13:47:43 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:64188 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968699AbdDSRrm (ORCPT ); Wed, 19 Apr 2017 13:47:42 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0Lwisq-1bz1XL2WV6-016NPf; Wed, 19 Apr 2017 19:47:19 +0200 From: Arnd Bergmann To: "Rafael J. Wysocki" , Len Brown Cc: Arnd Bergmann , Paul Menzel , Josh Poimboeuf , Steven Rostedt , "Rafael J . Wysocki" , All applicable , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] ACPI: avoid maybe-uninitialized warning Date: Wed, 19 Apr 2017 19:47:04 +0200 Message-Id: <20170419174720.4110126-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:M0tBnrR1gujWR4mvWe22e1x0ayOqjnm9TSYfdE8xnnlWDFHoHIg NX7HBARflq8LRRc8v1H7Pe2E4qFK8xHV8ftLrHbquozmGj7bdxD3I+lEyXVrZ4kyD16hxrV f3Fnq2Yec58tggcf3SllwIAjjxep/P7ACl3jrJgmDy3Orb/8toIKcMbT9+3ixS1Xn8ptH2Y WKfiqTpAY79IAe28IEihg== X-UI-Out-Filterresults: notjunk:1; V01:K0:r1v9TKYoOnA=:n3e1R4tT1oXOIzAT/0oqNc RPkKujLeS6xsdAnCAD4rXih1NAeXmmx6WZHQXDT0847C5sz3mHZK0HbqpbKVZStvFiAD29Iol g/IzoUOYJpXZfGPP5a46Bam6GVX699aPj5wSbUPiXjhlMp7kIJEgTjlEMT9AMAaXrgQiIAK3U +wCaWCE9A+r0mesAhsHxc1Ttwe59wQsM4i6eEIgUT93I5Ub7/KAyfkKiXxS7qaWYtupb7/gFS fA0l/JpcV9AiatN5IkdEBNjf+6kqT+cjdfxozhRH6EevU10HPHZUT8BNFq8myidf/CXYSG5Kl VDqC7u3uwPDD7jqDfMCX4OHWSuYN1bV6S7ZR7GAGPPWgUJLiR3CaUkipyloVM6AxU9a1HXyFb 86l26BI0A6a7J5B5ywyP9pWDmH/FSXmvFVaRw3TeTEPONQBZk8Vwr+9muKhlFWOEC1xCt5Yf9 pBT5PgKKvtwBdYSjZqbeQ+CoTEweRCvXLWI+I5VLKXlKQdvKC0I9aJDgtVLN2Dc/vXZ9tJJXv 90DuUpCCTLC8NNy2h3m34+5kQbiH3VzzfzBs7Fdw7kLUdScUxJ3Xf6VcwyHfDqYV/0NsNv2oW mJo2R/ebXZJPIsdOSHIxrd5tU5NaVO1VWfeupq28QK0sqg1CZ1TmUbTQCdn+KL6rmYJaXzh88 BLuwMstEgC2ERw4fSkXaH1ksQ0CgNg6pJee4kRxF0v3qJma91SBe/pfF/qMDa8bIMUZg= Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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") Cc: Paul Menzel Cc: Josh Poimboeuf Cc: Steven Rostedt (VMware) Cc: Rafael J. Wysocki Cc: All applicable Signed-off-by: Arnd Bergmann --- drivers/acpi/power.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index fcd4ce6f78d5..1c2b846c5776 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c @@ -200,6 +200,7 @@ static int acpi_power_get_list_state(struct list_head *list, int *state) return -EINVAL; /* The state of the list is 'on' IFF all resources are 'on'. */ + cur_state = 0; list_for_each_entry(entry, list, node) { struct acpi_power_resource *resource = entry->resource; acpi_handle handle = resource->device.handle;