From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id B8AD81B53 for ; Wed, 9 Aug 2017 15:53:45 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga105.fm.intel.com with ESMTP; 09 Aug 2017 06:53:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,348,1498546800"; d="scan'208";a="121674117" Received: from irsmsx151.ger.corp.intel.com ([163.33.192.59]) by orsmga002.jf.intel.com with ESMTP; 09 Aug 2017 06:53:43 -0700 Received: from irsmsx103.ger.corp.intel.com ([169.254.3.185]) by IRSMSX151.ger.corp.intel.com ([169.254.4.191]) with mapi id 14.03.0319.002; Wed, 9 Aug 2017 14:53:42 +0100 From: "Ananyev, Konstantin" To: "Wiles, Keith" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] kvargs: return error if key not find in kvlist Thread-Index: AQHTERWGz4HbnCU5IkyYsAipwmIJtKJ8C1tg Date: Wed, 9 Aug 2017 13:53:41 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258489AB211@IRSMSX103.ger.corp.intel.com> References: <20170809133004.3307-1-keith.wiles@intel.com> In-Reply-To: <20170809133004.3307-1-keith.wiles@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] kvargs: return error if key not find in kvlist X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Aug 2017 13:53:46 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Keith Wiles > Sent: Wednesday, August 9, 2017 4:30 PM > To: dev@dpdk.org > Subject: [dpdk-dev] [PATCH] kvargs: return error if key not find in kvlis= t >=20 > rte_kvargs_process() should return error if the key > is not found in the kvlist or kvlist is NULL. Looks like an API breakage for me... Could you probably explain why do you think it is necessary? Konstantin >=20 > Minor documentation changes and update for when an > error is returned. >=20 > Signed-off-by: Keith Wiles > --- > lib/librte_kvargs/rte_kvargs.c | 7 ++++--- > lib/librte_kvargs/rte_kvargs.h | 7 ++++--- > 2 files changed, 8 insertions(+), 6 deletions(-) >=20 > diff --git a/lib/librte_kvargs/rte_kvargs.c b/lib/librte_kvargs/rte_kvarg= s.c > index 854ac83f5..c8e8f4b28 100755 > --- a/lib/librte_kvargs/rte_kvargs.c > +++ b/lib/librte_kvargs/rte_kvargs.c > @@ -158,16 +158,17 @@ rte_kvargs_process(const struct rte_kvargs *kvlist, > void *opaque_arg) > { > const struct rte_kvargs_pair *pair; > - unsigned i; > + unsigned int i, found =3D 0; >=20 > for (i =3D 0; i < kvlist->count; i++) { > pair =3D &kvlist->pairs[i]; > - if (key_match =3D=3D NULL || strcmp(pair->key, key_match) =3D=3D 0) { > + if (!key_match || strcmp(pair->key, key_match) =3D=3D 0) { > + found++; > if ((*handler)(pair->key, pair->value, opaque_arg) < 0) > return -1; > } > } > - return 0; > + return (!found) ? -1 : 0; > } >=20 > /* free the rte_kvargs structure */ > diff --git a/lib/librte_kvargs/rte_kvargs.h b/lib/librte_kvargs/rte_kvarg= s.h > index 5821c726a..260d4db5b 100755 > --- a/lib/librte_kvargs/rte_kvargs.h > +++ b/lib/librte_kvargs/rte_kvargs.h > @@ -115,9 +115,9 @@ void rte_kvargs_free(struct rte_kvargs *kvlist); > * Call a handler function for each key/value matching the key > * > * For each key/value association that matches the given key, calls the > - * handler function with the for a given arg_name passing the value on t= he > + * handler function with the given arg_name passing the value in the > * dictionary for that key and a given extra argument. If *kvlist* is NU= LL > - * function does nothing. > + * function does nothing and returns error. > * > * @param kvlist > * The rte_kvargs structure > @@ -131,7 +131,8 @@ void rte_kvargs_free(struct rte_kvargs *kvlist); > * > * @return > * - 0 on success > - * - Negative on error > + * - Negative on error or > + * if *key_match* does not match an entry in *kvlist* > */ > int rte_kvargs_process(const struct rte_kvargs *kvlist, > const char *key_match, arg_handler_t handler, void *opaque_arg); > -- > 2.11.0