From patchwork Wed Nov 2 13:52:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101574 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp144560qge; Wed, 2 Nov 2016 06:53:32 -0700 (PDT) X-Received: by 10.99.227.81 with SMTP id o17mr5836026pgj.69.1478094812571; Wed, 02 Nov 2016 06:53:32 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i6si2672652pao.147.2016.11.02.06.53.32; Wed, 02 Nov 2016 06:53:32 -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 S1754295AbcKBNxX (ORCPT + 27 others); Wed, 2 Nov 2016 09:53:23 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:65475 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753425AbcKBNxW (ORCPT ); Wed, 2 Nov 2016 09:53:22 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue103) with ESMTPA (Nemesis) id 0MKcX1-1c3Ik41qLf-001wcu; Wed, 02 Nov 2016 14:52:31 +0100 From: Arnd Bergmann To: Jaegeuk Kim , Chao Yu Cc: Arnd Bergmann , Fan Li , Weichao Guo , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH] f2fs: hide a maybe-uninitialized warning Date: Wed, 2 Nov 2016 14:52:15 +0100 Message-Id: <20161102135226.2753644-1-arnd@arndb.de> X-Mailer: git-send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el-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org gcc is unsure about the use of last_ofs_in_node, which might happen without a prior initialization: fs/f2fs//git/arm-soc/fs/f2fs/data.c: In function ‘f2fs_map_blocks’: fs/f2fs/data.c:799:54: warning: ‘last_ofs_in_node’ may be used uninitialized in this function [-Wmaybe-uninitialized] if (prealloc && dn.ofs_in_node != last_ofs_in_node + 1) { As pointed out by Chao Yu, the code is actually correct as 'prealloc' is only set if the last_ofs_in_node has been set, the two always get updated together. This initializes last_ofs_in_node to dn.ofs_in_node for each new dnode at the start of the 'next_block' loop, which at that point is a correct initialization as well. I assume that compilers that correctly track the contents of the variables and do not warn about the condition also figure out that they can eliminate the extra assignment here. Fixes: 46008c6d4232 ("f2fs: support in batch multi blocks preallocation") Signed-off-by: Arnd Bergmann --- fs/f2fs/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.0 diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index a59ea8e60040..6f01aaddfce9 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -719,7 +719,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, } prealloc = 0; - ofs_in_node = dn.ofs_in_node; + last_ofs_in_node = ofs_in_node = dn.ofs_in_node; end_offset = ADDRS_PER_PAGE(dn.node_page, inode); next_block: