From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 986DC2BA2 for ; Thu, 20 Apr 2017 10:36:43 +0200 (CEST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP; 20 Apr 2017 01:36:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,225,1488873600"; d="scan'208,217";a="79119442" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga004.jf.intel.com with ESMTP; 20 Apr 2017 01:36:42 -0700 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 20 Apr 2017 01:36:42 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 20 Apr 2017 01:36:41 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.246]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.193]) with mapi id 14.03.0319.002; Thu, 20 Apr 2017 16:36:39 +0800 From: "Lu, Wenzhuo" To: Olivier Matz CC: "dev@dpdk.org" Thread-Topic: CLI parsing issue Thread-Index: AdK5rZEyXVh4UIJASg6apLd75x49UA== Date: Thu, 20 Apr 2017 08:36:38 +0000 Message-ID: <6A0DE07E22DDAD4C9103DF62FEBC09093B59B248@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [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:36:44 -0000 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 ambi= guous check. Seems the following check may change the parsing result of the= previous one, /* fully parsed */ tok =3D 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/cmdlin= e_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 *) =3D NULL; void *data =3D NULL; @@ -321,7 +322,7 @@ debug_printf("INST %d\n", inst_num); /* fully parsed */ - tok =3D match_inst(inst, buf, 0, result.buf, sizeof(result.= buf), + tok =3D 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++; Best regards Wenzhuo Lu