Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965514AbcJQWI7 (ORCPT ); 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 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 List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2232 Lines: 65 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(-) 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; } -- 2.9.0