linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.cz, nborisov@suse.com
Subject: [PATCH v2 3/6] btrfs-progs: mkfs: Fix overwritten return value for mkfs
Date: Thu, 19 Oct 2017 13:41:35 +0800	[thread overview]
Message-ID: <20171019054138.13965-4-wqu@suse.com> (raw)
In-Reply-To: <20171019054138.13965-1-wqu@suse.com>

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 <wqu@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
---
 mkfs/main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mkfs/main.c b/mkfs/main.c
index 9d53c6632b45..60250c011ac3 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -1426,6 +1426,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;
@@ -1944,9 +1945,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) {
-- 
2.14.2


  parent reply	other threads:[~2017-10-19  5:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-19  5:41 [PATCH v2 0/6] Rootdir refactor and small bug fixes Qu Wenruo
2017-10-19  5:41 ` [PATCH v2 1/6] btrfs-progs: Avoid BUG_ON for chunk allocation when ENOSPC happens Qu Wenruo
2017-10-19  5:41 ` [PATCH v2 2/6] btrfs-progs: mkfs: Avoid positive return value from cleanup_temp_chunks Qu Wenruo
2017-10-19  5:41 ` Qu Wenruo [this message]
2017-10-19  5:41 ` [PATCH v2 4/6] btrfs-progs: mkfs: Error out gracefully for --rootdir Qu Wenruo
2017-10-19  5:41 ` [PATCH v2 5/6] btrfs-progs: mkfs: Move image creation of rootdir to its own files Qu Wenruo
2017-10-26 17:05   ` David Sterba
2017-10-19  5:41 ` [PATCH v2 6/6] btrfs-progs: mkfs: Move source dir size calculation " Qu Wenruo
2017-10-26 17:13 ` [PATCH v2 0/6] Rootdir refactor and small bug fixes David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171019054138.13965-4-wqu@suse.com \
    --to=wqu@suse.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).