kvargs: make the NULL key to match all entries
[dpdk.git] / lib / librte_kvargs / rte_kvargs.c
index c41a016..a7586a3 100644 (file)
@@ -139,7 +139,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 +160,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;
                }