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=f9d46ca40f0d7fb307486ce692e38bd5ae4b7f75;hpb=af75078fece3615088e561357c1e97603e43a5fe;p=dpdk.git diff --git a/lib/librte_cmdline/cmdline_parse.c b/lib/librte_cmdline/cmdline_parse.c index f9d46ca40f..03e0b5357a 100644 --- a/lib/librte_cmdline/cmdline_parse.c +++ b/lib/librte_cmdline/cmdline_parse.c @@ -30,7 +30,6 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * version: DPDK.L.1.2.3-3 */ /* @@ -125,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++; @@ -229,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 @@ -343,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)); @@ -424,6 +433,7 @@ cmdline_complete(struct cmdline *cl, const char *buf, int *state, } } next: + debug_printf("next\n"); inst_num ++; inst = ctx[inst_num]; }