summaryrefslogtreecommitdiff
path: root/lib/librte_kvargs
diff options
context:
space:
mode:
authorThomas Monjalon <thomas@monjalon.net>2018-10-23 18:01:40 +0200
committerThomas Monjalon <thomas@monjalon.net>2018-10-24 15:06:46 +0200
commit25495407cbda028f7f6d5cce38f78e609cf970e1 (patch)
treed00ce5c63680bd177c97965921ef3880f2ccdf3d /lib/librte_kvargs
parent198b66b9461c01558d4fb474d1485d1312bf2650 (diff)
downloaddpdk-25495407cbda028f7f6d5cce38f78e609cf970e1.zip
dpdk-25495407cbda028f7f6d5cce38f78e609cf970e1.tar.gz
dpdk-25495407cbda028f7f6d5cce38f78e609cf970e1.tar.xz
kvargs: fix processing a null list
In the doxygen description of rte_kvargs_process(), it is said: If *kvlist* is NULL function does nothing. It has been added by mistake here instead of rte_kvargs_free(). Anyway, null list should be correctly handled in both functions. Comments are fixed in both functions and NULL handling is added to rte_kvargs_process(). Fixes: c34af7424e09 ("kvargs: fix freeing behaviour for null") Cc: stable@dpdk.org Signed-off-by: Thomas Monjalon <thomas@monjalon.net> Acked-by: Olivier Matz <olivier.matz@6wind.com>
Diffstat (limited to 'lib/librte_kvargs')
-rw-r--r--lib/librte_kvargs/rte_kvargs.c3
-rw-r--r--lib/librte_kvargs/rte_kvargs.h7
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/librte_kvargs/rte_kvargs.c b/lib/librte_kvargs/rte_kvargs.c
index a28f769..7ec1ea5 100644
--- a/lib/librte_kvargs/rte_kvargs.c
+++ b/lib/librte_kvargs/rte_kvargs.c
@@ -120,6 +120,9 @@ rte_kvargs_process(const struct rte_kvargs *kvlist,
const struct rte_kvargs_pair *pair;
unsigned i;
+ if (kvlist == NULL)
+ return 0;
+
for (i = 0; i < kvlist->count; i++) {
pair = &kvlist->pairs[i];
if (key_match == NULL || strcmp(pair->key, key_match) == 0) {
diff --git a/lib/librte_kvargs/rte_kvargs.h b/lib/librte_kvargs/rte_kvargs.h
index fc04195..1946195 100644
--- a/lib/librte_kvargs/rte_kvargs.h
+++ b/lib/librte_kvargs/rte_kvargs.h
@@ -110,7 +110,7 @@ struct rte_kvargs *rte_kvargs_parse_delim(const char *args,
* rte_kvargs_parse().
*
* @param kvlist
- * The rte_kvargs structure
+ * The rte_kvargs structure. No error if NULL.
*/
void rte_kvargs_free(struct rte_kvargs *kvlist);
@@ -119,11 +119,10 @@ void rte_kvargs_free(struct rte_kvargs *kvlist);
*
* For each key/value association that matches the given key, calls the
* handler function with the for a given arg_name passing the value on the
- * dictionary for that key and a given extra argument. If *kvlist* is NULL
- * function does nothing.
+ * dictionary for that key and a given extra argument.
*
* @param kvlist
- * The rte_kvargs structure
+ * The rte_kvargs structure. No error if NULL.
* @param key_match
* The key on which the handler should be called, or NULL to process handler
* on all associations