diff mbox

[2/5] btrfs-progs: mkfs: Fix overwritten return value for mkfs

Message ID 20171018080054.25509-3-wqu@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Qu Wenruo Oct. 18, 2017, 8 a.m. UTC
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>
---
 mkfs/main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox

Patch

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) {