tests: posix: common: avoid direct pthread_attr_t field access
Avoid directly accessing fields in `pthread_attr_t` and only
access / mutate them with POSIX functions.
@@ -319,8 +319,9 @@ ZTEST(posix_apis, test_posix_pthread_execution)
/* TESTPOINTS: Retrieve set stack attributes and compare */
pthread_attr_setstack(&attr[i], &stack_e[i][0], STACKS);
+ stackaddr = NULL;
pthread_attr_getstack(&attr[i], &stackaddr, &stacksize);
- zassert_equal_ptr(attr[i].stack, stackaddr,
+ zassert_equal_ptr(&stack_e[i][0], stackaddr,
"stack attribute addresses do not match!");
zassert_equal(STACKS, stacksize, "stack sizes do not match!");
@@ -446,7 +447,7 @@ ZTEST(posix_apis, test_posix_pthread_error_condition)
zassert_equal(pthread_setschedparam(PTHREAD_INVALID, policy, &param), ESRCH,
"set schedparam with NULL error");
- attr.initialized = 0U;
+ attr = (pthread_attr_t){0};
zassert_equal(pthread_attr_getdetachstate(&attr, &detach),
EINVAL, "get detach state error");
@@ -571,7 +572,7 @@ ZTEST(posix_apis, test_posix_pthread_create_negative)
ret = pthread_attr_init(&attr1);
zassert_false(ret, "attr1 initialized failed");
- attr1.stack = NULL;
+ attr1 = (pthread_attr_t){0};
ret = pthread_create(&pthread1, &attr1, create_thread1, (void *)1);
zassert_equal(ret, EINVAL, "create successful with NULL attr");
