From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941635AbcJYJ73 (ORCPT ); Tue, 25 Oct 2016 05:59:29 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:61328 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933920AbcJYJ70 (ORCPT ); Tue, 25 Oct 2016 05:59:26 -0400 From: Arnd Bergmann To: Dmitry Torokhov Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] Input: tca8418_keypad: hide gcc-4.9 -Wmaybe-uninitialized warning Date: Tue, 25 Oct 2016 11:59:22 +0200 Message-ID: <3580924.2eqYJQ5Dgh@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-34-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <20161024234513.GA15034@dtor-ws> References: <20161024153222.2738294-1-arnd@arndb.de> <20161024234513.GA15034@dtor-ws> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:VeYJ1keXcqAQ+n4ft3eW+SAMdUTVMeURE/OrsJ2HvSkLuvxBPkS TEuKk5HjxEKBC4XHKNCcQtHbySbkngr1nzFFHcnRSbHjyLdaQ/5jjTCCkNFWRsetNRzE3XF mKX7pTKVyjj19h+/KlDYPZMLdQ+M28vQhi1DGVShy6fUbHakwNbP/qiaUQdhpQkrsrHDYCJ fpe1/RUK1KFCqgfklK6Vw== X-UI-Out-Filterresults: notjunk:1;V01:K0:giTmi0n0RLY=:aaUxNFw1UfUm7MEsEZAbPY iHmgD60+HynYSOS0eGy/C+rnIYOHObAbeVStD4UQUaH1i/iBhPvuKY8cB+O9rMj5LC35esSbB MmWLDn911eUjdmjHH67OBWkosNEDmT8pKsdB+/R2KYQcuIXDln22qNtXY7L2i3kVT3+Ql201/ hBSa8nolucU0lRj9ZyjNKF0klGRkJ2/5WIpVTp8QNHZYuOEOnoBeJDvh3xFPWvKShLcFBvnU8 ji9aiJUxKqBlvRZOFV8JDrosdmpZlKBN31E1hxJW1o6F/96afm5mAdYHL4Dve8dupOz6UnI2O icQTP3A9Nt9CllaFfe5icXqDdRrFvztUx0JYLEkzc4j9YNIZCkmaRIMxNU6zl2G8PMYtgtiXX gYvTUoMX6ZJ1wOFDDYj9uQ2m/8HBYLKNtbi6hGKZ81xEp6uq5oIJpb8newdfqY3a1QPSiBPbY nMX7rMiRJjs4G5FsVcOtsyUG06kHzOd/t/KFkoy+J55yIk7TOSvPUJO4RccYcsVsoDKq+imDh i0U3A4cCyikT9p2SNtNrqykX4hfx/xFLrXiXHl/K8pICXuO0EtxBWSMVUDntGEDV5St4ukAz9 ZKpb1B7gc3VOXRG67vIAwWyXhyhqcHRSY+0jDwaxKHqigp5lVB6SWwIryPANE2JdxhIVIM8nc jfnSXLjCeiA/cbGRAuAGYBiURogA1NoA3ieeBR0sxYtuo4fvDza04Fei8fsQE5oRD/6+EN2ki 6k3te7u5oS7t08eC Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday, October 24, 2016 4:45:13 PM CEST Dmitry Torokhov wrote: > > diff --git a/drivers/input/keyboard/tca8418_keypad.c b/drivers/input/keyboard/tca8418_keypad.c > > index 9002298698fc..3048ef3e3e16 100644 > > --- a/drivers/input/keyboard/tca8418_keypad.c > > +++ b/drivers/input/keyboard/tca8418_keypad.c > > @@ -164,11 +164,18 @@ static void tca8418_read_keypad(struct tca8418_keypad *keypad_data) > > int error, col, row; > > u8 reg, state, code; > > > > - /* Initial read of the key event FIFO */ > > - error = tca8418_read_byte(keypad_data, REG_KEY_EVENT_A, ®); > > + do { > > + error = tca8418_read_byte(keypad_data, REG_KEY_EVENT_A, ®); > > + if (error < 0) { > > + dev_err(&keypad_data->client->dev, > > + "unable to read REG_KEY_EVENT_A\n"); > > + break; > > + } > > + > > + /* Assume that key code 0 signifies empty FIFO */ > > + if (reg <= 0) > > + break; > > I am unconvinced that this rearrangement fixes the issue for all older > GCCs. Can we simply do: > > u8 uninitialized_var(reg); > > and be done with it? Yes, that would work. However: - avoiding the fake intialization tends to produce better object code, as gcc actually knows what's going on - Linus doesn't like uninitialized_var() and would rather see it removed from the kernel - llvm produces warnings for uninitialized_var() I have checked gcc-4.6/4.7/4.8/4.9/5.x/6.x, and only gcc-4.9 produces the warning. 4.9 changed the detection for uninitialized variables significantly, which generally caused fewer false positives but unfortunately introduced a couple of new ones like this. Arnd