From mboxrd@z Thu Jan 1 00:00:00 1970 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) 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:references:mime-version :content-disposition:in-reply-to; bh=tvqPPFhJ9GwvosrkpTXHQ6UiiYf7JlMsRlfSvteHA8Y=; b=y2XQFRaet7cBEvJC7A16R1DyjevyGIQtLSjPp7AQ+pt9RjW5Yk49q2swhS6c+AM+ae y2tcqtI/xk6kyJpx0ZA2jTXCMI24A3Pu2smsyfLAt1R8QnHkREaHY2O1dK+s1WrdVGkR A/NyVyI5r+wQbOOwtzzL6hszlLfTqgw1GWFoFzQmoVSAL1h671pqG5nlqGOD9ohE/Lz/ cWWTPJiqIeLmxofGW6miYEhPXXwP7oH/FMiMQ2KQiTItMqbAagsUBT1M5RkAAgXoytFX ffHkhdrOjDZpzHBlDLoGA1A0TDoxzyTiIMv7mialpoalvf04XMWJJWPKlig/sBYYTuC+ dADQ== 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:references :mime-version:content-disposition:in-reply-to; bh=tvqPPFhJ9GwvosrkpTXHQ6UiiYf7JlMsRlfSvteHA8Y=; b=WqAcuQSsaI4z06QlkHvA11xiPK2/Dh+bp9Sfdl/BHcUOEKG/JNc1xVUn9KOujv33Sz GLzVtjSH8xmeaupAGHJQv5aaRrut8DTRNSxNlta7MY3d2qxCB7nBhGL+4IIl7+2R0olz LZNGtuiN3t/9Em8O0+w9fX7LswsAbNbUwELv39OBK5S5uSl1Qz0ePzH57al3zTGrZnxH j6SFmbi7isxHvzxdj5bvLuireeM6lmB32scFfKzCgvQxLI//cnYtDI0Kopae5B1nTuC9 q3rft7l77VWTBo+EPw5knaXKkukm/reXEE+BXabVvnIi+mm0cOnnsIg2tlyHyVNi7WvA eVjw== X-Gm-Message-State: AJaThX6fH/W6oxh2Gnkk04bVp4g4iyRuMDrgfA6Zu2RjnQipXXyD7XW1 bjuaYARJnLcVnmnitTUdOuy7UQ== X-Google-Smtp-Source: AGs4zMZ0Xduc2JxNqiS/nCE3qD9PbXRujmsB/mRhabkAu/9XZf4FrMlXuMtG4AZPC8RGIZC9+I9C/A== X-Received: by 10.223.187.7 with SMTP id r7mr25952238wrg.253.1512736059529; Fri, 08 Dec 2017 04:27:39 -0800 (PST) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id k14sm8875194wrc.90.2017.12.08.04.27.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Dec 2017 04:27:38 -0800 (PST) Date: Fri, 8 Dec 2017 13:27:26 +0100 From: Adrien Mazarguil To: Xueming Li , Wenzhuo Lu , Olivier MATZ Cc: dev@dpdk.org 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 Content-Disposition: inline In-Reply-To: <20171208070244.24094-1-xuemingl@mellanox.com> Subject: Re: [dpdk-dev] [PATCH v1] lib/cmdline: init parse result memory 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: Fri, 08 Dec 2017 12:27:40 -0000 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