[dpdk-dev] [PATCH v4 3/5] kvargs: add get by key function

Xueming(Steven) Li xuemingl at nvidia.com
Mon Apr 12 14:07:13 CEST 2021



> -----Original Message-----
> From: Olivier Matz <olivier.matz at 6wind.com>
> Sent: Monday, April 12, 2021 2:53 PM
> To: Xueming(Steven) Li <xuemingl at nvidia.com>
> Cc: NBU-Contact-Thomas Monjalon <thomas at monjalon.net>; Gaetan Rivet <gaetanr at nvidia.com>; dev at dpdk.org; Asaf Penso
> <asafp at nvidia.com>; Ray Kinsella <mdr at ashroe.eu>; Neil Horman <nhorman at tuxdriver.com>
> Subject: Re: [PATCH v4 3/5] kvargs: add get by key function
> 
> Hi Xueming,
> 
> On Sat, Apr 10, 2021 at 02:23:55PM +0000, Xueming Li wrote:
> > Adds a new function to get value of a specific key from kvargs list.
> >
> > Signed-off-by: Xueming Li <xuemingl at nvidia.com>
> > Reviewed-by: Gaetan Rivet <grive at u256.net>
> > ---
> >  lib/librte_kvargs/rte_kvargs.c | 20 ++++++++++++++++++++
> > lib/librte_kvargs/rte_kvargs.h | 21 +++++++++++++++++++++
> > lib/librte_kvargs/version.map  |  3 +++
> >  3 files changed, 44 insertions(+)
> >
> > diff --git a/lib/librte_kvargs/rte_kvargs.c
> > b/lib/librte_kvargs/rte_kvargs.c index ffae8914cf..40e7670ab3 100644
> > --- a/lib/librte_kvargs/rte_kvargs.c
> > +++ b/lib/librte_kvargs/rte_kvargs.c
> > @@ -203,6 +203,26 @@ rte_kvargs_free(struct rte_kvargs *kvlist)
> >  	free(kvlist);
> >  }
> >
> > +/* Lookup a value in an rte_kvargs list by its key. */ const char *
> > +rte_kvargs_get(const struct rte_kvargs *kvlist, const char *key) {
> > +	unsigned int i;
> > +
> > +	if (!kvlist)
> > +		return NULL;
> > +	for (i = 0; i < kvlist->count; ++i) {
> > +		/* Allows key to be NULL. */
> > +		if (!key && !kvlist->pairs[i].key)
> > +			return kvlist->pairs[i].value;
> 
> Is it possible that kvlist->pairs[i].key == NULL? In which case?

Impossible, will remove this in next version, thanks.

> 
> 
> Thanks,
> Olivier


More information about the dev mailing list