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 <xuemi...@mellanox.com>
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