summaryrefslogtreecommitdiff
path: root/tests/test-pthread-mutex.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2026-03-08 17:28:33 +0100
committerJörg Frings-Fürst <debian@jff.email>2026-03-08 17:28:33 +0100
commit5f59a34ab747dde8ede7357f3431bf06bd6002fe (patch)
tree056a4477fd870d454d5be5868cddab829a47f4d2 /tests/test-pthread-mutex.c
parent27dae84ed92f1ef0300263091972338d12e78348 (diff)
New upstream version 1.4.2upstream/1.4.2upstream
Diffstat (limited to 'tests/test-pthread-mutex.c')
-rw-r--r--tests/test-pthread-mutex.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/tests/test-pthread-mutex.c b/tests/test-pthread-mutex.c
index 5671263e..a82ae8c3 100644
--- a/tests/test-pthread-mutex.c
+++ b/tests/test-pthread-mutex.c
@@ -1,5 +1,5 @@
/* Test of locking in multithreaded situations.
- Copyright (C) 2005, 2008-2025 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2008-2026 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -99,10 +99,10 @@ random_account (void)
static void
check_accounts (void)
{
- int i, sum;
+ int sum;
sum = 0;
- for (i = 0; i < ACCOUNT_COUNT; i++)
+ for (int i = 0; i < ACCOUNT_COUNT; i++)
sum += account[i];
if (sum != ACCOUNT_COUNT * 1000)
abort ();
@@ -120,9 +120,7 @@ static pthread_mutex_t my_lock;
static void *
lock_mutator_thread (void *arg)
{
- int repeat;
-
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
int i1, i2, value;
@@ -176,12 +174,11 @@ lock_checker_thread (void *arg)
static void
test_pthread_mutex_normal (void)
{
- int i;
pthread_t checkerthread;
pthread_t threads[THREAD_COUNT];
/* Initialization. */
- for (i = 0; i < ACCOUNT_COUNT; i++)
+ for (int i = 0; i < ACCOUNT_COUNT; i++)
account[i] = 1000;
init_atomic_int (&lock_checker_done);
set_atomic_int_value (&lock_checker_done, 0);
@@ -189,11 +186,11 @@ test_pthread_mutex_normal (void)
/* Spawn the threads. */
ASSERT (pthread_create (&checkerthread, NULL, lock_checker_thread, NULL)
== 0);
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (pthread_create (&threads[i], NULL, lock_mutator_thread, NULL) == 0);
/* Wait for the threads to terminate. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (pthread_join (threads[i], NULL) == 0);
set_atomic_int_value (&lock_checker_done, 1);
ASSERT (pthread_join (checkerthread, NULL) == 0);
@@ -236,9 +233,7 @@ recshuffle (void)
static void *
reclock_mutator_thread (void *arg)
{
- int repeat;
-
- for (repeat = REPEAT_COUNT; repeat > 0; repeat--)
+ for (int repeat = REPEAT_COUNT; repeat > 0; repeat--)
{
recshuffle ();
@@ -278,12 +273,11 @@ reclock_checker_thread (void *arg)
static void
test_pthread_mutex_recursive (void)
{
- int i;
pthread_t checkerthread;
pthread_t threads[THREAD_COUNT];
/* Initialization. */
- for (i = 0; i < ACCOUNT_COUNT; i++)
+ for (int i = 0; i < ACCOUNT_COUNT; i++)
account[i] = 1000;
init_atomic_int (&reclock_checker_done);
set_atomic_int_value (&reclock_checker_done, 0);
@@ -291,12 +285,12 @@ test_pthread_mutex_recursive (void)
/* Spawn the threads. */
ASSERT (pthread_create (&checkerthread, NULL, reclock_checker_thread, NULL)
== 0);
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (pthread_create (&threads[i], NULL, reclock_mutator_thread, NULL)
== 0);
/* Wait for the threads to terminate. */
- for (i = 0; i < THREAD_COUNT; i++)
+ for (int i = 0; i < THREAD_COUNT; i++)
ASSERT (pthread_join (threads[i], NULL) == 0);
set_atomic_int_value (&reclock_checker_done, 1);
ASSERT (pthread_join (checkerthread, NULL) == 0);