[v2] app/test: fix to prevent zcd gcc compile error

Message ID 20201110110313.1924365-1-conor.walsh@intel.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series [v2] app/test: fix to prevent zcd gcc compile error |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/travis-robot success Travis build: passed
ci/Intel-compilation success Compilation OK
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Conor Walsh Nov. 10, 2020, 11:03 a.m. UTC
  When DPDK is compiled with gcc < 9 with the optimization level set to 1
gcc sees zcd in test_ring.h as possibly being uninitialised. To correct
this error if statements from _st_ring_dequeue_bulk and
_st_ring_enqueue_bulk were corrected within test_ring_mt_peek_stress_zc.c

Signed-off-by: Conor Walsh <conor.walsh@intel.com>

---

v2: Moved from initialising zcd to changing if statements within
    test_ring_mt_peek_stress_zc.c following list feedback as the
    original method used may have masked errors within the library.
---
 app/test/test_ring_mt_peek_stress_zc.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
  

Comments

Honnappa Nagarahalli Nov. 10, 2020, 2:57 p.m. UTC | #1
<snip>

> 
> When DPDK is compiled with gcc < 9 with the optimization level set to 1 gcc
> sees zcd in test_ring.h as possibly being uninitialised. To correct this error if
> statements from _st_ring_dequeue_bulk and _st_ring_enqueue_bulk were
> corrected within test_ring_mt_peek_stress_zc.c
> 
> Signed-off-by: Conor Walsh <conor.walsh@intel.com>
Thank you Conor, looks good.

Review-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>

