summaryrefslogtreecommitdiff
path: root/lib/librte_kvargs
diff options
context:
space:
mode:
authorOlivier Matz <olivier.matz@6wind.com>2014-01-28 17:06:43 +0100
committerDavid Marchand <david.marchand@6wind.com>2014-02-26 11:01:14 +0100
commit38a901702fdfde778d50b2f123c562a66c394f87 (patch)
tree475713ec569762ba5ce1266136861153c89b8476 /lib/librte_kvargs
parent95418a30be0d3f1495db702d44c50139742663fc (diff)
downloaddpdk-38a901702fdfde778d50b2f123c562a66c394f87.zip
dpdk-38a901702fdfde778d50b2f123c562a66c394f87.tar.gz
dpdk-38a901702fdfde778d50b2f123c562a66c394f87.tar.xz
kvargs: make the NULL key to match all entries
In rte_kvargs_process() and rte_kvargs_count(), if the key_match argument is NULL, process all entries. Signed-off-by: Olivier Matz <olivier.matz@6wind.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Diffstat (limited to 'lib/librte_kvargs')
-rw-r--r--lib/librte_kvargs/rte_kvargs.c4
-rw-r--r--lib/librte_kvargs/rte_kvargs.h5
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/librte_kvargs/rte_kvargs.c b/lib/librte_kvargs/rte_kvargs.c
index c41a016..a7586a3 100644
--- a/lib/librte_kvargs/rte_kvargs.c
+++ b/lib/librte_kvargs/rte_kvargs.c
@@ -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;
}
diff --git a/lib/librte_kvargs/rte_kvargs.h b/lib/librte_kvargs/rte_kvargs.h
index 94003e2..71c9630 100644
--- a/lib/librte_kvargs/rte_kvargs.h
+++ b/lib/librte_kvargs/rte_kvargs.h
@@ -120,7 +120,8 @@ void rte_kvargs_free(struct rte_kvargs *kvlist);
* @param kvlist
* The rte_kvargs structure
* @param key_match
- * The key on which the handler should be called
+ * The key on which the handler should be called, or NULL to process handler
+ * on all associations
* @param handler
* The function to call for each matching key
* @param opaque_arg
@@ -139,7 +140,7 @@ int rte_kvargs_process(const struct rte_kvargs *kvlist,
* @param kvlist
* The rte_kvargs structure
* @param key_match
- * The key that should match
+ * The key that should match, or NULL to count all associations
* @return
* The number of entries