diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-03-28 00:51:03 +0200 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-03-28 00:51:03 +0200 |
commit | b1f57fa0cf5515263bebcefe1044995ebaf9a1f3 (patch) | |
tree | dc73df6d0831bb483a38856d5f1e5c475dc60b26 | |
parent | 05cefb83e22c08aedf5d3b893ad387eb6424faba (diff) |
Fix coding style
-rw-r--r-- | tests/test-1.c | 4 | ||||
-rw-r--r-- | tests/test-11.c | 14 | ||||
-rw-r--r-- | tests/test-13.c | 2 | ||||
-rw-r--r-- | tests/test-14.c | 2 | ||||
-rw-r--r-- | tests/test-15.c | 9 | ||||
-rw-r--r-- | tests/test-17.c | 8 | ||||
-rw-r--r-- | tests/test-3.c | 16 | ||||
-rw-r--r-- | tests/test-4.c | 2 | ||||
-rw-r--r-- | tests/test-5.c | 2 | ||||
-rw-r--r-- | tests/test-6.c | 14 | ||||
-rw-r--r-- | tests/test-7.c | 17 | ||||
-rw-r--r-- | tests/test-8.c | 8 | ||||
-rw-r--r-- | tests/test-9.c | 8 | ||||
-rw-r--r-- | tests/test-__pthread_destroy_specific-skip.c | 11 |
14 files changed, 59 insertions, 58 deletions
diff --git a/tests/test-1.c b/tests/test-1.c index 6ec1afb..640a37f 100644 --- a/tests/test-1.c +++ b/tests/test-1.c @@ -26,7 +26,7 @@ main (int argc, char **argv) pthread_t tid[THREADS]; pthread_mutex_t mutex[THREADS]; - for (i = 0; i < THREADS; i ++) + for (i = 0; i < THREADS; i++) { pthread_mutex_init (&mutex[i], 0); pthread_mutex_lock (&mutex[i]); @@ -36,7 +36,7 @@ main (int argc, char **argv) sched_yield (); } - for (i = THREADS - 1; i >= 0; i --) + for (i = THREADS - 1; i >= 0; i--) { void *ret; pthread_mutex_unlock (&mutex[i]); diff --git a/tests/test-11.c b/tests/test-11.c index f5a5aa0..119b86d 100644 --- a/tests/test-11.c +++ b/tests/test-11.c @@ -20,7 +20,7 @@ test1 (void *arg) pthread_rwlock_t *lock = arg; int i; - for (i = 0; i < 200; i ++) + for (i = 0; i < 200; i++) { err = pthread_rwlock_rdlock (lock); assert (err == 0); @@ -75,31 +75,31 @@ main (int argc, char **argv) /* Now test the lock. */ - for (i = 0; i < THREADS; i ++) + for (i = 0; i < THREADS; i++) { err = pthread_create (&tid[i], 0, test1, &lock); if (err) error (1, err, "pthread_create"); } - for (i = 0; i < 10; i ++) + for (i = 0; i < 10; i++) { sched_yield (); /* Get a write lock. */ pthread_rwlock_wrlock (&lock); /* Increment a and b giving other threads a chance to run in - between. */ + between. */ sched_yield (); - a ++; + a++; sched_yield (); - b ++; + b++; sched_yield (); /* Unlock. */ pthread_rwlock_unlock (&lock); } - for (i = 0; i < THREADS; i ++) + for (i = 0; i < THREADS; i++) { err = pthread_join (tid[i], &ret); if (err) diff --git a/tests/test-13.c b/tests/test-13.c index 13b0905..292dd2d 100644 --- a/tests/test-13.c +++ b/tests/test-13.c @@ -57,7 +57,7 @@ main (int argc, char **argv) assert (err == ETIMEDOUT); diff = after.tv_sec * 1000000 + after.tv_usec - - before.tv_sec * 1000000 - before.tv_usec; + - before.tv_sec * 1000000 - before.tv_usec; if (diff < 900000 || diff > 1100000) error (1, EGRATUITOUS, "pthread_cond_timedwait waited %d us", diff); diff --git a/tests/test-14.c b/tests/test-14.c index b1dbfa6..b1e4e4f 100644 --- a/tests/test-14.c +++ b/tests/test-14.c @@ -35,7 +35,7 @@ main (int argc, char **argv) printf ("End wait @ %d\n", (int) after.tv_sec); diff = after.tv_sec * 1000000 + after.tv_usec - - before.tv_sec * 1000000 - before.tv_usec; + - before.tv_sec * 1000000 - before.tv_usec; if (diff < 900000 || diff > 1100000) error (1, EGRATUITOUS, "pthread_mutex_timedlock waited %d us", diff); diff --git a/tests/test-15.c b/tests/test-15.c index 173f8b6..ae20f10 100644 --- a/tests/test-15.c +++ b/tests/test-15.c @@ -38,11 +38,10 @@ test (void *arg) gettimeofday (&after, 0); - printf ("Thread %d ending wait @ %d\n", pthread_self (), - (int) after.tv_sec); + printf ("Thread %d ending wait @ %d\n", pthread_self (), (int) after.tv_sec); diff = after.tv_sec * 1000000 + after.tv_usec - - before.tv_sec * 1000000 - before.tv_usec; + - before.tv_sec * 1000000 - before.tv_usec; if (diff < 900000 || diff > 1100000) error (1, EGRATUITOUS, "pthread_mutex_timedlock waited %d us", diff); @@ -65,14 +64,14 @@ main (int argc, char **argv) err = pthread_rwlock_wrlock (&rwlock); assert (err == 0); - for (i = 0; i < THREADS; i ++) + for (i = 0; i < THREADS; i++) { err = pthread_create (&tid[i], 0, test, (void *) i); if (err) error (1, err, "pthread_create"); } - for (i = 0; i < THREADS; i ++) + for (i = 0; i < THREADS; i++) { void *ret; diff --git a/tests/test-17.c b/tests/test-17.c index a8bd150..cfe755f 100644 --- a/tests/test-17.c +++ b/tests/test-17.c @@ -28,16 +28,16 @@ work (int iter) printf ("work/%d: pre-setspecific: %p,%p\n", iter, value1, value2); assert (value1 == NULL); assert (value2 == NULL); - err = pthread_setspecific (key1, (void *)(0x100 + iter)); + err = pthread_setspecific (key1, (void *) (0x100 + iter)); assert (err == 0); - err = pthread_setspecific (key2, (void *)(0x200 + iter)); + err = pthread_setspecific (key2, (void *) (0x200 + iter)); assert (err == 0); value1 = pthread_getspecific (key1); value2 = pthread_getspecific (key2); printf ("work/%d: post-setspecific: %p,%p\n", iter, value1, value2); - assert (value1 == (void *)(0x100 + iter)); - assert (value2 == (void *)(0x200 + iter)); + assert (value1 == (void *) (0x100 + iter)); + assert (value2 == (void *) (0x200 + iter)); err = pthread_key_delete (key1); assert (err == 0); diff --git a/tests/test-3.c b/tests/test-3.c index 7db2e43..46369e0 100644 --- a/tests/test-3.c +++ b/tests/test-3.c @@ -36,14 +36,14 @@ main (int argc, char *argv[]) #define TEST(foo, rv, v) TEST1(foo, rv, v) - TEST(inheritsched, &i, i); - TEST(schedparam, &sp, &sp); - TEST(schedpolicy, &i, i); - TEST(scope, &i, i); - TEST(stackaddr, &p, p); - TEST(detachstate, &i, i); - TEST(guardsize, &sz, sz); - TEST(stacksize, &sz, sz); + TEST (inheritsched, &i, i); + TEST (schedparam, &sp, &sp); + TEST (schedpolicy, &i, i); + TEST (scope, &i, i); + TEST (stackaddr, &p, p); + TEST (detachstate, &i, i); + TEST (guardsize, &sz, sz); + TEST (stacksize, &sz, sz); err = pthread_attr_getstack (&attr, &p, &sz); assert_perror (err); diff --git a/tests/test-4.c b/tests/test-4.c index de9c8fe..0ae9271 100644 --- a/tests/test-4.c +++ b/tests/test-4.c @@ -18,7 +18,7 @@ thr (void *arg) char *foo; foo = alloca (3 * stacksize / 4); - for (i = 0; i < sizeof foo; i ++) + for (i = 0; i < sizeof foo; i++) foo[i] = -1; return (void *) 1; diff --git a/tests/test-5.c b/tests/test-5.c index 0f5000b..f8dfa99 100644 --- a/tests/test-5.c +++ b/tests/test-5.c @@ -14,7 +14,7 @@ void * thr (void *arg) { - * (int *)0 = 0; + *(int *) 0 = 0; return 0; } diff --git a/tests/test-6.c b/tests/test-6.c index 205c7a4..fc0194e 100644 --- a/tests/test-6.c +++ b/tests/test-6.c @@ -49,10 +49,10 @@ main (int argc, char **argv) if (err) error (1, err, "pthread_barrier_init"); - for (j = 0; j < WAITS; j ++) + for (j = 0; j < WAITS; j++) { - for (i = 0; i < THREADS; i ++) + for (i = 0; i < THREADS; i++) { err = pthread_create (&tid[i], 0, dowait, &barrier); if (err) @@ -62,10 +62,10 @@ main (int argc, char **argv) printf ("Manager will now call pthread_barrier_wait.\n"); havesyncs - = pthread_barrier_wait (&barrier) == PTHREAD_BARRIER_SERIAL_THREAD - ? 1 : 0; + = pthread_barrier_wait (&barrier) == PTHREAD_BARRIER_SERIAL_THREAD + ? 1 : 0; - for (i = THREADS - 1; i >= 0; i --) + for (i = THREADS - 1; i >= 0; i--) { void *ret; err = pthread_join (tid[i], &ret); @@ -78,11 +78,11 @@ main (int argc, char **argv) break; case PTHREAD_BARRIER_SERIAL_THREAD: - havesyncs ++; + havesyncs++; break; default: - assert (! "Unknown value returned from pthread_barrier_wait."); + assert (!"Unknown value returned from pthread_barrier_wait."); break; } } diff --git a/tests/test-7.c b/tests/test-7.c index be724ce..18bae68 100644 --- a/tests/test-7.c +++ b/tests/test-7.c @@ -17,13 +17,14 @@ thr (void *arg) error_t err; int i; - for (i = 0; i < KEYS; i ++) + for (i = 0; i < KEYS; i++) { printf ("pthread_getspecific(%d).\n", key[i]); assert (pthread_getspecific (key[i]) == NULL); printf ("pthread_setspecific(%d, %d).\n", key[i], pthread_self ()); err = pthread_setspecific (key[i], (void *) pthread_self ()); - printf ("pthread_setspecific(%d, %d) => %d.\n", key[i], pthread_self (), err); + printf ("pthread_setspecific(%d, %d) => %d.\n", key[i], pthread_self (), + err); assert_perror (err); } @@ -38,24 +39,24 @@ main (int argc, char **argv) pthread_t tid[THREADS]; void des (void *val) - { - assert ((pthread_t) val == pthread_self ()); - } + { + assert ((pthread_t) val == pthread_self ()); + } assert (pthread_getspecific ((pthread_key_t) 0) == NULL); assert (pthread_setspecific ((pthread_key_t) 0, (void *) 0x1) == EINVAL); - for (i = 0; i < KEYS; i ++) + for (i = 0; i < KEYS; i++) err = pthread_key_create (&key[i], des); - for (i = 0; i < THREADS; i ++) + for (i = 0; i < THREADS; i++) { err = pthread_create (&tid[i], 0, thr, 0); if (err) error (1, err, "pthread_create (%d)", i); } - for (i = 0; i < THREADS; i ++) + for (i = 0; i < THREADS; i++) { void *ret; diff --git a/tests/test-8.c b/tests/test-8.c index 85a7f8f..5fc51de 100644 --- a/tests/test-8.c +++ b/tests/test-8.c @@ -13,7 +13,7 @@ int var; void inc_var (void) { - var ++; + var++; } void * @@ -21,7 +21,7 @@ thr (void *arg) { int i; - for (i = 0; i < 500; i ++) + for (i = 0; i < 500; i++) pthread_once (&inc_var_once, inc_var); return 0; @@ -34,7 +34,7 @@ main (int argc, char **argv) int i; pthread_t tid[THREADS]; - for (i = 0; i < THREADS; i ++) + for (i = 0; i < THREADS; i++) { err = pthread_create (&tid[i], 0, thr, 0); if (err) @@ -43,7 +43,7 @@ main (int argc, char **argv) assert (thr (0) == 0); - for (i = 0; i < THREADS; i ++) + for (i = 0; i < THREADS; i++) { void *ret; diff --git a/tests/test-9.c b/tests/test-9.c index 8205157..2667ab6 100644 --- a/tests/test-9.c +++ b/tests/test-9.c @@ -20,9 +20,9 @@ thr (void *arg) foo = pthread_self (); - for (i = 0; i < 500; i ++) + for (i = 0; i < 500; i++) pthread_mutex_lock (arg); - for (i = 0; i < 500; i ++) + for (i = 0; i < 500; i++) pthread_mutex_unlock (arg); assert (foo == pthread_self ()); @@ -62,14 +62,14 @@ main (int argc, char **argv) pthread_mutex_unlock (&mutex); pthread_mutex_unlock (&mutex); - for (i = 0; i < THREADS; i ++) + for (i = 0; i < THREADS; i++) { err = pthread_create (&tid[i], 0, thr, &mutex); if (err) error (1, err, "pthread_create (%d)", i); } - for (i = 0; i < THREADS; i ++) + for (i = 0; i < THREADS; i++) { void *ret; diff --git a/tests/test-__pthread_destroy_specific-skip.c b/tests/test-__pthread_destroy_specific-skip.c index b2c4c0b..9451f8c 100644 --- a/tests/test-__pthread_destroy_specific-skip.c +++ b/tests/test-__pthread_destroy_specific-skip.c @@ -37,7 +37,7 @@ test (void *x) { err = pthread_key_create (&k[i], &d); if (err != 0) - error (1, err, "pthread_key_create %d", i); + error (1, err, "pthread_key_create %d", i); } for (i = 0; i < N_k; i += 1) @@ -45,7 +45,7 @@ test (void *x) k_v[i] = i; err = pthread_setspecific (k[i], &k_v[i]); if (err != 0) - error (1, err, "pthread_setspecific %d", i); + error (1, err, "pthread_setspecific %d", i); } /* Delete every even key. */ @@ -53,7 +53,7 @@ test (void *x) { err = pthread_key_delete (k[i]); if (err != 0) - error (1, err, "pthread_key_delete %d", i); + error (1, err, "pthread_key_delete %d", i); } v = 1; @@ -63,7 +63,8 @@ test (void *x) } -int main(void) +int +main (void) { pthread_t tid; int err; @@ -72,7 +73,7 @@ int main(void) if (err != 0) error (1, err, "pthread_create"); - err = pthread_join(tid, NULL); + err = pthread_join (tid, NULL); if (err) error (1, err, "pthread_join"); |