diff mbox series

[09/10] tests/aio-multithread: Clean up global variable shadowing

Message ID 20231009100251.56019-10-philmd@linaro.org
State New
Headers show
Series tests: Clean up global variables shadowing | expand

Commit Message

Philippe Mathieu-Daudé Oct. 9, 2023, 10:02 a.m. UTC
Rename the argument to avoid:

  tests/unit/test-aio-multithread.c:226:37: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  static void test_multi_co_mutex(int threads, int seconds)
                                      ^
  tests/unit/test-aio-multithread.c:401:34: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
  static void test_multi_mutex(int threads, int seconds)
                                   ^
  tests/unit/test-aio-multithread.c:24:18: note: previous declaration is here
  static IOThread *threads[NUM_CONTEXTS];
                   ^

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 tests/unit/test-aio-multithread.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Thomas Huth Oct. 13, 2023, 6:26 a.m. UTC | #1
On 09/10/2023 12.02, Philippe Mathieu-Daudé wrote:
> Rename the argument to avoid:
> 
>    tests/unit/test-aio-multithread.c:226:37: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
>    static void test_multi_co_mutex(int threads, int seconds)
>                                        ^
>    tests/unit/test-aio-multithread.c:401:34: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
>    static void test_multi_mutex(int threads, int seconds)
>                                     ^
>    tests/unit/test-aio-multithread.c:24:18: note: previous declaration is here
>    static IOThread *threads[NUM_CONTEXTS];
>                     ^
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   tests/unit/test-aio-multithread.c | 16 ++++++++--------
>   1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/tests/unit/test-aio-multithread.c b/tests/unit/test-aio-multithread.c
> index 08d4570ccb..d587f20667 100644
> --- a/tests/unit/test-aio-multithread.c
> +++ b/tests/unit/test-aio-multithread.c
> @@ -223,7 +223,7 @@ static void coroutine_fn test_multi_co_mutex_entry(void *opaque)
>       qatomic_dec(&running);
>   }
>   
> -static void test_multi_co_mutex(int threads, int seconds)
> +static void test_multi_co_mutex(unsigned ctx_num, int seconds)

Why did you change the type of the variable? ... you should at least mention 
this in the commit description.

>   {
>       int i;
>   
> @@ -233,9 +233,9 @@ static void test_multi_co_mutex(int threads, int seconds)
>       now_stopping = false;
>   
>       create_aio_contexts();
> -    assert(threads <= NUM_CONTEXTS);
> -    running = threads;
> -    for (i = 0; i < threads; i++) {
> +    assert(ctx_num <= NUM_CONTEXTS);
> +    running = ctx_num;
> +    for (i = 0; i < ctx_num; i++) {
>           Coroutine *co1 = qemu_coroutine_create(test_multi_co_mutex_entry, NULL);
>           aio_co_schedule(ctx[i], co1);
>       }
> @@ -398,7 +398,7 @@ static void test_multi_mutex_entry(void *opaque)
>       qatomic_dec(&running);
>   }
>   
> -static void test_multi_mutex(int threads, int seconds)
> +static void test_multi_mutex(unsigned ctx_num, int seconds)

dito.

  Thomas

>   {
>       int i;
>   
> @@ -408,9 +408,9 @@ static void test_multi_mutex(int threads, int seconds)
>       now_stopping = false;
>   
>       create_aio_contexts();
> -    assert(threads <= NUM_CONTEXTS);
> -    running = threads;
> -    for (i = 0; i < threads; i++) {
> +    assert(ctx_num <= NUM_CONTEXTS);
> +    running = ctx_num;
> +    for (i = 0; i < ctx_num; i++) {
>           Coroutine *co1 = qemu_coroutine_create(test_multi_mutex_entry, NULL);
>           aio_co_schedule(ctx[i], co1);
>       }
diff mbox series

Patch

diff --git a/tests/unit/test-aio-multithread.c b/tests/unit/test-aio-multithread.c
index 08d4570ccb..d587f20667 100644
--- a/tests/unit/test-aio-multithread.c
+++ b/tests/unit/test-aio-multithread.c
@@ -223,7 +223,7 @@  static void coroutine_fn test_multi_co_mutex_entry(void *opaque)
     qatomic_dec(&running);
 }
 
-static void test_multi_co_mutex(int threads, int seconds)
+static void test_multi_co_mutex(unsigned ctx_num, int seconds)
 {
     int i;
 
@@ -233,9 +233,9 @@  static void test_multi_co_mutex(int threads, int seconds)
     now_stopping = false;
 
     create_aio_contexts();
-    assert(threads <= NUM_CONTEXTS);
-    running = threads;
-    for (i = 0; i < threads; i++) {
+    assert(ctx_num <= NUM_CONTEXTS);
+    running = ctx_num;
+    for (i = 0; i < ctx_num; i++) {
         Coroutine *co1 = qemu_coroutine_create(test_multi_co_mutex_entry, NULL);
         aio_co_schedule(ctx[i], co1);
     }
@@ -398,7 +398,7 @@  static void test_multi_mutex_entry(void *opaque)
     qatomic_dec(&running);
 }
 
-static void test_multi_mutex(int threads, int seconds)
+static void test_multi_mutex(unsigned ctx_num, int seconds)
 {
     int i;
 
@@ -408,9 +408,9 @@  static void test_multi_mutex(int threads, int seconds)
     now_stopping = false;
 
     create_aio_contexts();
-    assert(threads <= NUM_CONTEXTS);
-    running = threads;
-    for (i = 0; i < threads; i++) {
+    assert(ctx_num <= NUM_CONTEXTS);
+    running = ctx_num;
+    for (i = 0; i < ctx_num; i++) {
         Coroutine *co1 = qemu_coroutine_create(test_multi_mutex_entry, NULL);
         aio_co_schedule(ctx[i], co1);
     }