All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavan Nikhilesh Bhagavatula <pbhagavatula@marvell.com>
To: David Marchand <david.marchand@redhat.com>
Cc: Wenzhuo Lu <wenzhuo.lu@intel.com>,
	Jingjing Wu <jingjing.wu@intel.com>,
	Bernard Iremonger <bernard.iremonger@intel.com>,
	Olivier Matz <olivier.matz@6wind.com>,
	Bruce Richardson <bruce.richardson@intel.com>,
	Vladimir Medvedkin <vladimir.medvedkin@intel.com>,
	Anatoly Burakov <anatoly.burakov@intel.com>,
	Reshma Pattan <reshma.pattan@intel.com>,
	"Robert Sanford" <rsanford@akamai.com>,
	Erik Gabriel Carrillo <erik.g.carrillo@intel.com>,
	dev <dev@dpdk.org>
Subject: Re: [dpdk-dev] [EXT] Re: [PATCH 1/3] app: use RTE_DIM to calculate array size
Date: Thu, 7 Nov 2019 02:12:15 +0000	[thread overview]
Message-ID: <CY4PR1801MB18638285A93307E8657592A7DE780@CY4PR1801MB1863.namprd18.prod.outlook.com> (raw)
In-Reply-To: <CAJFAV8zb33F3G++FSSBGj1hEyNH=Y9punUvme=0dLzQBkAxPZg@mail.gmail.com>

>On Mon, Oct 28, 2019 at 10:09 AM <pbhagavatula@marvell.com> wrote:
>>
>> From: Pavan Nikhilesh <pbhagavatula@marvell.com>
>>
>> Use RTE_DIM macro to calculate array size
>>
>> Suggested-by: David Marchand <david.marchand@redhat.com>
>> Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
>
>Ah, I was not expecting this soon.
>Thanks for looking at it.
>
>
>> ---
>>  app/test-pmd/cmdline.c            |  2 +-
>>  app/test-pmd/icmpecho.c           |  2 +-
>>  app/test-pmd/testpmd.c            |  2 +-
>>  app/test/test.c                   |  2 +-
>>  app/test/test_cmdline_etheraddr.c | 10 +++-------
>>  app/test/test_cmdline_ipaddr.c    | 18 ++++++------------
>>  app/test/test_cmdline_num.c       | 16 +++++-----------
>>  app/test/test_cmdline_portlist.c  | 12 ++++--------
>>  app/test/test_cmdline_string.c    | 15 +++++----------
>>  app/test/test_debug.c             |  2 +-
>>  app/test/test_eal_flags.c         |  9 ++++-----
>>  app/test/test_errno.c             |  4 ++--
>>  app/test/test_lpm.c               |  2 +-
>>  app/test/test_lpm6.c              |  2 +-
>>  app/test/test_lpm6_data.h         |  3 +--
>>  app/test/test_malloc.c            |  2 +-
>>  app/test/test_memcpy.c            |  2 +-
>>  app/test/test_memcpy_perf.c       |  4 ++--
>>  app/test/test_mp_secondary.c      |  3 +--
>>  app/test/test_pdump.c             |  3 +--
>>  app/test/test_pmd_ring_perf.c     |  2 +-
>>  app/test/test_ring_perf.c         |  6 +++---
>>  app/test/test_timer_secondary.c   |  3 +--
>>  23 files changed, 48 insertions(+), 78 deletions(-)
>>
>> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
>> index 447806991..c6b4e44a2 100644
>> --- a/app/test-pmd/cmdline.c
>> +++ b/app/test-pmd/cmdline.c
>> @@ -5490,7 +5490,7 @@ cmd_show_bypass_config_parsed(void
>*parsed_result,
>>                 "OS/board off",
>>                 "power supply off",
>>                 "timeout"};
>> -       int num_events = (sizeof events) / (sizeof events[0]);
>> +       int num_events = RTE_DIM(events);
>>
>>         /* Display the bypass mode.*/
>>         if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode)
>!= 0) {
>> diff --git a/app/test-pmd/icmpecho.c b/app/test-pmd/icmpecho.c
>> index 2d359c943..65aece16c 100644
>> --- a/app/test-pmd/icmpecho.c
>> +++ b/app/test-pmd/icmpecho.c
>> @@ -188,7 +188,7 @@ ip_proto_name(uint16_t ip_proto)
>>                 "PIM",        /**< Protocol Independent Mcast */
>>         };
>>
>> -       if (ip_proto < sizeof(ip_proto_names) /
>sizeof(ip_proto_names[0]))
>> +       if (ip_proto < RTE_DIM(ip_proto_names))
>>                 return ip_proto_names[ip_proto];
>>         switch (ip_proto) {
>>  #ifdef IPPROTO_PGM
>> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
>> index 38acbc58a..1103db629 100644
>> --- a/app/test-pmd/testpmd.c
>> +++ b/app/test-pmd/testpmd.c
>> @@ -2584,7 +2584,7 @@ struct pmd_test_command {
>>         cmd_func_t cmd_func;
>>  };
>>
>> -#define PMD_TEST_CMD_NB (sizeof(pmd_test_menu) /
>sizeof(pmd_test_menu[0]))
>> +#define PMD_TEST_CMD_NB RTE_DIM(pmd_test_menu)
>
>This macro is just unused and can be shot.

