From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) by dpdk.org (Postfix) with ESMTP id C08542BA4 for ; Thu, 20 Apr 2017 10:54:28 +0200 (CEST) Received: by mail-wm0-f51.google.com with SMTP id m123so31236309wma.0 for ; Thu, 20 Apr 2017 01:54:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zretuo1OGixdlVRuJ9Xa6DwiZa2lXxyBgqUZpAJqMdY=; b=w3WWYFbdnir46y16mIC9ipJH+rRaDRs+JsQ77ZRwX0AhmYPsFyjeW1J6/LNJbPKeVt PCs6uRDmoVosiB/N9H/0M5fe7dqvpY/v1e+dy2Pooo4B/9ZbayVez+14D4e8kKVmUsRe 4Y0I13Vb4VliBMqy10+wnp8qNvyqsvUDH/cuad+SC8Snm2rOJyAA2E63sLANwpy47VKc awVMSegHvXn9Qdsv0MLruAz9LfkwlzDPo7926qaWsT/QA6PZxKzY86tSukI3tcot5dvR LUfL/GKV2WXTyVcjmThxx3ZOjZUvryGafHDlma5oLYz/pWIJivpZRT+NiiNJYV2RWNNP 7CGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zretuo1OGixdlVRuJ9Xa6DwiZa2lXxyBgqUZpAJqMdY=; b=hIPt31oGKMjupczV+OvwLQJ79bkxp/drAUuKu5BYXMMdDS8hL0Z5moXNsALrz7b3nm B93CRv21ouRSjw6laSABV/yQdHBmIdrU35jntbjUxUmmMmBGhzkSe+GzdniK4OeVcuoE 9x5+H4Cxg0WJrzh2Ci1VMVhusS04R0NKP+f5+LPz/nH3RbNgX3ZPoTCB9aIVETW8dctW 4NpJ+F4uMRJbryX6LSwIgNhkcLpscRMr4UqTNfE8DHnfEzmXPFMcyWeQ1D0UJaMlCOxg B9Uukwau6UPoExQtEUGfMQjx8XNkFt5+Gcm0r0dX7/r3gPFRYLiCe/w6XfMqEOVR3KZE 2hYg== X-Gm-Message-State: AN3rC/6YkOFuySxprzVPSN9682kM0p1Vk8WbBQpwrEAcoS2bUftnTj4o 1EUAGTwsEWqA0kCx8R8= X-Received: by 10.28.144.1 with SMTP id s1mr2017248wmd.27.1492678468299; Thu, 20 Apr 2017 01:54:28 -0700 (PDT) Received: from glumotte.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id f64sm7195925wmg.2.2017.04.20.01.54.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Apr 2017 01:54:28 -0700 (PDT) Date: Thu, 20 Apr 2017 10:54:55 +0200 From: Olivier MATZ To: "Lu, Wenzhuo" Cc: "dev@dpdk.org" Message-ID: <20170420105455.02ccc25f@glumotte.dev.6wind.com> In-Reply-To: <6A0DE07E22DDAD4C9103DF62FEBC09093B59B248@shsmsx102.ccr.corp.intel.com> References: <6A0DE07E22DDAD4C9103DF62FEBC09093B59B248@shsmsx102.ccr.corp.intel.com> X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] CLI parsing issue X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Apr 2017 08:54:29 -0000 Hi Wenzhuo, On Thu, 20 Apr 2017 08:36:38 +0000, "Lu, Wenzhuo" wrote: > Hi Olivier, > I met a problem thar the parsing result of CLI is wrong. > I checked this function, cmdline_parse. It will check the CLI instances one by one. Even if an instance is matched, the parsing will not stop for ambiguous check. Seems the following check may change the parsing result of the previous one, > /* fully parsed */ > tok = match_inst(inst, buf, 0, result.buf, sizeof(result.buf), > &dyn_tokens); > > > Is it better to use a temporary validate for match_inst and only store the result when it matches, so the previous result has no chance to be changed? Like bellow, > > > diff --git a/lib/librte_cmdline/cmdline_parse.c b/lib/librte_cmdline/cmdline_parse.c > index 763c286..663efd1 100644 > --- a/lib/librte_cmdline/cmdline_parse.c > +++ b/lib/librte_cmdline/cmdline_parse.c > @@ -259,6 +259,7 @@ > char buf[CMDLINE_PARSE_RESULT_BUFSIZE]; > long double align; /* strong alignment constraint for buf */ > } result; > + char tmp_buf[CMDLINE_PARSE_RESULT_BUFSIZE]; > cmdline_parse_token_hdr_t *dyn_tokens[CMDLINE_PARSE_DYNAMIC_TOKENS]; > void (*f)(void *, struct cmdline *, void *) = NULL; > void *data = NULL; > @@ -321,7 +322,7 @@ > debug_printf("INST %d\n", inst_num); > > /* fully parsed */ > - tok = match_inst(inst, buf, 0, result.buf, sizeof(result.buf), > + tok = match_inst(inst, buf, 0, tmp_buf, sizeof(tmp_buf), > &dyn_tokens); > > if (tok > 0) /* we matched at least one token */ > @@ -329,6 +330,8 @@ > > else if (!tok) { > debug_printf("INST fully parsed\n"); > + memcpy(result.buf, tmp_buf, > + CMDLINE_PARSE_RESULT_BUFSIZE); > /* skip spaces */ > while (isblank2(*curbuf)) { > curbuf++; > > At first glance, I think your patch doesn't hurt. Do you have an example code that triggers the issue? Thanks, Olivier