From patchwork Wed Oct 18 08:00:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10013989 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 4868C60211 for ; Wed, 18 Oct 2017 08:01:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B7C328390 for ; Wed, 18 Oct 2017 08:01:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 302D128AF0; Wed, 18 Oct 2017 08:01:17 +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 61F5328AD1 for ; Wed, 18 Oct 2017 08:01:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936001AbdJRIBP (ORCPT ); Wed, 18 Oct 2017 04:01:15 -0400 Received: from victor.provo.novell.com ([137.65.250.26]:54412 "EHLO prv3-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935991AbdJRIBJ (ORCPT ); Wed, 18 Oct 2017 04:01:09 -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 02:00:59 -0600 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz Subject: [PATCH 2/5] btrfs-progs: mkfs: Fix overwritten return value for mkfs Date: Wed, 18 Oct 2017 16:00:51 +0800 Message-Id: <20171018080054.25509-3-wqu@suse.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171018080054.25509-1-wqu@suse.com> References: <20171018080054.25509-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 For mkfs failure, especially --rootdir errors like EPERM/ENOSPC, the out branch will overwrite return value, causing wrong status code. Signed-off-by: Qu Wenruo --- mkfs/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mkfs/main.c b/mkfs/main.c index 1b4cabc1ef90..5817f114c1a1 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -1423,6 +1423,7 @@ int main(int argc, char **argv) int zero_end = 1; int fd = -1; int ret; + int close_ret; int i; int mixed = 0; int nodesize_forced = 0; @@ -1938,9 +1939,9 @@ raid_groups: */ fs_info->finalize_on_close = 1; out: - ret = close_ctree(root); + close_ret = close_ctree(root); - if (!ret) { + if (!close_ret) { optind = saved_optind; dev_cnt = argc - optind; while (dev_cnt-- > 0) {