Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752014AbdHALuq (ORCPT ); Tue, 1 Aug 2017 07:50:46 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:58262 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751368AbdHALuo (ORCPT ); Tue, 1 Aug 2017 07:50:44 -0400 From: Arnd Bergmann To: Ross Zwisler , Andrew Morton , Dan Williams Cc: Christoph Hellwig , Arnd Bergmann , Vishal Verma , Toshi Kani , Johannes Thumshirn , linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Subject: [PATCH] nvdimm: avoid bogus -Wmaybe-uninitialized warning Date: Tue, 1 Aug 2017 13:48:48 +0200 Message-Id: <20170801114926.1171418-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:NjYF2f4EZNvGf+qOG3PmLJNIe2epZwhM05PjoJ5rzYfFxjvqvOS vWH3uGIfXobvfFL9/u6RiIIrnb8bMvPYlSmzJf4EmnfOOXXgiHQYKevwTyNfiBRI7/DlC86 ITYbG3D2gPraBZ5t93YQbtZQrqanZf5bYNuXFjaNpgObEHk9FyELRx36IE+pJ8Yv4TLZr2G aVaaA48T4kS51FyQMYfdQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:JnNpq32LAt4=:KrQHbzU8qGqLiSVUWFFt2X 4eHzys45T+D82g5HldyCNjZo1qGv2KGZEeKGoFAf9DL1l5JK3mE2ZTRVwkpSKOCxXb9ptCdU9 2sy8yU0PfHfVpkh/zEdqaSUllGt3mtWVkXubP6VYzAxdJL9398WwgJapT5ESaxwED/lxiUvoM +RDqAJYABm2cMWw5TFropqYlYMqk1Ibilp+NiqOHEGxx+Vtg0nql7lsrszHkSCDVzXtyV5Vu/ doCt+lVVLFXz9+YzY0B9aNko3W+aYvQCl7UXSCHmJpluucbmBGWjpldlaGXoFJKMvuAKGP9ws EnEMqSczcmCxNfUhSBZF2xqbg7259hGYWsJeSmlfTcrxn+RoZzyK30ows6xaWYBieWAE1idYB qof5lST0p2CZzrteYLsCo++2ESG4YdOil5aDSso/hKVCxuqZr9e+29LBbOk7FzVeomIY0Buip nZj0Z/PN/JGiXfYuqXl2GVEA0fB2NR28d8VaYTAat+Dn/R7RxX9civep1t0zA1wzybRVqXfnt qqlH0C7mjPMt59NRpyXxLzlW79lbmm35MZXUHM9nLFHDbqRrskamVdDWXVFeCJI5PVDmFj7gS QwaR36qskjWUWLRiHVA2GkofYCGM5Qxr33TLi6RnkTSsvFIV5/MWPaWzqcMfsjc8zK0BoFxnz cyRGgIGAluQokV7lzqxo7p7R4kXYl6oHiUtAebUWttym67q6UPFv1aTTOizONop6PCwrELgDx VskjjRj5lse/RioGlGtYoD6zK+GBcteuAoE2Ig== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1870 Lines: 46 Removing the btt_rw_page/pmem_rw_page functions had a surprising side-effect of introducing a false-positive warning in another function, due to changed inlining decisions in gcc: In file included from drivers/nvdimm/pmem.c:36:0: drivers/nvdimm/pmem.c: In function 'pmem_make_request': drivers/nvdimm/nd.h:407:2: error: 'start' may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/nvdimm/pmem.c:174:16: note: 'start' was declared here In file included from drivers/nvdimm/btt.c:27:0: drivers/nvdimm/btt.c: In function 'btt_make_request': drivers/nvdimm/nd.h:407:2: error: 'start' may be used uninitialized in this function [-Werror=maybe-uninitialized] drivers/nvdimm/btt.c:1202:16: note: 'start' was declared here The problem is that gcc fails to track the value of the 'do_acct' variable here and has to read it back from stack, but it does remember that 'start' may be uninitialized sometimes. This shuts up the warning by making nd_iostat_start() always initialize the 'start' variable. In those cases that gcc successfully tracks the state of the variable, this will have no effect. Fixes: 503a5e89b1de ("drivers/nvdimm/btt.c: remove btt_rw_page()") Fixes: 58100d6e735e ("drivers/nvdimm/pmem.c: remove pmem_rw_page()") Signed-off-by: Arnd Bergmann --- drivers/nvdimm/nd.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h index e1b5715bd91f..64f79a156456 100644 --- a/drivers/nvdimm/nd.h +++ b/drivers/nvdimm/nd.h @@ -392,8 +392,10 @@ static inline bool nd_iostat_start(struct bio *bio, unsigned long *start) { struct gendisk *disk = bio->bi_bdev->bd_disk; - if (!blk_queue_io_stat(disk->queue)) + if (!blk_queue_io_stat(disk->queue)) { + *start = 0; return false; + } *start = jiffies; generic_start_io_acct(bio_data_dir(bio), -- 2.9.0