From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id E342929CF for ; Thu, 3 Mar 2016 19:16:56 +0100 (CET) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP; 03 Mar 2016 10:16:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,532,1449561600"; d="scan'208";a="59293981" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.237.220.130]) ([10.237.220.130]) by fmsmga004.fm.intel.com with ESMTP; 03 Mar 2016 10:16:44 -0800 To: "Ananyev, Konstantin" , "dev@dpdk.org" References: <1457024900-18245-1-git-send-email-ferruh.yigit@intel.com> <1457024900-18245-2-git-send-email-ferruh.yigit@intel.com> <2601191342CEEE43887BDE71AB97725836B15FD6@irsmsx105.ger.corp.intel.com> <56D875C3.20507@intel.com> <2601191342CEEE43887BDE71AB97725836B16008@irsmsx105.ger.corp.intel.com> From: Ferruh Yigit X-Enigmail-Draft-Status: N1110 Message-ID: <56D87F8B.7000103@intel.com> Date: Thu, 3 Mar 2016 18:16:43 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <2601191342CEEE43887BDE71AB97725836B16008@irsmsx105.ger.corp.intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit 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 18:16:57 -0000 On 3/3/2016 5:45 PM, Ananyev, Konstantin wrote: > > >> -----Original Message----- >> From: Yigit, Ferruh >> Sent: Thursday, March 03, 2016 5:35 PM >> To: Ananyev, Konstantin; dev@dpdk.org >> Subject: Re: [dpdk-dev] [PATCH] igb_uio: use macros for array size calculation >> >> On 3/3/2016 5:25 PM, Ananyev, Konstantin wrote: >>> >>> >>>> -----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 calculation >>>> >>>> Minor code cleanup. >>>> Remove array size calculations and remove unnecessary assignment. >>>> >>>> Signed-off-by: Ferruh Yigit >>>> --- >>>> lib/librte_eal/linuxapp/igb_uio/igb_uio.c | 8 ++++---- >>>> 1 file changed, 4 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/lib/librte_eal/linuxapp/igb_uio/igb_uio.c b/lib/librte_eal/linuxapp/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; >>>> }; >>>> >>>> -static char *intr_mode = NULL; >>>> +static char *intr_mode; >>>> static enum rte_intr_mode igbuio_intr_mode_preferred = RTE_INTR_MODE_MSIX; >>>> >>>> /* sriov sysfs */ >>>> @@ -332,7 +332,7 @@ igbuio_pci_setup_iomem(struct pci_dev *dev, struct uio_info *info, >>>> unsigned long addr, len; >>>> void *internal_addr; >>>> >>>> - if (sizeof(info->mem) / sizeof(info->mem[0]) <= n) >>>> + if (n >= 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? >> >> Both are valid, but in uio (uio_driver.h) "mem" array defined as: >> struct uio_mem mem[MAX_UIO_MAPS]; > > Yep, so if both are valid, why to change it a the first place? :) > >> >> So we already know the size of the array, and it is exposed to us, why >> need to calculate. Is there any benefit of calculating it? > > if in future definition of the mem[] would change to let say: > struct uio_mem mem[X] > your code would still be valid, and no need to update it. Since it is the part of uio API, I expect this will remain same, otherwise igb_uio.c will already have problems because there is other piece of code that already rely on this information. But I don't have a strong opinion on one or other, I will update this to use ARRAY_SIZE() Thanks, ferruh