Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 904FD20347175 for ; Tue, 31 Oct 2017 12:22:35 -0700 (PDT) Date: Tue, 31 Oct 2017 13:24:13 -0600 From: Vishal Verma Subject: Re: [ndctl patch] dax_io: fix unknown parameter handling Message-ID: <20171031192412.GB5253@omniknight.lm.intel.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" To: Jeff Moyer Cc: linux-nvdimm@lists.01.org List-ID: On 10/20, Jeff Moyer wrote: > The for loop will not loop more than once due to the return statement. > What's more, the following code, which prints out the usage, also won't > run. Let's change this to look more like other commands. Print out > invalid options and then print out the usage. usage_with_options will > exit, so no need for a return there. > > Signed-off-by: Jeff Moyer Looks good, Reviewed-by: Vishal Verma > > diff --git a/daxctl/io.c b/daxctl/io.c > index 27e7463..2f8cb4a 100644 > --- a/daxctl/io.c > +++ b/daxctl/io.c > @@ -526,15 +526,11 @@ int cmd_io(int argc, const char **argv, void *daxctl_ctx) > struct ndctl_ctx *ndctl_ctx; > > argc = parse_options(argc, argv, options, u, 0); > - for (i = 0; i < argc; i++) { > + for (i = 0; i < argc; i++) > fail("Unknown parameter \"%s\"\n", argv[i]); > - return -EINVAL; > - } > > - if (argc) { > + if (argc) > usage_with_options(u, options); > - return 0; > - } > > if (!io.dev[0].parm_path && !io.dev[1].parm_path) { > usage_with_options(u, options); > _______________________________________________ > Linux-nvdimm mailing list > Linux-nvdimm@lists.01.org > https://lists.01.org/mailman/listinfo/linux-nvdimm _______________________________________________ Linux-nvdimm mailing list Linux-nvdimm@lists.01.org https://lists.01.org/mailman/listinfo/linux-nvdimm