Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759377AbcJRJ5h (ORCPT ); Tue, 18 Oct 2016 05:57:37 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:33500 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752313AbcJRJ5f (ORCPT ); Tue, 18 Oct 2016 05:57:35 -0400 MIME-Version: 1.0 In-Reply-To: <20161017221037.1781185-2-arnd@arndb.de> References: <20161017220342.1627073-1-arnd@arndb.de> <20161017221037.1781185-2-arnd@arndb.de> From: Ilya Dryomov Date: Tue, 18 Oct 2016 11:57:33 +0200 Message-ID: Subject: Re: [PATCH 11/28] block: rdb: false-postive gcc-4.9 -Wmaybe-uninitialized To: Arnd Bergmann Cc: Sage Weil , Linus Torvalds , "linux-kernel@vger.kernel.org" , Alex Elder , Mike Christie , Ceph Development Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id u9I9veLe009367 Content-Length: 1737 Lines: 50 On Tue, Oct 18, 2016 at 12:10 AM, Arnd Bergmann wrote: > When building with gcc-4.9 -Wmaybe-uninitialized, we get a bogus > warning in rbd_watch_cb, as the variable is not used at all > in the one case in which it is not initialized first: > > drivers/block/rbd.c: In function ‘rbd_watch_cb’: > drivers/block/rbd.c:3690:5: error: ‘struct_v’ may be used uninitialized in this function [-Werror=maybe-uninitialized] > drivers/block/rbd.c:3759:5: note: ‘struct_v’ was declared here > > Later compiler versions fix this, but adding another initialization > here is harmless and lets us build cleanly with 4.9 as well. > > Signed-off-by: Arnd Bergmann > --- > drivers/block/rbd.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c > index abb7162..4ab990b 100644 > --- a/drivers/block/rbd.c > +++ b/drivers/block/rbd.c > @@ -3776,6 +3776,7 @@ static void rbd_watch_cb(void *arg, u64 notify_id, u64 cookie, > } else { > /* legacy notification for header updates */ > notify_op = RBD_NOTIFY_OP_HEADER_UPDATE; > + struct_v = 0; > len = 0; > } It already got silenced by initializing at declaration in one of the downstream trees, so I'd rather we do @@ -3756,7 +3819,7 @@ static void rbd_watch_cb(void *arg, u64 notify_id, u64 cookie, struct rbd_device *rbd_dev = arg; void *p = data; void *const end = p + data_len; - u8 struct_v; + u8 struct_v = 0; u32 len; u32 notify_op; int ret; to reduce the churn. The "block" prefix is redundant and "rdb" should be "rbd" in the subject. Thanks, Ilya