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>
This commit is contained in:
parent
95418a30be
commit
38a901702f
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user