summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorOlivier Matz <olivier.matz@6wind.com>2014-01-28 17:06:43 +0100
committerThomas Monjalon <thomas.monjalon@6wind.com>2014-02-04 15:41:08 +0100
commit786f82f284a7a4b380b4093280065e9a3cbb7683 (patch)
tree7193dc4552dd047f7a0d32f10c47a174ba697b8e /lib
parent760061ab7940c963d8fb7e7005298dd71ff5416d (diff)
downloaddpdk-786f82f284a7a4b380b4093280065e9a3cbb7683.zip
dpdk-786f82f284a7a4b380b4093280065e9a3cbb7683.tar.gz
dpdk-786f82f284a7a4b380b4093280065e9a3cbb7683.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')
-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