From 3d146aed05c37d170e3b16e9a42f14361cb82409 Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Wed, 23 Apr 2025 08:44:27 -0400 Subject: [PATCH] tests: posix: pthread: correct cases for pthread_timedjoin_np() pthread_timedjoin_np() is allowed to take a negative tv_sec parameter, since that is still a valid timespec. Signed-off-by: Chris Friedt --- tests/posix/common/src/pthread.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/posix/common/src/pthread.c b/tests/posix/common/src/pthread.c index 3801d3b4186..035730ee4dc 100644 --- a/tests/posix/common/src/pthread.c +++ b/tests/posix/common/src/pthread.c @@ -404,9 +404,8 @@ ZTEST(pthread, test_pthread_timedjoin) struct timespec not_done; struct timespec done; struct timespec invalid[] = { - [0] = {.tv_sec = -1}, - [1] = {.tv_nsec = -1}, - [2] = {.tv_nsec = NSEC_PER_SEC}, + {.tv_nsec = -1}, + {.tv_nsec = NSEC_PER_SEC}, }; /* setup timespecs when the thread is still running and when it is done */ @@ -426,7 +425,7 @@ ZTEST(pthread, test_pthread_timedjoin) /* Creating a thread that exits after 200ms*/ zassert_ok(pthread_create(&th, NULL, timedjoin_thread, INT_TO_POINTER(sleep_duration_ms))); - /* pthread_timedjoin-np must return -EINVAL for invalid struct timespecs */ + /* pthread_timedjoin-np must return EINVAL for invalid struct timespecs */ zassert_equal(pthread_timedjoin_np(th, &ret, NULL), EINVAL); for (size_t i = 0; i < ARRAY_SIZE(invalid); ++i) { zassert_equal(pthread_timedjoin_np(th, &ret, &invalid[i]), EINVAL);