[v2,3/4] test/ring: fix the wrong number of enq/deq elements
diff mbox series

Message ID 20200805061421.13037-4-feifei.wang2@arm.com
State Superseded
Delegated to: David Marchand
Headers show
Series
  • wrong pointer passed and add check
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Feifei Wang Aug. 5, 2020, 6:14 a.m. UTC
The actual capacity of ring should be the (RING_SIZE - 1), thus only
(RING_SIZE - 1) elements can be enqueued into the ring.

Fixes: a9fe152363e2 ("test/ring: add custom element size functional tests")
Cc: honnappa.nagarahalli@arm.com
Cc: stable@dpdk.org

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

Comments

Honnappa Nagarahalli Aug. 26, 2020, 8:51 p.m. UTC | #1
<snip>

> Subject: [PATCH v2 3/4] test/ring: fix the wrong number of enq/deq elements
> 
> The actual capacity of ring should be the (RING_SIZE - 1), thus only (RING_SIZE
> - 1) elements can be enqueued into the ring.
> 
> Fixes: a9fe152363e2 ("test/ring: add custom element size functional tests")
This issue is not because of this commit. It is coming from af75078fece3.

> Cc: honnappa.nagarahalli@arm.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
> Reviewed-by: Ruifeng Wang <ruifeng.wang@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
> c508a13a9..51bae0d48 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++) {
>  			test_ring_enqueue(rp, obj, esize[i], 1,
>  				TEST_RING_THREAD_DEF |
> TEST_RING_ELEM_SINGLE);
Can you validate the return value of this function (which should have caught the error)?

>  		}
> @@ -833,7 +833,7 @@ test_ring_basic_ex(void)
>  			goto fail_test;
>  		}
> 
> -		for (j = 0; j < RING_SIZE; j++) {
> +		for (j = 0; j < RING_SIZE - 1; j++) {
>  			test_ring_dequeue(rp, obj, esize[i], 1,
>  				TEST_RING_THREAD_DEF |
> TEST_RING_ELEM_SINGLE);
Same here.

>  		}
> --
> 2.17.1
Feifei Wang Aug. 27, 2020, 8:54 a.m. UTC | #2
> -----邮件原件-----
> 发件人: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>
> 发送时间: 2020年8月27日 4:51
> 收件人: Feifei Wang <Feifei.Wang2@arm.com>; Konstantin Ananyev
> <konstantin.ananyev@intel.com>; Olivier Matz <olivier.matz@6wind.com>;
> Gavin Hu <Gavin.Hu@arm.com>
> 抄送: dev@dpdk.org; nd <nd@arm.com>; Feifei Wang
> <Feifei.Wang2@arm.com>; stable@dpdk.org; Honnappa Nagarahalli
> <Honnappa.Nagarahalli@arm.com>; nd <nd@arm.com>
> 主题: RE: [PATCH v2 3/4] test/ring: fix the wrong number of enq/deq elements
> 
> <snip>
> 
> > Subject: [PATCH v2 3/4] test/ring: fix the wrong number of enq/deq elements
> >
> > The actual capacity of ring should be the (RING_SIZE - 1), thus only
> (RING_SIZE
> > - 1) elements can be enqueued into the ring.
> >
> > Fixes: a9fe152363e2 ("test/ring: add custom element size functional tests")
> This issue is not because of this commit. It is coming from af75078fece3.
Sorry for my mistake, I will correct it.
> 
> > Cc: honnappa.nagarahalli@arm.com
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
> > Reviewed-by: Ruifeng Wang <ruifeng.wang@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
> > c508a13a9..51bae0d48 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++) {
> >  			test_ring_enqueue(rp, obj, esize[i], 1,
> >  				TEST_RING_THREAD_DEF |
> > TEST_RING_ELEM_SINGLE);
> Can you validate the return value of this function (which should have caught the
> error)?
Ok, only for these two loops, I will add test to validate the number of enqueue/dequeue elements.
> 
> >  		}
> > @@ -833,7 +833,7 @@ test_ring_basic_ex(void)
> >  			goto fail_test;
> >  		}
> >
> > -		for (j = 0; j < RING_SIZE; j++) {
> > +		for (j = 0; j < RING_SIZE - 1; j++) {
> >  			test_ring_dequeue(rp, obj, esize[i], 1,
> >  				TEST_RING_THREAD_DEF |
> > TEST_RING_ELEM_SINGLE);
> Same here.
> 
> >  		}
> > --
> > 2.17.1

Patch
diff mbox series

diff --git a/app/test/test_ring.c b/app/test/test_ring.c
index c508a13a9..51bae0d48 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++) {
 			test_ring_enqueue(rp, obj, esize[i], 1,
 				TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
 		}
@@ -833,7 +833,7 @@  test_ring_basic_ex(void)
 			goto fail_test;
 		}
 
-		for (j = 0; j < RING_SIZE; j++) {
+		for (j = 0; j < RING_SIZE - 1; j++) {
 			test_ring_dequeue(rp, obj, esize[i], 1,
 				TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);
 		}