From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757553AbcIHJa3 (ORCPT ); Thu, 8 Sep 2016 05:30:29 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:59136 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751957AbcIHJa1 (ORCPT ); Thu, 8 Sep 2016 05:30:27 -0400 From: Arnd Bergmann To: Thierry Reding Cc: Carlo Caione , Kevin Hilman , Neil Armstrong , 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, 08 Sep 2016 11:29:57 +0200 Message-ID: <7923222.muhSLJ29Um@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-34-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <20160908092354.GB24112@ulmo.ba.sec> References: <20160906125106.1511562-1-arnd@arndb.de> <20160908092354.GB24112@ulmo.ba.sec> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:TjzbfdsfXZf8WlI+2diZ4f+ZUoXRkS+//BcJyIinHZI6eKw7Fqp y3J9ahwUnGsPAh0DM4JOQoWPqW9NRX3oOuNCM10pXbHkCT9RXHBaa/6RlLoCCAhQ7JskSCG IK/aFtahVFHiO6ogV7/2aGlrj7aN5HEQOZT8o+647OjBTE+HxLtkvSJaB17Pe5S/ASF2cJe qdwAtPOQdNjw06JnAuwTg== X-UI-Out-Filterresults: notjunk:1;V01:K0:hV1/JXSYmqc=:l8uZa39GHcbBZ2W6LIfpr9 ajmsb9DOhI+kpHbmh3C2MQOGHNznbpXz43bKshCNbiubrcvphF0059TbGYv7ENmR/BbaGFrj+ hMZXBwIoCNJj1Dk8cX9nywkCcjF+ceQ5x7cj9qNyJCxh0bdkni0X8Igjcc6CqAFlFe6oYAfD0 Z0qDLRGCIWvvW421lY4laBBht1/Z5/vyXHzabqFqqIDZ4VtfqHttS9mjyFL1Nd9bFXu7yJ5+9 BoUjGCIWU6T9S4sgfwbgQqAvBUrDHqwQ22k12TF4z29rM7H/9T73gGi+T6Dj2NERMnyn+UmRO d2MNW605Icl57KjyOOPO+Ar/Hh59wYBmhNb1DRBkGjlNn8KIDhV1ehv+5I2raRFpb+OObeGpF vpj2C9e/laYleVo7++VkEainbgIFBUiGHQk55X1ebu8FWHb4W37RQHb1tV9Up0UsEE7UtFQpe oi/UVcziq0xm8Q7WrpJXzEE5zeioBFOFRrWpcBvNUTUhLtTy91k3nJErbSf3HRIOQ4yx2UTtI wLhST6IkongHSzNNpXbA4a007TIZY8WcS970X3ld9OAQiihYvdK4llXDoA6uWLeMgM+xgzGSv xdRZ5O/TeE3ZL6dbYAdjcgJz5XAapfgkzwFWor4SpVyBDCNKBy0vSunX364tQDzHVTLlIYwtG lnTj+G/hX+SK/UTBUp0mIu7g2en5E39hDUBzJEcExw+B0Kcuc0xCOWh7ayjtwZzeS/ZOfJ0B3 D0a9II1sEiDb8B1n Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday, September 8, 2016 11:23:54 AM CEST Thierry Reding wrote: > 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 > > --- > > 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. Sounds good. My first version had "break" instead of "return" there, so it required the assignment, but you are in the current version you are right that we are better off without it. Arnd