From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 94DDA2BA3 for ; Fri, 4 Mar 2016 12:21:22 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 04 Mar 2016 03:21:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,535,1449561600"; d="scan'208";a="926742573" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 04 Mar 2016 03:21:20 -0800 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id u24BLJre028092; Fri, 4 Mar 2016 11:21:19 GMT Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id u24BLJDe022217; Fri, 4 Mar 2016 11:21:19 GMT Received: (from fyigit@localhost) by sivswdev02.ir.intel.com with id u24BLJS5022213; Fri, 4 Mar 2016 11:21:19 GMT From: Ferruh Yigit To: dev@dpdk.org Date: Fri, 4 Mar 2016 11:21:16 +0000 Message-Id: <1457090476-22179-1-git-send-email-ferruh.yigit@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1457024900-18245-2-git-send-email-ferruh.yigit@intel.com> References: <1457024900-18245-2-git-send-email-ferruh.yigit@intel.com> Subject: [dpdk-dev] [PATCH v2] 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: Fri, 04 Mar 2016 11:21:23 -0000 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..a3ad912 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 >= ARRAY_SIZE(info->mem)) return -EINVAL; addr = pci_resource_start(dev, pci_bar); @@ -357,7 +357,7 @@ igbuio_pci_setup_ioport(struct pci_dev *dev, struct uio_info *info, { unsigned long addr, len; - if (sizeof(info->port) / sizeof(info->port[0]) <= n) + if (n >= ARRAY_SIZE(info->port)) return -EINVAL; addr = pci_resource_start(dev, pci_bar); @@ -402,7 +402,7 @@ igbuio_setup_bars(struct pci_dev *dev, struct uio_info *info) iom = 0; iop = 0; - for (i = 0; i != sizeof(bar_names) / sizeof(bar_names[0]); i++) { + for (i = 0; i < ARRAY_SIZE(bar_names); i++) { if (pci_resource_len(dev, i) != 0 && pci_resource_start(dev, i) != 0) { flags = pci_resource_flags(dev, i); -- 2.5.0