From patchwork Thu Feb 8 21:04:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 10208029 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 389E960247 for ; Thu, 8 Feb 2018 21:04:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28D4F296B1 for ; Thu, 8 Feb 2018 21:04:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D6A2296B2; Thu, 8 Feb 2018 21:04:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 274EC296AF for ; Thu, 8 Feb 2018 21:04:33 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3186B222DE15A; Thu, 8 Feb 2018 12:58:48 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=vishal.l.verma@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id EB27F22361E6A for ; Thu, 8 Feb 2018 12:58:45 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Feb 2018 13:04:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,480,1511856000"; d="scan'208";a="202461219" Received: from vverma7-desk1.lm.intel.com ([10.232.112.218]) by fmsmga005.fm.intel.com with ESMTP; 08 Feb 2018 13:04:30 -0800 From: Vishal Verma To: Subject: [ndctl PATCH 1/4] ndctl, inject-error: error out for a non-existent namespace Date: Thu, 8 Feb 2018 14:04:25 -0700 Message-Id: <20180208210428.7285-1-vishal.l.verma@intel.com> X-Mailer: git-send-email 2.14.3 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP When an invalid namespace was specified, inject-error would simply walk through a loop trying to matching namespace, and at the end, exit out silently. This could make it look as though the operation had been successful, when in reality, nothing had been done. Fix to print a message, and exit with an ENXIO when this happens. Signed-off-by: Vishal Verma --- ndctl/inject-error.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ndctl/inject-error.c b/ndctl/inject-error.c index 9b9d821..efa9f92 100644 --- a/ndctl/inject-error.c +++ b/ndctl/inject-error.c @@ -338,7 +338,8 @@ static int do_inject(const char *namespace, struct ndctl_ctx *ctx) } } - return 0; + error("%s: no such namespace\n", namespace); + return rc; } int cmd_inject_error(int argc, const char **argv, void *ctx)