From patchwork Mon Oct 17 22:05:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101685 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp594585qge; Mon, 17 Oct 2016 15:09:02 -0700 (PDT) X-Received: by 10.66.83.98 with SMTP id p2mr34092985pay.54.1476742142309; Mon, 17 Oct 2016 15:09:02 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 14si29078158pga.306.2016.10.17.15.09.01; Mon, 17 Oct 2016 15:09:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965515AbcJQWI7 (ORCPT + 27 others); Mon, 17 Oct 2016 18:08:59 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:52994 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964817AbcJQWIz (ORCPT ); Mon, 17 Oct 2016 18:08:55 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue003) with ESMTPA (Nemesis) id 0Lr6Rz-1caHWN0yF1-00eguh; Tue, 18 Oct 2016 00:07:36 +0200 From: Arnd Bergmann To: Jan Kara Cc: Linus Torvalds , linux-kernel@vger.kernel.org, Arnd Bergmann , Christoph Hellwig , Dave Chinner , Ross Zwisler , Dave Chinner , Al Viro , Andrew Morton , Matthew Wilcox , Carlos Maiolino , linux-ext4@vger.kernel.org Subject: [PATCH 05/28] ext2: avoid bogus -Wmaybe-uninitialized warning Date: Tue, 18 Oct 2016 00:05:34 +0200 Message-Id: <20161017220557.1688282-5-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20161017220342.1627073-1-arnd@arndb.de> References: <20161017220342.1627073-1-arnd@arndb.de> X-Provags-ID: V03:K0:emJO/hNR/kszmUkYPEiOmbm6Y8BDlEcTXCC2c0SAXatpdSKQdsx GI2zrXwaG7gkv0RhBfTxVZ0+5RA4796NpoPBsjRP4mB6+e2LQZseMFmX+MRkwfBpo5qkG3L oroD25cADSZlZmeoc/bYJ+70uvSFuGzbum8Yx+v4pJ34yKeKfAK+djrB2upKkRjdBkPaXsi PojoSBUacv+XT+6v0d8cg== X-UI-Out-Filterresults: notjunk:1; V01:K0:UO/pltakBbs=:Ob2ey27sYG5wqTyi0SoAtF sJoSOOaZOdcPe31eozoJIGT+b3gHuPYxW1Qrl9E/9GtaODS6TDJ7w8XzRm/ih3CcyXtTKZkT3 WHy+oDuwmNYirNCD+bwvYeQBq4ZQn/SwKYtM56ZZCRgFJ2o28vZXpEN7Ogg7IjQroWxEo9KtK Wf08RTi0c/wvTX9cbEQV30f9eo+N2S+WlumDWDTq09tPpeZ4hJ/rxlDW+0rEup8QIqpZwsgQW qAVU02Fh2i3W1J/0E85G1UVCiLLTh9pL/Ob3CTIXgakSj8YB+4xWMULUY35ejytrmwDG+wuu6 FK8pDSJ19I0jzRg5rZvFHpffh/x1XpPFth88ADS9XyRcnyg3uC3KJdeqYeuObd9sJwue3lVxw Mhv8auUY1xhdE3baScQH06TTKK+Xt83TLV0FZUYd0Bn45s7e+jNVL2IQZu9LWvOHi6N8dxZAq Q5LRJnz6ACuJNQDf15N5JyDy3MqKqQsdZRXYx4utlEr6/qfaxwJl4mOfkLXo7bmsiHud8J40S 7TczeqVIER3dbNCKPqUgcKHIG/ygr//ZDU6Xy+E4V9i0rkvFE8PIYgtUFmsIdJfnaOVAUaXiF zHK/6OqNVlBnyCMbdAbt9ggkScWcEtVm4NnRaUW3sNrpMTCZ4JX+vt6nJ79qTT8vxCtPcTUUi LfI8SZtNZ9OjzurR6jZ8VFxlVGdIQoUkKZNnKJM4HxM9aOy3S7RZtLTQzLRxi5wc6oZA= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On ARM, we get this false-positive warning since the rework of the ext2_get_blocks interface: fs/ext2/inode.c: In function 'ext2_get_block': include/linux/buffer_head.h:340:16: error: 'bno' may be used uninitialized in this function [-Werror=maybe-uninitialized] The calling conventions for this function are rather complex, and it's not surprising that the compiler gets this wrong, I spent a long time trying to understand how it all fits together myself. This change to avoid the warning makes sure the compiler sees that we always set 'bno' pointer whenever we have a positive return code. The transformation is correct because we always arrive at the 'got_it' label with a positive count that gets used as the return value, while any branch to the 'cleanup' label has a negative or zero 'err'. Fixes: 6750ad71986d ("ext2: stop passing buffer_head to ext2_get_blocks") Signed-off-by: Arnd Bergmann Cc: Christoph Hellwig Cc: Dave Chinner --- fs/ext2/inode.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 2.9.0 diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index d831e24..41b8b44 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -622,7 +622,7 @@ static int ext2_get_blocks(struct inode *inode, u32 *bno, bool *new, bool *boundary, int create) { - int err = -EIO; + int err; int offsets[4]; Indirect chain[4]; Indirect *partial; @@ -639,7 +639,7 @@ static int ext2_get_blocks(struct inode *inode, depth = ext2_block_to_path(inode,iblock,offsets,&blocks_to_boundary); if (depth == 0) - return (err); + return -EIO; partial = ext2_get_branch(inode, depth, offsets, chain, &err); /* Simplest case - block found, no allocation needed */ @@ -761,7 +761,6 @@ static int ext2_get_blocks(struct inode *inode, ext2_splice_branch(inode, iblock, partial, indirect_blks, count); mutex_unlock(&ei->truncate_mutex); got_it: - *bno = le32_to_cpu(chain[depth-1].key); if (count > blocks_to_boundary) *boundary = true; err = count; @@ -772,6 +771,8 @@ static int ext2_get_blocks(struct inode *inode, brelse(partial->bh); partial--; } + if (err > 0) + *bno = le32_to_cpu(chain[depth-1].key); return err; }