X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_kvargs%2Frte_kvargs.c;h=8d56abd4c8bee40be83c756730693c29ce09b156;hb=c52afa68d763;hp=c41a01688e1010e35ae728cbcd81a7e8ad32e021;hpb=95418a30be0d3f1495db702d44c50139742663fc;p=dpdk.git diff --git a/lib/librte_kvargs/rte_kvargs.c b/lib/librte_kvargs/rte_kvargs.c index c41a01688e..8d56abd4c8 100644 --- a/lib/librte_kvargs/rte_kvargs.c +++ b/lib/librte_kvargs/rte_kvargs.c @@ -48,7 +48,9 @@ static int rte_kvargs_tokenize(struct rte_kvargs *kvlist, const char *params) { unsigned i; - char *str, *ctx1, *ctx2; + char *str; + char *ctx1 = NULL; + char *ctx2 = NULL; /* Copy the const char *params to a modifiable string * to pass to rte_strsplit @@ -139,7 +141,7 @@ rte_kvargs_count(const struct rte_kvargs *kvlist, const char *key_match) ret = 0; for (i = 0; i < kvlist->count; i++) { pair = &kvlist->pairs[i]; - if (strcmp(pair->key, key_match) == 0) + if (key_match == NULL || strcmp(pair->key, key_match) == 0) ret++; } @@ -160,7 +162,7 @@ rte_kvargs_process(const struct rte_kvargs *kvlist, for (i = 0; i < kvlist->count; i++) { pair = &kvlist->pairs[i]; - if (strcmp(pair->key, key_match) == 0) { + if (key_match == NULL || strcmp(pair->key, key_match) == 0) { if ((*handler)(pair->key, pair->value, opaque_arg) < 0) return -1; } @@ -172,8 +174,10 @@ rte_kvargs_process(const struct rte_kvargs *kvlist, void rte_kvargs_free(struct rte_kvargs *kvlist) { - if (kvlist->str != NULL) - free(kvlist->str); + if (!kvlist) + return; + + free(kvlist->str); free(kvlist); }