From patchwork Thu Oct 19 05:41:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10016007 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DA4DE600CC for ; Thu, 19 Oct 2017 05:42:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD9BA28C51 for ; Thu, 19 Oct 2017 05:42:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C283428CB5; Thu, 19 Oct 2017 05:42:11 +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=-6.9 required=2.0 tests=BAYES_00,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 6F23828C51 for ; Thu, 19 Oct 2017 05:42:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751481AbdJSFmA (ORCPT ); Thu, 19 Oct 2017 01:42:00 -0400 Received: from victor.provo.novell.com ([137.65.250.26]:51063 "EHLO prv3-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751153AbdJSFmA (ORCPT ); Thu, 19 Oct 2017 01:42:00 -0400 Received: from adam-pc.lan (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (NOT encrypted); Wed, 18 Oct 2017 23:41:44 -0600 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz, nborisov@suse.com Subject: [PATCH v2 2/6] btrfs-progs: mkfs: Avoid positive return value from cleanup_temp_chunks Date: Thu, 19 Oct 2017 13:41:34 +0800 Message-Id: <20171019054138.13965-3-wqu@suse.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171019054138.13965-1-wqu@suse.com> References: <20171019054138.13965-1-wqu@suse.com> 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 Since we're calling btrfs_search_slot() the return value can be positive. However we just pass that return value out, causing undefined return value. This can cause mkfs return 1, which indicates something wrong. Fix it. Signed-off-by: Qu Wenruo --- mkfs/main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mkfs/main.c b/mkfs/main.c index 80e6089c37a1..9d53c6632b45 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -1350,6 +1350,9 @@ static int cleanup_temp_chunks(struct btrfs_fs_info *fs_info, ret = btrfs_search_slot(trans, root, &key, &path, 0, 0); if (ret < 0) goto out; + /* Don't pollute ret for >0 case */ + if (ret > 0) + ret = 0; btrfs_item_key_to_cpu(path.nodes[0], &found_key, path.slots[0]);