From patchwork Fri Nov 16 07:54:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10685589 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 62BEB14E2 for ; Fri, 16 Nov 2018 07:54:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 572F42D41D for ; Fri, 16 Nov 2018 07:54:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4BF542D427; Fri, 16 Nov 2018 07:54:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 075892D41D for ; Fri, 16 Nov 2018 07:54:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389417AbeKPSGA (ORCPT ); Fri, 16 Nov 2018 13:06:00 -0500 Received: from mx2.suse.de ([195.135.220.15]:46204 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727380AbeKPSGA (ORCPT ); Fri, 16 Nov 2018 13:06:00 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6D589ABDC for ; Fri, 16 Nov 2018 07:54:44 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH 7/9] btrfs-progs: Fix Wmaybe-uninitialized warning Date: Fri, 16 Nov 2018 15:54:24 +0800 Message-Id: <20181116075426.4142-8-wqu@suse.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181116075426.4142-1-wqu@suse.com> References: <20181116075426.4142-1-wqu@suse.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The only location is the following code: int level = path->lowest_level + 1; BUG_ON(path->lowest_level + 1 >= BTRFS_MAX_LEVEL); while(level < BTRFS_MAX_LEVEL) { slot = path->slots[level] + 1; ... } path->slots[level] = slot; Again, it's the stupid compiler needs some hint for the fact that we will always enter the while loop for at least once, thus @slot should always be initialized. Fix it by assign level after the BUG_ON(), so the stupid compiler knows we will always go into the while loop. Signed-off-by: Qu Wenruo Reviewed-by: Nikolay Borisov --- ctree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ctree.c b/ctree.c index 46e2ccedc0bf..9c9cb0dfdbf2 100644 --- a/ctree.c +++ b/ctree.c @@ -2961,11 +2961,12 @@ int btrfs_next_sibling_tree_block(struct btrfs_fs_info *fs_info, struct btrfs_path *path) { int slot; - int level = path->lowest_level + 1; + int level; struct extent_buffer *c; struct extent_buffer *next = NULL; BUG_ON(path->lowest_level + 1 >= BTRFS_MAX_LEVEL); + level = path->lowest_level + 1; while(level < BTRFS_MAX_LEVEL) { if (!path->nodes[level]) return 1;