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. Signed-off-by: Chris Friedt <cfriedt@meta.com>
This commit is contained in:
parent
7921ed8bb9
commit
1f20503e46
1 changed files with 5 additions and 4 deletions
|
@ -319,9 +319,10 @@ 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,
|
||||
"stack attribute addresses do not match!");
|
||||
zassert_equal_ptr(&stack_e[i][0], stackaddr,
|
||||
"stack attribute addresses do not match!");
|
||||
zassert_equal(STACKS, stacksize, "stack sizes do not match!");
|
||||
|
||||
pthread_attr_getstacksize(&attr[i], &stacksize);
|
||||
|
@ -446,7 +447,7 @@ ZTEST(posix_apis, test_posix_pthread_error_condition)
|
|||
zassert_equal(pthread_setschedparam(PTHREAD_INVALID, policy, ¶m), 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");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue