i40e: add ethertype filter
[dpdk.git] / lib / librte_kvargs / rte_kvargs.c
index c7f626f..8bc1e46 100644 (file)
@@ -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,8 +162,8 @@ 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 ((*handler)(pair->value, opaque_arg) < 0)
+               if (key_match == NULL || strcmp(pair->key, key_match) == 0) {
+                       if ((*handler)(pair->key, pair->value, opaque_arg) < 0)
                                return -1;
                }
        }