From patchwork Mon Apr 28 08:37:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 4075761 X-Patchwork-Delegate: dave@jikos.cz Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C2D7B9F485 for ; Mon, 28 Apr 2014 08:36:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E523C201F9 for ; Mon, 28 Apr 2014 08:36:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D1D43201D3 for ; Mon, 28 Apr 2014 08:36:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754001AbaD1Igd (ORCPT ); Mon, 28 Apr 2014 04:36:33 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:35500 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753944AbaD1Igb (ORCPT ); Mon, 28 Apr 2014 04:36:31 -0400 X-IronPort-AV: E=Sophos;i="4.97,942,1389715200"; d="scan'208";a="29819377" Received: from unknown (HELO edo.cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 28 Apr 2014 16:34:01 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (localhost.localdomain [127.0.0.1]) by edo.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s3S8aSlY001439 for ; Mon, 28 Apr 2014 16:36:28 +0800 Received: from adam-work.lan (10.167.226.24) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.146.2; Mon, 28 Apr 2014 16:36:33 +0800 From: Qu Wenruo To: Subject: [PATCH 2/2] btrfs-progs: Replace the overkill assert with normal error message. Date: Mon, 28 Apr 2014 16:37:30 +0800 Message-ID: <1398674250-9656-2-git-send-email-quwenruo@cn.fujitsu.com> X-Mailer: git-send-email 1.9.2 In-Reply-To: <1398674250-9656-1-git-send-email-quwenruo@cn.fujitsu.com> References: <1398674250-9656-1-git-send-email-quwenruo@cn.fujitsu.com> MIME-Version: 1.0 X-Originating-IP: [10.167.226.24] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);