From patchwork Thu Oct 27 15:32:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101585 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp688465qge; Thu, 27 Oct 2016 08:33:49 -0700 (PDT) X-Received: by 10.98.23.212 with SMTP id 203mr15579556pfx.21.1477582429580; Thu, 27 Oct 2016 08:33:49 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s63si8458745pfj.281.2016.10.27.08.33.49; Thu, 27 Oct 2016 08:33:49 -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 S1034156AbcJ0Pdq (ORCPT + 27 others); Thu, 27 Oct 2016 11:33:46 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:52797 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030284AbcJ0Pdh (ORCPT ); Thu, 27 Oct 2016 11:33:37 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue005) with ESMTPA (Nemesis) id 0Lu05i-1d0AHs1HF8-011Q7U; Thu, 27 Oct 2016 17:32:58 +0200 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 v2] f2fs: replace a build-time warning with runtime WARN_ON Date: Thu, 27 Oct 2016 17:32:50 +0200 Message-Id: <20161027153256.4121871-1-arnd@arndb.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f67GwXtacDcuA Sender: linux-kernel-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(-) v2: use simpler workaround, as discussed with Chao Yu. -- 2.9.0 diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 68edb47f5f71..cf5ec39f907d 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -713,7 +713,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: