[v3,4/6] test/ring: fix wrong number of enq/deq elements

Message ID 20200911161002.19816-5-feifei.wang2@arm.com (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers
Series fix wrong passed pointer and add check |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Feifei Wang Sept. 11, 2020, 4:10 p.m. UTC
  The ring capacity is (RING_SIZE - 1), thus only (RING_SIZE - 1) number of
elements can be enqueued into the ring.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Phil Yang <phil.yang@arm.com>
---
 app/test/test_ring.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Honnappa Nagarahalli Sept. 14, 2020, 4:31 a.m. UTC | #1
<snip>

> 
> The ring capacity is (RING_SIZE - 1), thus only (RING_SIZE - 1) number of
> elements can be enqueued into the ring.
> 
> Fixes: af75078fece3 ("first public release")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> Reviewed-by: Phil Yang <phil.yang@arm.com>
Looks good
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>

> ---
>  app/test/test_ring.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/app/test/test_ring.c b/app/test/test_ring.c index
> 63d44d85e..811adc523 100644
> --- a/app/test/test_ring.c
> +++ b/app/test/test_ring.c
> @@ -822,7 +822,7 @@ test_ring_basic_ex(void)
>  		printf("%u ring entries are now free\n",
>  			rte_ring_free_count(rp));
> 
> -		for (j = 0; j < RING_SIZE; j++) {
> +		for (j = 0; j < RING_SIZE - 1; j++) {
>  			ret = test_ring_enqueue(rp, cur_src, esize[i], 1,
>  				TEST_RING_THREAD_DEF |
> TEST_RING_ELEM_SINGLE);
>  			if (ret != 0) {
> @@ -839,7 +839,7 @@ test_ring_basic_ex(void)
>  			goto fail_test;
>  		}
> 
> -		for (j = 0; j < RING_SIZE; j++) {
> +		for (j = 0; j < RING_SIZE - 1; j++) {
>  			ret = test_ring_dequeue(rp, cur_dst, esize[i], 1,
>  				TEST_RING_THREAD_DEF |
> TEST_RING_ELEM_SINGLE);
>  			if (ret != 0) {
> --
> 2.17.1
  

Patch

diff --git a/app/test/test_ring.c b/app/test/test_ring.c
index 63d44d85e..811adc523 100644
--- a/app/test/test_ring.c
+++ b/app/test/test_ring.c
@@ -822,7 +822,7 @@  test_ring_basic_ex(void)
 		printf("%u ring entries are now free\n",
 			rte_ring_free_count(rp));
 
-		for (j = 0; j < RING_SIZE; j++) {
+		for (j = 0; j < RING_SIZE - 1; j++) {
 			ret = test_ring_enqueue(rp, cur_src, esize[i], 1,
 				TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
 			if (ret != 0) {
@@ -839,7 +839,7 @@  test_ring_basic_ex(void)
 			goto fail_test;
 		}
 
-		for (j = 0; j < RING_SIZE; j++) {
+		for (j = 0; j < RING_SIZE - 1; j++) {
 			ret = test_ring_dequeue(rp, cur_dst, esize[i], 1,
 				TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
 			if (ret != 0) {