From: Thierry Reding <thierry.reding@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Carlo Caione <carlo@caione.org>,
Kevin Hilman <khilman@baylibre.com>,
Neil Armstrong <narmstrong@baylibre.com>,
linux-pwm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pwm: meson: handle unknown ID values
Date: Thu, 8 Sep 2016 11:23:54 +0200 [thread overview]
Message-ID: <20160908092354.GB24112@ulmo.ba.sec> (raw)
In-Reply-To: <20160906125106.1511562-1-arnd@arndb.de>
[-- Attachment #1: Type: text/plain, Size: 1723 bytes --]
On Tue, Sep 06, 2016 at 02:50:47PM +0200, Arnd Bergmann wrote:
> When building with -Wmaybe-uninitialized, we get a couple of harmless
> warnings about three functions in this new driver that don't look
> safe to the compiler:
>
> drivers/pwm/pwm-meson.c: In function 'meson_pwm_get_state':
> drivers/pwm/pwm-meson.c:355:26: error: 'mask' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> drivers/pwm/pwm-meson.c: In function 'meson_pwm_disable':
> drivers/pwm/pwm-meson.c:263:13: error: 'enable' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> drivers/pwm/pwm-meson.c: In function 'meson_pwm_apply':
> drivers/pwm/pwm-meson.c:231:13: error: 'clk_shift' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> drivers/pwm/pwm-meson.c:231:36: error: 'enable' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> drivers/pwm/pwm-meson.c:231:24: error: 'clk_enable' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> Specifically, if we have a device with an id other than 0 or 1,
> this would result in undefined behavior. This is currently not
> possible, but the compiler cannot be expected to know this.
>
> This patch adds a 'default' clause to let the compiler know
> what to do instead, which shuts up the warning and makes the
> code slightly more resiliant in case it gets extended to other
> identifiers.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/pwm/pwm-meson.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
Applied, though I left out the dummy assignment of state->enabled = 0
because that's dead code anyway.
Thanks,
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
next prev parent reply other threads:[~2016-09-08 9:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-06 12:50 [PATCH] pwm: meson: handle unknown ID values Arnd Bergmann
2016-09-06 12:55 ` Neil Armstrong
2016-09-08 9:23 ` Thierry Reding [this message]
2016-09-08 9:29 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160908092354.GB24112@ulmo.ba.sec \
--to=thierry.reding@gmail.com \
--cc=arnd@arndb.de \
--cc=carlo@caione.org \
--cc=khilman@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=narmstrong@baylibre.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).