From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id EC5422BA8 for ; Tue, 31 May 2016 16:50:13 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP; 31 May 2016 07:50:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,395,1459839600"; d="scan'208";a="113470954" Received: from irsmsx154.ger.corp.intel.com ([163.33.192.96]) by fmsmga004.fm.intel.com with ESMTP; 31 May 2016 07:50:11 -0700 Received: from irsmsx109.ger.corp.intel.com ([169.254.13.193]) by IRSMSX154.ger.corp.intel.com ([169.254.12.28]) with mapi id 14.03.0248.002; Tue, 31 May 2016 15:50:11 +0100 From: "Pattan, Reshma" To: "Ananyev, Konstantin" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v4 6/9] app/pdump: add pdump tool for packet capturing Thread-Index: AQHRuCt/TPztRZeOMEGHgoZxdsWGfJ/TJf9w Date: Tue, 31 May 2016 14:50:09 +0000 Message-ID: <3AEA2BF9852C6F48A459DA490692831F01045487@IRSMSX109.ger.corp.intel.com> References: <1463503030-10318-1-git-send-email-reshma.pattan@intel.com> <1464039512-2683-1-git-send-email-reshma.pattan@intel.com> <1464039512-2683-7-git-send-email-reshma.pattan@intel.com> <2601191342CEEE43887BDE71AB97725836B6810D@irsmsx105.ger.corp.intel.com> In-Reply-To: <2601191342CEEE43887BDE71AB97725836B6810D@irsmsx105.ger.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZTZhYWU1MGQtZTBlYy00MmNkLTk4MmMtM2RiN2ViZDc4ZDdhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IkVGRkZCbzVhMlNRcnBUY0VGRytkZjBmNVcwUjAyU2pidWZyTUFDSCswMTQ9In0= x-ctpclassification: CTP_IC 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 v4 6/9] app/pdump: add pdump tool for packet capturing X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 May 2016 14:50:14 -0000 > -----Original Message----- > From: Ananyev, Konstantin > Sent: Friday, May 27, 2016 4:22 PM > To: Pattan, Reshma ; dev@dpdk.org > Cc: Pattan, Reshma > Subject: RE: [dpdk-dev] [PATCH v4 6/9] app/pdump: add pdump tool for pack= et > capturing >=20 >=20 > > +static int > > +parse_num_mbufs(const char *key __rte_unused, const char *value, void > > +*extra_args) { > > + int n; > > + struct pdump_tuples *pt =3D extra_args; > > + > > + n =3D atoi(value); > > + if (n > 1024) > > + pt->total_num_mbufs =3D (uint16_t) n; > > + else { > > + printf("total-num-mbufs %d invalid - must be > 1024\n", n); > > + return -1; > > + } > > + > > + return 0; > > +} >=20 >=20 > You have several parse functions - doing almost the same thing: > convert string to integer value and then check that this valu is within s= pecific > range. > Why not to introduce one function that would accept as extra_args pointer= to > the struct {uint64_t v; uint64_t min; uint64_t max; } So inside that func= tion you > can check that: v >=3D min && v < max or so. > Then you can use that function all over the places. > Another possibility just have parse function that only does conversion wi= thout > any boundary checking, and make boundary check later in parse_pdump(). > In both cases you can re-use same parse function. >=20 Yes, I do have 4 functions but in all I am not checking min and max values = and log message also differs in each=20 function. So I would like to retain this as it is now. =20 Thanks, Reshma