summaryrefslogtreecommitdiffstats
path: root/lib/librte_cmdline
diff options
context:
space:
mode:
authorLuca Boccassi <luca.boccassi@gmail.com>2018-03-07 11:22:30 +0000
committerLuca Boccassi <luca.boccassi@gmail.com>2018-03-07 11:23:17 +0000
commitc3f15def2ebe9cc255cf0e5cf32aa171f5b4326d (patch)
tree8c8fc77df57bca8c0bfe4d0e8797879e12c6d6f9 /lib/librte_cmdline
parent169a9de21e263aa6599cdc2d87a45ae158d9f509 (diff)
New upstream version 17.11.1upstream/17.11.1
Change-Id: Ida1700b5dac8649fc563670a37278e636bea051c Signed-off-by: Luca Boccassi <luca.boccassi@gmail.com>
Diffstat (limited to 'lib/librte_cmdline')
-rw-r--r--lib/librte_cmdline/cmdline_cirbuf.h2
-rw-r--r--lib/librte_cmdline/cmdline_parse.c10
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/librte_cmdline/cmdline_cirbuf.h b/lib/librte_cmdline/cmdline_cirbuf.h
index 6321dec5..87407efa 100644
--- a/lib/librte_cmdline/cmdline_cirbuf.h
+++ b/lib/librte_cmdline/cmdline_cirbuf.h
@@ -61,6 +61,8 @@
#ifndef _CIRBUF_H_
#define _CIRBUF_H_
+#include <rte_config.h>
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/lib/librte_cmdline/cmdline_parse.c b/lib/librte_cmdline/cmdline_parse.c
index 3e12ee54..7f799f94 100644
--- a/lib/librte_cmdline/cmdline_parse.c
+++ b/lib/librte_cmdline/cmdline_parse.c
@@ -168,6 +168,8 @@ 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);
@@ -263,6 +265,7 @@ cmdline_parse(struct cmdline *cl, const char * buf)
#ifdef RTE_LIBRTE_CMDLINE_DEBUG
char debug_buf[BUFSIZ];
#endif
+ char *result_buf = result.buf;
if (!cl || !buf)
return CMDLINE_PARSE_BAD_ARGS;
@@ -312,16 +315,14 @@ cmdline_parse(struct cmdline *cl, const char * buf)
debug_printf("INST %d\n", inst_num);
/* fully parsed */
- tok = match_inst(inst, buf, 0, tmp_result.buf,
- sizeof(tmp_result.buf));
+ tok = match_inst(inst, buf, 0, result_buf,
+ CMDLINE_PARSE_RESULT_BUFSIZE);
if (tok > 0) /* we matched at least one token */
err = CMDLINE_PARSE_BAD_ARGS;
else if (!tok) {
debug_printf("INST fully parsed\n");
- memcpy(&result, &tmp_result,
- sizeof(result));
/* skip spaces */
while (isblank2(*curbuf)) {
curbuf++;
@@ -332,6 +333,7 @@ cmdline_parse(struct cmdline *cl, const char * buf)
if (!f) {
memcpy(&f, &inst->f, sizeof(f));
memcpy(&data, &inst->data, sizeof(data));
+ result_buf = tmp_result.buf;
}
else {
/* more than 1 inst matches */