[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACRpkdb-yw45j_4kV88LXipjfXK2eYgGwkqbzVOE9Lyb1gh7rg@mail.gmail.com>
Date: Thu, 28 Jan 2016 11:37:33 +0100
From: Linus Walleij <linus.walleij@...aro.org>
To: Arnd Bergmann <arnd@...db.de>
Cc: Lee Jones <lee.jones@...aro.org>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] mfd: db8500: avoid uninitialized variable reference
On Mon, Jan 25, 2016 at 5:02 PM, Arnd Bergmann <arnd@...db.de> wrote:
> The prcmu_config_clkout() function ensures that the 'clkout' argument
> can only be '0' or '1' using an appropriate BUG_ON(), so the compiler
> should know that the div_mask, mask, and bits variables are always
> initialized later on. However, it doesn't understand this in gcc-5.2
> and produces a false positive warning instead:
>
> drivers/mfd/db8500-prcmu.c: In function 'prcmu_config_clkout':
> drivers/mfd/db8500-prcmu.c:762:10: error: 'div_mask' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> if (val & div_mask) {
> ^
> drivers/mfd/db8500-prcmu.c:769:13: error: 'mask' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> if ((val & mask & ~div_mask) != bits) {
> ^
> drivers/mfd/db8500-prcmu.c:757:7: error: 'bits' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> Replacing the switch() statement with an equivalent if() lets
> gcc figure this out reliably and avoids the warnings.
>
> Signed-off-by: Arnd Bergmann <arnd@...db.de>
OK then..
Acked-by: Linus Walleij <linus.walleij@...aro.org>
Yours,
Linus Walleij
Powered by blists - more mailing lists