From: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>
To: "Yigit, Ferruh" <ferruh.yigit@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] igb_uio: use macros for array size calculation
Date: Thu, 3 Mar 2016 17:25:14 +0000 [thread overview]
Message-ID: <2601191342CEEE43887BDE71AB97725836B15FD6@irsmsx105.ger.corp.intel.com> (raw)
In-Reply-To: <1457024900-18245-2-git-send-email-ferruh.yigit@intel.com>
> -----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 <ferruh.yigit@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?
Konstantin
> 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 >= MAX_UIO_PORT_REGIONS)
> 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
next prev parent reply other threads:[~2016-03-03 17:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-03 17:08 [dpdk-dev] [PATCH] igb_uio: cast private data to correct struct type Ferruh Yigit
2016-03-03 17:08 ` [dpdk-dev] [PATCH] igb_uio: use macros for array size calculation Ferruh Yigit
2016-03-03 17:25 ` Ananyev, Konstantin [this message]
2016-03-03 17:34 ` Ferruh Yigit
2016-03-03 17:45 ` Ananyev, Konstantin
2016-03-03 18:16 ` Ferruh Yigit
2016-03-04 11:21 ` [dpdk-dev] [PATCH v2] " Ferruh Yigit
2016-03-04 11:43 ` Ananyev, Konstantin
2016-03-07 22:30 ` Thomas Monjalon
2016-03-04 13:17 ` [dpdk-dev] [PATCH] igb_uio: cast private data to correct struct type Ananyev, Konstantin
2016-03-07 22:29 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2601191342CEEE43887BDE71AB97725836B15FD6@irsmsx105.ger.corp.intel.com \
--to=konstantin.ananyev@intel.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).