From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 8E153293B for ; Thu, 3 Mar 2016 18:25:17 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 03 Mar 2016 09:25:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,532,1449561600"; d="scan'208";a="928959911" Received: from irsmsx109.ger.corp.intel.com ([163.33.3.23]) by fmsmga002.fm.intel.com with ESMTP; 03 Mar 2016 09:25:15 -0800 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.35]) by IRSMSX109.ger.corp.intel.com ([169.254.13.100]) with mapi id 14.03.0248.002; Thu, 3 Mar 2016 17:25:15 +0000 From: "Ananyev, Konstantin" To: "Yigit, Ferruh" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] igb_uio: use macros for array size calculation Thread-Index: AQHRdW9sm4r8BAUzEU2RUY12A12f5J9H93BA Date: Thu, 3 Mar 2016 17:25:14 +0000 Message-ID: <2601191342CEEE43887BDE71AB97725836B15FD6@irsmsx105.ger.corp.intel.com> References: <1457024900-18245-1-git-send-email-ferruh.yigit@intel.com> <1457024900-18245-2-git-send-email-ferruh.yigit@intel.com> In-Reply-To: <1457024900-18245-2-git-send-email-ferruh.yigit@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYzc1MTc0ODUtOGQ2Zi00ZGU2LWEzZmUtMWYxNTJhNWEwOGRhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6ImZJZE0zSUxqM1RTZHFSMk1pc212V2VxQlFZUFpOWDZZWFpuV21EUUNKWTQ9In0= x-ctpclassification: CTP_IC x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] igb_uio: use macros for array size calculation 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: Thu, 03 Mar 2016 17:25:18 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ferruh Yigit > Sent: Thursday, March 03, 2016 5:08 PM > To: dev@dpdk.org > Subject: [dpdk-dev] [PATCH] igb_uio: use macros for array size calculatio= n >=20 > Minor code cleanup. > Remove array size calculations and remove unnecessary assignment. >=20 > Signed-off-by: Ferruh Yigit > --- > lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) >=20 > diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c b/lib/librte_eal/l= inuxapp/igb_uio/igb_uio.c > index 3374e44..563c57b 100644 > --- a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c > +++ b/lib/librte_eal/linuxapp/igb_uio/igb_uio.c > @@ -58,7 +58,7 @@ struct rte_uio_pci_dev { > enum rte_intr_mode mode; > }; >=20 > -static char *intr_mode =3D NULL; > +static char *intr_mode; > static enum rte_intr_mode igbuio_intr_mode_preferred =3D RTE_INTR_MODE_M= SIX; >=20 > /* sriov sysfs */ > @@ -332,7 +332,7 @@ igbuio_pci_setup_iomem(struct pci_dev *dev, struct ui= o_info *info, > unsigned long addr, len; > void *internal_addr; >=20 > - if (sizeof(info->mem) / sizeof(info->mem[0]) <=3D n) > + if (n >=3D MAX_UIO_MAPS) Why using hardcoded value is better than sizeof()? As I can see below there is a macro ARRAY_SIZE, why not to use it here then= ? Konstantin > return -EINVAL; >=20 > addr =3D pci_resource_start(dev, pci_bar); > @@ -357,7 +357,7 @@ igbuio_pci_setup_ioport(struct pci_dev *dev, struct u= io_info *info, > { > unsigned long addr, len; >=20 > - if (sizeof(info->port) / sizeof(info->port[0]) <=3D n) > + if (n >=3D MAX_UIO_PORT_REGIONS) > return -EINVAL; >=20 > addr =3D pci_resource_start(dev, pci_bar); > @@ -402,7 +402,7 @@ igbuio_setup_bars(struct pci_dev *dev, struct uio_inf= o *info) > iom =3D 0; > iop =3D 0; >=20 > - for (i =3D 0; i !=3D sizeof(bar_names) / sizeof(bar_names[0]); i++) { > + for (i =3D 0; i < ARRAY_SIZE(bar_names); i++) { > if (pci_resource_len(dev, i) !=3D 0 && > pci_resource_start(dev, i) !=3D 0) { > flags =3D pci_resource_flags(dev, i); > -- > 2.5.0