All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH 2/2] btrfs-progs: Replace the overkill assert with normal error message.
Date: Mon, 28 Apr 2014 16:37:30 +0800	[thread overview]
Message-ID: <1398674250-9656-2-git-send-email-quwenruo@cn.fujitsu.com> (raw)
In-Reply-To: <1398674250-9656-1-git-send-email-quwenruo@cn.fujitsu.com>

When 'btrfs replace status' encounters an unknown dev replace status, it
will cause an assert, which is somewhat overkilled and can be replaced
with a normal error message.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 cmds-replace.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/cmds-replace.c b/cmds-replace.c
index 645dc98..9eb981b 100644
--- a/cmds-replace.c
+++ b/cmds-replace.c
@@ -449,7 +449,10 @@ static int print_replace_status(int fd, const char *path, int once)
 			break;
 		default:
 			prevent_loop = 1;
-			assert(0);
+			fprintf(stderr,
+				"Unknown btrfs dev replace status:%llu",
+				status->replace_state);
+			ret = -EINVAL;
 			break;
 		}
 
@@ -459,9 +462,9 @@ static int print_replace_status(int fd, const char *path, int once)
 				(unsigned long long)status->num_write_errors,
 				(unsigned long long)
 				 status->num_uncorrectable_read_errors);
-		if (once || prevent_loop) {
+		if (once || prevent_loop || ret) {
 			printf("\n");
-			return 0;
+			return ret;
 		}
 
 		fflush(stdout);
-- 
1.9.2


      reply	other threads:[~2014-04-28  8:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-28  8:37 [PATCH 1/2] btrfs-progs: Improve the errno string about open_path_or_dev_mnt() Qu Wenruo
2014-04-28  8:37 ` Qu Wenruo [this message]

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=1398674250-9656-2-git-send-email-quwenruo@cn.fujitsu.com \
    --to=quwenruo@cn.fujitsu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.