From mboxrd@z Thu Jan 1 00:00:00 1970 From: Adrien Mazarguil Subject: Re: [PATCH v1] lib/cmdline: init parse result memory Date: Fri, 8 Dec 2017 13:27:26 +0100 Message-ID: <20171208122726.GT4062@6wind.com> References: <20171115155402.9967-1-xuemingl@mellanox.com> <20171208070244.24094-1-xuemingl@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: dev@dpdk.org To: Xueming Li , Wenzhuo Lu , Olivier MATZ Return-path: Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by dpdk.org (Postfix) with ESMTP id E2E9F9B6B for ; Fri, 8 Dec 2017 13:27:39 +0100 (CET) Received: by mail-wr0-f193.google.com with SMTP id v105so10676879wrc.3 for ; Fri, 08 Dec 2017 04:27:39 -0800 (PST) Content-Disposition: inline In-Reply-To: <20171208070244.24094-1-xuemingl@mellanox.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Fri, Dec 08, 2017 at 03:02:44PM +0800, Xueming Li wrote: > Initialize binary result memory before parsing to avoid garbage in > parsing result. > > Signed-off-by: Xueming Li Since you chose to move the break statement, maybe the original commit mentioned in my previous message (9b3fbb051d2e "cmdline: fix parsing") can be reverted afterward? I think it makes tmp_result redundant. Wenzhuo, as the author of that commit, can you confirm? Olivier, no problem with breaking the loop immediately after the first successful match_inst() call instead of the last one? (I don't see why it would be an issue but I may have missed something) > --- > lib/librte_cmdline/cmdline_parse.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_cmdline/cmdline_parse.c b/lib/librte_cmdline/cmdline_parse.c > index 3e12ee54f..4072103f2 100644 > --- a/lib/librte_cmdline/cmdline_parse.c > +++ b/lib/librte_cmdline/cmdline_parse.c > @@ -168,6 +168,9 @@ match_inst(cmdline_parse_inst_t *inst, const char *buf, > int n = 0; > struct cmdline_token_hdr token_hdr; > > + if (resbuf != NULL) > + memset(resbuf, 0, resbuf_size); > + > /* check if we match all tokens of inst */ > while (!nb_match_token || i < nb_match_token) { > token_p = get_token(inst, i); > @@ -338,8 +341,8 @@ cmdline_parse(struct cmdline *cl, const char * buf) > err = CMDLINE_PARSE_AMBIGUOUS; > f=NULL; > debug_printf("Ambiguous cmd\n"); > - break; > } > + break; > } > } > > -- > 2.13.3 > -- Adrien Mazarguil 6WIND