Ill send v2 removing the macros. 

Thanks.
>
>
>>
>>  /* Check the link status of all ports in up to 9s, and print them finally
>*/
>>  static void
>> diff --git a/app/test/test.c b/app/test/test.c
>> index cd7aaf645..784535095 100644
>> --- a/app/test/test.c
>> +++ b/app/test/test.c
>> @@ -74,7 +74,7 @@ do_recursive_call(void)
>>
>>         if (recursive_call == NULL)
>>                 return -1;
>> -       for (i = 0; i < sizeof(actions)/sizeof(actions[0]); i++) {
>> +       for (i = 0; i < RTE_DIM(actions); i++) {
>>                 if (strcmp(actions[i].env_var, recursive_call) == 0)
>>                         return (actions[i].action_fn)();
>>         }
>> diff --git a/app/test/test_cmdline_etheraddr.c
>b/app/test/test_cmdline_etheraddr.c
>> index 9a32fd7ec..dc7fa944b 100644
>> --- a/app/test/test_cmdline_etheraddr.c
>> +++ b/app/test/test_cmdline_etheraddr.c
>> @@ -72,13 +72,9 @@ const char * ether_addr_invalid_strs[] = {
>>                 " ",
>>  };
>>
>> -#define ETHERADDR_VALID_STRS_SIZE \
>> -       (sizeof(ether_addr_valid_strs) /
>sizeof(ether_addr_valid_strs[0]))
>> -#define ETHERADDR_GARBAGE_STRS_SIZE \
>> -       (sizeof(ether_addr_garbage_strs) /
>sizeof(ether_addr_garbage_strs[0]))
>> -#define ETHERADDR_INVALID_STRS_SIZE \
>> -       (sizeof(ether_addr_invalid_strs) /
>sizeof(ether_addr_invalid_strs[0]))
>> -
>> +#define ETHERADDR_VALID_STRS_SIZE
>RTE_DIM(ether_addr_valid_strs)
>> +#define ETHERADDR_GARBAGE_STRS_SIZE
>RTE_DIM(ether_addr_garbage_strs)
>> +#define ETHERADDR_INVALID_STRS_SIZE
>RTE_DIM(ether_addr_invalid_strs)
>
>Those macros are just used once, in loops enumerating the array
>entries.
>Let's remove them and replace inline:
>
>        /* test full strings */
>-       for (i = 0; i < ETHERADDR_VALID_STRS_SIZE; i++) {
>+       for (i = 0; i < RTE_DIM(ether_addr_valid_strs); i++) {
>
>etc...
>
>>
>>
>>  static int
>> diff --git a/app/test/test_cmdline_ipaddr.c
>b/app/test/test_cmdline_ipaddr.c
>> index 2d11ce936..0c90162e8 100644
>> --- a/app/test/test_cmdline_ipaddr.c
>> +++ b/app/test/test_cmdline_ipaddr.c
>> @@ -264,18 +264,12 @@ const char * ipaddr_invalid_strs[] = {
>>                 " ",
>>  };
>>
>> -#define IPADDR_VALID_STRS_SIZE \
>> -       (sizeof(ipaddr_valid_strs) / sizeof(ipaddr_valid_strs[0]))
>> -#define IPADDR_GARBAGE_ADDR4_STRS_SIZE \
>> -       (sizeof(ipaddr_garbage_addr4_strs) /
>sizeof(ipaddr_garbage_addr4_strs[0]))
>> -#define IPADDR_GARBAGE_ADDR6_STRS_SIZE \
>> -       (sizeof(ipaddr_garbage_addr6_strs) /
>sizeof(ipaddr_garbage_addr6_strs[0]))
>> -#define IPADDR_GARBAGE_NETWORK4_STRS_SIZE \
>> -       (sizeof(ipaddr_garbage_network4_strs) /
>sizeof(ipaddr_garbage_network4_strs[0]))
>> -#define IPADDR_GARBAGE_NETWORK6_STRS_SIZE \
>> -       (sizeof(ipaddr_garbage_network6_strs) /
>sizeof(ipaddr_garbage_network6_strs[0]))
>> -#define IPADDR_INVALID_STRS_SIZE \
>> -       (sizeof(ipaddr_invalid_strs) / sizeof(ipaddr_invalid_strs[0]))
>> +#define IPADDR_VALID_STRS_SIZE RTE_DIM(ipaddr_valid_strs)
>> +#define IPADDR_GARBAGE_ADDR4_STRS_SIZE
>RTE_DIM(ipaddr_garbage_addr4_strs)
>> +#define IPADDR_GARBAGE_ADDR6_STRS_SIZE
>RTE_DIM(ipaddr_garbage_addr6_strs)
>> +#define IPADDR_GARBAGE_NETWORK4_STRS_SIZE
>RTE_DIM(ipaddr_garbage_network4_strs)
>> +#define IPADDR_GARBAGE_NETWORK6_STRS_SIZE
>RTE_DIM(ipaddr_garbage_network6_strs)
>> +#define IPADDR_INVALID_STRS_SIZE RTE_DIM(ipaddr_invalid_strs)
>
>Idem.
>
>>
>>  static void
>>  dump_addr(cmdline_ipaddr_t addr)
>> diff --git a/app/test/test_cmdline_num.c
>b/app/test/test_cmdline_num.c
>> index 4c97caf3d..1daeaf840 100644
>> --- a/app/test/test_cmdline_num.c
>> +++ b/app/test/test_cmdline_num.c
>> @@ -216,17 +216,11 @@ const char * num_invalid_strs[] = {
>>                 "\0",
>>  };
>>
>> -#define NUM_POSITIVE_STRS_SIZE \
>> -       (sizeof(num_valid_positive_strs) /
>sizeof(num_valid_positive_strs[0]))
>> -#define NUM_NEGATIVE_STRS_SIZE \
>> -       (sizeof(num_valid_negative_strs) /
>sizeof(num_valid_negative_strs[0]))
>> -#define NUM_POSITIVE_GARBAGE_STRS_SIZE \
>> -       (sizeof(num_garbage_positive_strs) /
>sizeof(num_garbage_positive_strs[0]))
>> -#define NUM_NEGATIVE_GARBAGE_STRS_SIZE \
>> -       (sizeof(num_garbage_negative_strs) /
>sizeof(num_garbage_negative_strs[0]))
>> -#define NUM_INVALID_STRS_SIZE \
>> -       (sizeof(num_invalid_strs) / sizeof(num_invalid_strs[0]))
>> -
>> +#define NUM_POSITIVE_STRS_SIZE
>RTE_DIM(num_valid_positive_strs)
>> +#define NUM_NEGATIVE_STRS_SIZE
>RTE_DIM(num_valid_negative_strs)
>> +#define NUM_POSITIVE_GARBAGE_STRS_SIZE
>RTE_DIM(num_garbage_positive_strs)
>> +#define NUM_NEGATIVE_GARBAGE_STRS_SIZE
>RTE_DIM(num_garbage_negative_strs)
>> +#define NUM_INVALID_STRS_SIZE RTE_DIM(num_invalid_strs)
>
>Idem.
>Stopping at this, I suppose you get the idea for the rest of the changes.
>
>
>Thanks.
>
>--
>David Marchand


  reply	other threads:[~2019-11-07  2:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-28  9:09 [dpdk-dev] [PATCH 1/3] app: use RTE_DIM to calculate array size pbhagavatula
2019-10-28  9:09 ` [dpdk-dev] [PATCH 2/3] examples: " pbhagavatula
2019-10-28  9:09 ` [dpdk-dev] [PATCH 3/3] lib: " pbhagavatula
2019-10-31  9:20 ` [dpdk-dev] [PATCH 1/3] app: " David Marchand
2019-11-07  2:12   ` Pavan Nikhilesh Bhagavatula [this message]
2019-11-07  2:58 ` [dpdk-dev] [PATCH v2 " pbhagavatula
2019-11-07  2:58   ` [dpdk-dev] [PATCH v2 2/3] examples: " pbhagavatula
2019-11-07  2:58   ` [dpdk-dev] [PATCH v2 3/3] lib: " pbhagavatula
2019-11-07  9:08     ` Dumitrescu, Cristian
2019-12-10 13:10   ` [dpdk-dev] [PATCH v2 1/3] app: " David Marchand
2020-01-24  4:55   ` [dpdk-dev] [PATCH v3 " pbhagavatula
2020-01-24  4:55     ` [dpdk-dev] [PATCH v3 2/3] examples: " pbhagavatula
2020-01-24  4:55     ` [dpdk-dev] [PATCH v3 3/3] lib: " pbhagavatula
2020-01-24 10:37       ` Laatz, Kevin
2020-02-05 10:22     ` [dpdk-dev] [PATCH v3 1/3] app: " David Marchand
2020-02-05 13:40       ` David Marchand

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=CY4PR1801MB18638285A93307E8657592A7DE780@CY4PR1801MB1863.namprd18.prod.outlook.com \
    --to=pbhagavatula@marvell.com \
    --cc=anatoly.burakov@intel.com \
    --cc=bernard.iremonger@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=erik.g.carrillo@intel.com \
    --cc=jingjing.wu@intel.com \
    --cc=olivier.matz@6wind.com \
    --cc=reshma.pattan@intel.com \
    --cc=rsanford@akamai.com \
    --cc=vladimir.medvedkin@intel.com \
    --cc=wenzhuo.lu@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.