git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bonding: do not activate slave twice
[dpdk.git]
/
lib
/
librte_kvargs
/
rte_kvargs.c
diff --git
a/lib/librte_kvargs/rte_kvargs.c
b/lib/librte_kvargs/rte_kvargs.c
index
c7f626f
..
8d56abd
100644
(file)
--- a/
lib/librte_kvargs/rte_kvargs.c
+++ b/
lib/librte_kvargs/rte_kvargs.c
@@
-48,7
+48,9
@@
static int
rte_kvargs_tokenize(struct rte_kvargs *kvlist, const char *params)
{
unsigned i;
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
/* 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];
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++;
}
ret++;
}
@@
-160,8
+162,8
@@
rte_kvargs_process(const struct rte_kvargs *kvlist,
for (i = 0; i < kvlist->count; i++) {
pair = &kvlist->pairs[i];
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;
}
}
return -1;
}
}
@@
-172,8
+174,10
@@
rte_kvargs_process(const struct rte_kvargs *kvlist,
void
rte_kvargs_free(struct rte_kvargs *kvlist)
{
void
rte_kvargs_free(struct rte_kvargs *kvlist)
{
- if (kvlist->str != NULL)
- free(kvlist->str);
+ if (!kvlist)
+ return;
+
+ free(kvlist->str);
free(kvlist);
}
free(kvlist);
}