[PATCH] tests: Fix a bug with count variables

Tianjia Zhang posted 1 patch 5 years, 9 months ago
Test docker-quick@centos7 passed
Test FreeBSD passed
Test docker-mingw@fedora passed
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200207115433.118254-1-tianjia.zhang@linux.alibaba.com
tests/test-rcu-list.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] tests: Fix a bug with count variables
Posted by Tianjia Zhang 5 years, 9 months ago
The counting code here should use the local variable n_nodes_local.
Otherwise, the variable n_nodes is counting incorrectly, causing the
counting logic of the code to be wrong.

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
---
 tests/test-rcu-list.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/test-rcu-list.c b/tests/test-rcu-list.c
index 6f076473e0..c0fc47ded4 100644
--- a/tests/test-rcu-list.c
+++ b/tests/test-rcu-list.c
@@ -219,7 +219,7 @@ static void *rcu_q_updater(void *arg)
             j++;
             if (target_el == j) {
                 struct list_element *new_el = g_new(struct list_element, 1);
-                n_nodes += n_nodes_local;
+                n_nodes_local++;
                 TEST_LIST_INSERT_AFTER_RCU(el, new_el, entry);
                 break;
             }
-- 
2.17.1


Re: [PATCH] tests: Fix a bug with count variables
Posted by Stefan Hajnoczi 5 years, 9 months ago
On Fri, Feb 07, 2020 at 07:54:33PM +0800, Tianjia Zhang wrote:
> The counting code here should use the local variable n_nodes_local.
> Otherwise, the variable n_nodes is counting incorrectly, causing the
> counting logic of the code to be wrong.
> 
> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
> ---
>  tests/test-rcu-list.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Re: [PATCH] tests: Fix a bug with count variables
Posted by Stefan Hajnoczi 5 years, 8 months ago
On Fri, Feb 07, 2020 at 07:54:33PM +0800, Tianjia Zhang wrote:
> The counting code here should use the local variable n_nodes_local.
> Otherwise, the variable n_nodes is counting incorrectly, causing the
> counting logic of the code to be wrong.
> 
> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
> ---
>  tests/test-rcu-list.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Sorry for the delay!  Normally this would not go through my tree, but
the tests/ maintainer is away on leave so I'll merge the patch.

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan
Re: [PATCH] tests: Fix a bug with count variables
Posted by Tianjia Zhang 5 years, 8 months ago

On 2020/3/6 18:53, Stefan Hajnoczi wrote:
> On Fri, Feb 07, 2020 at 07:54:33PM +0800, Tianjia Zhang wrote:
>> The counting code here should use the local variable n_nodes_local.
>> Otherwise, the variable n_nodes is counting incorrectly, causing the
>> counting logic of the code to be wrong.
>>
>> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
>> ---
>>   tests/test-rcu-list.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Sorry for the delay!  Normally this would not go through my tree, but
> the tests/ maintainer is away on leave so I'll merge the patch.
> 
> Thanks, applied to my block tree:
> https://github.com/stefanha/qemu/commits/block
> 
> Stefan
> 

Thanks and Best,
Tianjia