X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2Flibrte_cmdline%2Fcmdline_parse.c;h=03e0b5357a131ea6a1920a366b3acdcb2e80754b;hb=69d22b8e668d4cbc6d3a5e2873551de5d44c3a45;hp=84076815be02f7bdc66186acf697eeabbc645aa0;hpb=dada9ef6edc59015b6674b5a95258787c71401b0;p=dpdk.git diff --git a/lib/librte_cmdline/cmdline_parse.c b/lib/librte_cmdline/cmdline_parse.c index 84076815be..03e0b5357a 100644 --- a/lib/librte_cmdline/cmdline_parse.c +++ b/lib/librte_cmdline/cmdline_parse.c @@ -124,7 +124,7 @@ nb_common_chars(const char * s1, const char * s2) { unsigned int i=0; - while (*s1==*s2 && *s1 && *s2) { + while (*s1==*s2 && *s1) { s1++; s2++; i++; @@ -228,11 +228,16 @@ cmdline_parse(struct cmdline *cl, const char * buf) int parse_it = 0; int err = CMDLINE_PARSE_NOMATCH; int tok; - cmdline_parse_ctx_t *ctx = cl->ctx; + cmdline_parse_ctx_t *ctx; #ifdef RTE_LIBRTE_CMDLINE_DEBUG char debug_buf[BUFSIZ]; #endif + if (!cl || !buf) + return CMDLINE_PARSE_BAD_ARGS; + + ctx = cl->ctx; + /* * - look if the buffer contains at least one line * - look if line contains only spaces or comments @@ -342,7 +347,12 @@ cmdline_complete(struct cmdline *cl, const char *buf, int *state, unsigned int nb_non_completable; int local_state = 0; const char *help_str; - cmdline_parse_ctx_t *ctx = cl->ctx; + cmdline_parse_ctx_t *ctx; + + if (!cl || !buf || !state || !dst) + return -1; + + ctx = cl->ctx; debug_printf("%s called\n", __func__); memset(&token_hdr, 0, sizeof(token_hdr)); @@ -423,6 +433,7 @@ cmdline_complete(struct cmdline *cl, const char *buf, int *state, } } next: + debug_printf("next\n"); inst_num ++; inst = ctx[inst_num]; }