[PATCH 5/6] nptl: Convert some rwlock tests to use libsupport
Florian Weimer
fweimer@redhat.com
Fri Apr 5 11:06:00 GMT 2019
* Mike Crowe:
> if (pthread_rwlock_wrlock (&r) != 0)
> if (pthread_barrier_init (&b, NULL, 2) != 0)
We have xpthread_rwlock_wrlock and xpthread_barrier_init, which will
perform the error checking for you. Similarly for a few more functions.
> if (clock_gettime (CLOCK_REALTIME, &ts) != 0)
> - {
> - puts ("clock_gettime failed");
> - return 1;
> - }
> + FAIL_RET ("clock_gettime failed");
Perhaps it's time to introduce xclock_gettime?
> int e = pthread_rwlock_timedrdlock (&r, &ts);
> if (e == 0)
> - {
> - puts ("first rwlock_timedrdlock did not fail");
> - result = 1;
> - }
> + FAIL_PRINT ("first rwlock_timedrdlock did not fail");
> else if (e != EINVAL)
> - {
> - puts ("first rwlock_timedrdlock did not return EINVAL");
> - result = 1;
> - }
> + FAIL_PRINT ("first rwlock_timedrdlock did not return EINVAL");
You could use
TEST_COMPARE (pthread_rwlock_timedrdlock (&r, &ts), EINVAL);
instead.
Thanks,
Florian
More information about the Libc-alpha
mailing list