From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A5833A04F0; Tue, 10 Dec 2019 14:10:45 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E97DC23D; Tue, 10 Dec 2019 14:10:44 +0100 (CET) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by dpdk.org (Postfix) with ESMTP id A9D04A3 for ; Tue, 10 Dec 2019 14:10:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575983442; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I/cv57TOr+PwJelftT1ZHGEzBUY0Ol7uD1xeIFIyWno=; b=ipQjtl1jRONlp7EL376IXhZ9C8EHNEs3vN33SCTlYuapXYS+dR+uoCjwU5MCAuX9E8GU9J fC9xDmK0IOQOczI+QvVP2RNaP2MZMg4gzwDyPWjeLU2pfADzIYz2xFM6I8nfOIHWXqjRfZ 0u2sMxDKIEnwT7TqTRPx0M6EkbQmTHk= Received: from mail-ua1-f69.google.com (mail-ua1-f69.google.com [209.85.222.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-79-fkdSql6YOA2Xr5-QTXRf0A-1; Tue, 10 Dec 2019 08:10:38 -0500 Received: by mail-ua1-f69.google.com with SMTP id 101so4978783uam.2 for ; Tue, 10 Dec 2019 05:10:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZHDBH0ztkABy70uySKmxGMIO/Adgt+t4Xpx6ymqOp+A=; b=Auxg44VykkCHEN1hEK7hulrFiKB+USpEys3FAAsZjQjF9/9NE6Z3GhOn3f8ov634Fu HAsAt26/zTLYhpnjfPEBJqy4ejsOWqsnhnbzE0j/V+3CwnWDJCfl278ZtVOuvMZMtMp0 c3nn4gvWm5KZutGvmrkr92QAhJ3DNajV9e2F/YQdqsVxlSFn9+ESte+G1NUSdio4F8U/ sdzMeWIGr2qRkifP/JJe4TpAnkig8kbNiBRsJsaA0qpA8l3Kbzs/u/JJIubV0S1u/Iii ZZt3mvhpZYbVP6rtsZRutGiS55ZQB+7JH7cdFOjkc5Hh0nPaf/xppwfeRzl/x1wrDzRh bpnw== X-Gm-Message-State: APjAAAUzWFj0233UWQrccsfhsnfrX2Mlp71lBnzHOMPYdM374ROtE7io sNmvMlT3s6aXavuCw7JVmcU6SE0PUkCf2kRBcO9XrczHCJ3DoSvh9EGFX6OcVeE68r9pRqbsq7f PvHH6MT8o7jwAM/J2btA= X-Received: by 2002:a67:f9cb:: with SMTP id c11mr24364905vsq.180.1575983437726; Tue, 10 Dec 2019 05:10:37 -0800 (PST) X-Google-Smtp-Source: APXvYqxBf4uZoY8LsnvwlSuotKrj0+q4ybm/LlOvpF3l19iBCqYZoXQby6pnZfoBC4e4LlEU++CWfFzRoSI1G95HIMo= X-Received: by 2002:a67:f9cb:: with SMTP id c11mr24364868vsq.180.1575983437202; Tue, 10 Dec 2019 05:10:37 -0800 (PST) MIME-Version: 1.0 References: <20191028090907.824-1-pbhagavatula@marvell.com> <20191107025823.5200-1-pbhagavatula@marvell.com> In-Reply-To: <20191107025823.5200-1-pbhagavatula@marvell.com> From: David Marchand Date: Tue, 10 Dec 2019 14:10:26 +0100 Message-ID: To: Pavan Nikhilesh Cc: dev X-MC-Unique: fkdSql6YOA2Xr5-QTXRf0A-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] [PATCH v2 1/3] app: use RTE_DIM to calculate array size X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, Nov 7, 2019 at 3:59 AM wrote: > > From: Pavan Nikhilesh > > Use RTE_DIM macro to calculate array size > > Suggested-by: David Marchand > Signed-off-by: Pavan Nikhilesh > --- > v2 Changes: > ---------- > - remove macros that are used only once.(David) > > 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 | 15 +++------------ > app/test/test_cmdline_ipaddr.c | 25 ++++++------------------- > app/test/test_cmdline_num.c | 23 +++++------------------ > app/test/test_cmdline_portlist.c | 17 ++++------------- > app/test/test_cmdline_string.c | 23 +++++------------------ > app/test/test_debug.c | 2 +- > app/test/test_eal_flags.c | 9 ++++----- > app/test/test_errno.c | 4 ++-- > app/test/test_lpm.c | 3 +-- > app/test/test_lpm6.c | 3 +-- > 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, 47 insertions(+), 113 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 =3D (sizeof events) / (sizeof events[0]); > + int num_events =3D RTE_DIM(events); num_events is used only once. > > /* Display the bypass mode.*/ > if (rte_pmd_ixgbe_bypass_state_show(port_id, &bypass_mode) !=3D 0= ) { [snip] > diff --git a/app/test/test_cmdline_num.c b/app/test/test_cmdline_num.c > index 4c97caf3d..f6af58a27 100644 > --- a/app/test/test_cmdline_num.c > +++ b/app/test/test_cmdline_num.c [snip] > @@ -431,7 +418,7 @@ test_parse_num_valid(void) > token.num_data.type =3D type; > > /* test positive strings */ > - for (i =3D 0; i < NUM_POSITIVE_STRS_SIZE; i++) { > + for (i =3D 0; i < RTE_DIM(num_valid_positive_strs); i++)= { Unneeded space. > result =3D 0; > memset(&buf, 0, sizeof(buf)); > [snip] > diff --git a/app/test/test_cmdline_portlist.c b/app/test/test_cmdline_por= tlist.c > index 0dc6d0030..cbfdfcf54 100644 > --- a/app/test/test_cmdline_portlist.c > +++ b/app/test/test_cmdline_portlist.c > @@ -6,6 +6,7 @@ > #include > #include > > +#include We separate the includes in 3 groups, standard system headers, dpdk headers and finally application headers. Add a line here. > #include > #include > [snip] > diff --git a/app/test/test_memcpy.c b/app/test/test_memcpy.c > index 2c69ad964..53eb8433a 100644 > --- a/app/test/test_memcpy.c > +++ b/app/test/test_memcpy.c > @@ -103,7 +103,7 @@ static int > func_test(void) > { > unsigned int off_src, off_dst, i; > - unsigned int num_buf_sizes =3D sizeof(buf_sizes) / sizeof(buf_siz= es[0]); > + unsigned int num_buf_sizes =3D RTE_DIM(buf_sizes); num_buf_sizes is used only once. > int ret; > > for (off_src =3D 0; off_src < ALIGNMENT_UNIT; off_src++) { > diff --git a/app/test/test_memcpy_perf.c b/app/test/test_memcpy_perf.c > index 6f436f3ef..8f06b0f1e 100644 > --- a/app/test/test_memcpy_perf.c > +++ b/app/test/test_memcpy_perf.c > @@ -250,7 +250,7 @@ perf_test_constant_unaligned(void) > static inline void > perf_test_variable_aligned(void) > { > - unsigned n =3D sizeof(buf_sizes) / sizeof(buf_sizes[0]); > + unsigned n =3D RTE_DIM(buf_sizes); n is used only once. > unsigned i; > for (i =3D 0; i < n; i++) { > ALL_PERF_TESTS_FOR_SIZE((size_t)buf_sizes[i]); > @@ -261,7 +261,7 @@ perf_test_variable_aligned(void) > static inline void > perf_test_variable_unaligned(void) > { > - unsigned n =3D sizeof(buf_sizes) / sizeof(buf_sizes[0]); > + unsigned n =3D RTE_DIM(buf_sizes); idem. > unsigned i; > for (i =3D 0; i < n; i++) { > ALL_PERF_TESTS_FOR_SIZE_UNALIGNED((size_t)buf_sizes[i]); The rest looks good. If you still have some available cycles, can you handle those too? $ git grep 'sizeof(.*) */ *sizeof(.*)' -- app/test app/test/test_func_reentrancy.c: for (case_id =3D 0; case_id < sizeof(test_cases)/sizeof(struct test_case); case_id ++) { app/test/test_hash.c: i < sizeof(hashtest_funcs) / sizeof(rte_hash_function); app/test/test_hash.c: j < sizeof(hashtest_initvals) / sizeof(uint32_t); app/test/test_hash.c: k < sizeof(hashtest_key_lens) / sizeof(uint32_t); app/test/test_hash_functions.c: for (i =3D 0; i < sizeof(hashtest_key_lens) / sizeof(uint32_t); i++) { app/test/test_hash_functions.c: for (j =3D 0; j < sizeof(hashtest_initvals) / sizeof(uint32_t); j++) { app/test/test_hash_functions.c: for (i =3D 0; i < sizeof(hashtest_key_lens) / sizeof(uint32_t); i++) { app/test/test_hash_functions.c: for (j =3D 0; j < sizeof(hashtest_initvals) / sizeof(uint32_t); j++) { app/test/test_power.c: const int envs_size =3D sizeof(envs)/sizeof(enum power_management_env); Thanks for working on cleanups. -- David Marchand