On 3/3/2016 5:25 PM, Ananyev, Konstantin wrote:
> 
> 
>> -----Original Message-----
>> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Ferruh Yigit
>> Sent: Thursday, March 03, 2016 5:08 PM
>> To: dev at 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 <ferruh.yigit at intel.com>
>> ---
>>  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];

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?

Thanks,
ferruh

Reply via email to