> 
> ---
> 
> v2: Moved from initialising zcd to changing if statements within
>     test_ring_mt_peek_stress_zc.c following list feedback as the
>     original method used may have masked errors within the library.
> ---
>  app/test/test_ring_mt_peek_stress_zc.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/app/test/test_ring_mt_peek_stress_zc.c
> b/app/test/test_ring_mt_peek_stress_zc.c
> index 7e0bd511a7..85f0262ba0 100644
> --- a/app/test/test_ring_mt_peek_stress_zc.c
> +++ b/app/test/test_ring_mt_peek_stress_zc.c
> @@ -14,8 +14,7 @@ _st_ring_dequeue_bulk(struct rte_ring *r, void **obj,
> uint32_t n,
>  	struct rte_ring_zc_data zcd;
> 
>  	m = rte_ring_dequeue_zc_bulk_start(r, n, &zcd, avail);
> -	n = (m == n) ? n : 0;
> -	if (n != 0) {
> +	if (m != 0) {
>  		/* Copy the data from the ring */
>  		test_ring_copy_from(&zcd, obj, -1, n);
>  		rte_ring_dequeue_zc_finish(r, n);
> @@ -32,8 +31,7 @@ _st_ring_enqueue_bulk(struct rte_ring *r, void * const
> *obj, uint32_t n,
>  	struct rte_ring_zc_data zcd;
> 
>  	m = rte_ring_enqueue_zc_bulk_start(r, n, &zcd, free);
> -	n = (m == n) ? n : 0;
> -	if (n != 0) {
> +	if (m != 0) {
>  		/* Copy the data from the ring */
>  		test_ring_copy_to(&zcd, obj, -1, n);
>  		rte_ring_enqueue_zc_finish(r, n);
> --
> 2.25.1
  
Honnappa Nagarahalli Nov. 11, 2020, 4:18 p.m. UTC | #2
> -----Original Message-----
> From: Conor Walsh <conor.walsh@intel.com>
> Sent: Tuesday, November 10, 2020 5:03 AM
> To: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>;
> konstantin.ananyev@intel.com
> Cc: dev@dpdk.org; linglix.chen@intel.com; Conor Walsh
> <conor.walsh@intel.com>
> Subject: [PATCH v2] app/test: fix to prevent zcd gcc compile error
> 
> When DPDK is compiled with gcc < 9 with the optimization level set to 1 gcc
> sees zcd in test_ring.h as possibly being uninitialised. To correct this error if
> statements from _st_ring_dequeue_bulk and _st_ring_enqueue_bulk were
> corrected within test_ring_mt_peek_stress_zc.c
> 
> Signed-off-by: Conor Walsh <conor.walsh@intel.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>

> 
> ---
> 
> v2: Moved from initialising zcd to changing if statements within
>     test_ring_mt_peek_stress_zc.c following list feedback as the
>     original method used may have masked errors within the library.
> ---
>  app/test/test_ring_mt_peek_stress_zc.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/app/test/test_ring_mt_peek_stress_zc.c
> b/app/test/test_ring_mt_peek_stress_zc.c
> index 7e0bd511a7..85f0262ba0 100644
> --- a/app/test/test_ring_mt_peek_stress_zc.c
> +++ b/app/test/test_ring_mt_peek_stress_zc.c
> @@ -14,8 +14,7 @@ _st_ring_dequeue_bulk(struct rte_ring *r, void **obj,
> uint32_t n,
>  	struct rte_ring_zc_data zcd;
> 
>  	m = rte_ring_dequeue_zc_bulk_start(r, n, &zcd, avail);
> -	n = (m == n) ? n : 0;
> -	if (n != 0) {
> +	if (m != 0) {
>  		/* Copy the data from the ring */
>  		test_ring_copy_from(&zcd, obj, -1, n);
>  		rte_ring_dequeue_zc_finish(r, n);
> @@ -32,8 +31,7 @@ _st_ring_enqueue_bulk(struct rte_ring *r, void * const
> *obj, uint32_t n,
>  	struct rte_ring_zc_data zcd;
> 
>  	m = rte_ring_enqueue_zc_bulk_start(r, n, &zcd, free);
> -	n = (m == n) ? n : 0;
> -	if (n != 0) {
> +	if (m != 0) {
>  		/* Copy the data from the ring */
>  		test_ring_copy_to(&zcd, obj, -1, n);
>  		rte_ring_enqueue_zc_finish(r, n);
> --
> 2.25.1
  
David Marchand Nov. 15, 2020, 3:56 p.m. UTC | #3
On Wed, Nov 11, 2020 at 5:18 PM Honnappa Nagarahalli
<Honnappa.Nagarahalli@arm.com> wrote:
> > -----Original Message-----
> > From: Conor Walsh <conor.walsh@intel.com>
> > Sent: Tuesday, November 10, 2020 5:03 AM
> > To: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>;
> > konstantin.ananyev@intel.com
> > Cc: dev@dpdk.org; linglix.chen@intel.com; Conor Walsh
> > <conor.walsh@intel.com>
> > Subject: [PATCH v2] app/test: fix to prevent zcd gcc compile error
> >
> > When DPDK is compiled with gcc < 9 with the optimization level set to 1 gcc
> > sees zcd in test_ring.h as possibly being uninitialised. To correct this error if
> > statements from _st_ring_dequeue_bulk and _st_ring_enqueue_bulk were
> > corrected within test_ring_mt_peek_stress_zc.c

Fixes: f72299fd157d ("test/ring: add stress tests for zero copy API")

> >
> > Signed-off-by: Conor Walsh <conor.walsh@intel.com>
> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>

Updated title, and applied, thanks.
  

Patch

diff --git a/app/test/test_ring_mt_peek_stress_zc.c b/app/test/test_ring_mt_peek_stress_zc.c
index 7e0bd511a7..85f0262ba0 100644
--- a/app/test/test_ring_mt_peek_stress_zc.c
+++ b/app/test/test_ring_mt_peek_stress_zc.c
@@ -14,8 +14,7 @@  _st_ring_dequeue_bulk(struct rte_ring *r, void **obj, uint32_t n,
 	struct rte_ring_zc_data zcd;
 
 	m = rte_ring_dequeue_zc_bulk_start(r, n, &zcd, avail);
-	n = (m == n) ? n : 0;
-	if (n != 0) {
+	if (m != 0) {
 		/* Copy the data from the ring */
 		test_ring_copy_from(&zcd, obj, -1, n);
 		rte_ring_dequeue_zc_finish(r, n);
@@ -32,8 +31,7 @@  _st_ring_enqueue_bulk(struct rte_ring *r, void * const *obj, uint32_t n,
 	struct rte_ring_zc_data zcd;
 
 	m = rte_ring_enqueue_zc_bulk_start(r, n, &zcd, free);
-	n = (m == n) ? n : 0;
-	if (n != 0) {
+	if (m != 0) {
 		/* Copy the data from the ring */
 		test_ring_copy_to(&zcd, obj, -1, n);
 		rte_ring_enqueue_zc_finish(r, n);