public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Mark Harmstone <maharmstone@fb.com>
To: <linux-btrfs@vger.kernel.org>
Cc: Mark Harmstone <maharmstone@fb.com>
Subject: [PATCH] btrfs-progs: simplify mkfs_main cleanup
Date: Fri, 19 Jul 2024 16:46:43 +0100	[thread overview]
Message-ID: <20240719154649.4127040-1-maharmstone@fb.com> (raw)

mkfs_main is a main-like function, meaning that return and exit are
equivalent. Deduplicate code by adding a new out2 label.

Signed-off-by: Mark Harmstone <maharmstone@fb.com>
---
 mkfs/main.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/mkfs/main.c b/mkfs/main.c
index a69aa24b..5705acb6 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -1915,6 +1915,8 @@ out:
 	}
 
 	btrfs_close_all_devices();
+
+out2:
 	if (prepare_ctx) {
 		for (i = 0; i < device_count; i++)
 			close(prepare_ctx[i].fd);
@@ -1927,15 +1929,9 @@ out:
 	return !!ret;
 
 error:
-	if (prepare_ctx) {
-		for (i = 0; i < device_count; i++)
-			close(prepare_ctx[i].fd);
-	}
-	free(t_prepare);
-	free(prepare_ctx);
-	free(label);
-	free(source_dir);
-	exit(1);
+	ret = 1;
+	goto out2;
+
 success:
 	exit(0);
 }
-- 
2.44.2


             reply	other threads:[~2024-07-19 15:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-19 15:46 Mark Harmstone [this message]
2024-07-19 20:32 ` [PATCH] btrfs-progs: simplify mkfs_main cleanup Josef Bacik

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=20240719154649.4127040-1-maharmstone@fb.com \
    --to=maharmstone@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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