[PATCH v2 1/5] selftests/futex: reduce array declarations in the requeue_single

Yuwen Chen posted 5 patches 2 months ago
[PATCH v2 1/5] selftests/futex: reduce array declarations in the requeue_single
Posted by Yuwen Chen 2 months ago
In the requeue_single function, the variable "waits" only uses
one element. There is no need to use an array.

Signed-off-by: Yuwen Chen <ywen.chen@foxmail.com>
---
 tools/testing/selftests/futex/functional/futex_requeue.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/futex/functional/futex_requeue.c b/tools/testing/selftests/futex/functional/futex_requeue.c
index 69e2555b60399..1807465de2144 100644
--- a/tools/testing/selftests/futex/functional/futex_requeue.c
+++ b/tools/testing/selftests/futex/functional/futex_requeue.c
@@ -33,7 +33,7 @@ TEST(requeue_single)
 {
 	volatile futex_t _f1 = 0;
 	volatile futex_t f2 = 0;
-	pthread_t waiter[10];
+	pthread_t waiter;
 	int res;
 
 	f1 = &_f1;
@@ -41,7 +41,7 @@ TEST(requeue_single)
 	/*
 	 * Requeue a waiter from f1 to f2, and wake f2.
 	 */
-	if (pthread_create(&waiter[0], NULL, waiterfn, NULL))
+	if (pthread_create(&waiter, NULL, waiterfn, NULL))
 		ksft_exit_fail_msg("pthread_create failed\n");
 
 	usleep(WAKE_WAIT_US);
-- 
2.34.1
[PATCH v2 1/5] selftests/futex: reduce array declarations in the requeue_single
Posted by Licay 1 month, 3 weeks ago
> In the requeue_single function, the variable "waits" only uses
> one element. There is no need to use an array.
>
> Signed-off-by: Yuwen Chen <ywen.chen@foxmail.com>

Reviewed-by: Licay <licayy@foxmail.com>
> ---
>  tools/testing/selftests/futex/functional/futex_requeue.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/futex/functional/futex_requeue.c b/tools/testing/selftests/futex/functional/futex_requeue.c
> index 69e2555b60399..1807465de2144 100644
> --- a/tools/testing/selftests/futex/functional/futex_requeue.c
> +++ b/tools/testing/selftests/futex/functional/futex_requeue.c
> @@ -33,7 +33,7 @@ TEST(requeue_single)
>  {
>          volatile futex_t _f1 = 0;
>          volatile futex_t f2 = 0;
> -        pthread_t waiter[10];
> +        pthread_t waiter;
>          int res;
>
>          f1 = &_f1;
> @@ -41,7 +41,7 @@ TEST(requeue_single)
>          /*
>           * Requeue a waiter from f1 to f2, and wake f2.
>           */
> -        if (pthread_create(&waiter[0], NULL, waiterfn, NULL))
> +        if (pthread_create(&waiter, NULL, waiterfn, NULL))
>                  ksft_exit_fail_msg("pthread_create failed\n");
>
>          usleep(WAKE_WAIT_US);
> --
> 2.34.1