From e89abc5d30d0ae62572e8e83792d19502c0e8a02 Mon Sep 17 00:00:00 2001 From: Oleksandr Labetskyi Date: Fri, 28 Aug 2026 07:28:29 +0000 Subject: [PATCH 1/7] Fix #14758 Improve cfg: Add a list of pthread functions to posix lib --- cfg/posix.cfg | 161 +++++++++++++++++++++++++++++++++++++++++++++++ test/cfg/posix.c | 97 ++++++++++++++++++++++++++++ 2 files changed, 258 insertions(+) diff --git a/cfg/posix.cfg b/cfg/posix.cfg index 751142bacc1..8022a97702b 100644 --- a/cfg/posix.cfg +++ b/cfg/posix.cfg @@ -4600,6 +4600,142 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s + + + false + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + false + + + + + + + + + + + false + + + + + + + + false + + + + + + + + + + + + false + + + + + + + + + false + + + + + + + + false + + + + + + + + + + + + false + + + + + + + + 0:2 + + + + + false + + + + 0:2 + + + + + + + + false + + + + 0:2 + + + + + + + + false + + + + + + @@ -6437,6 +6573,31 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/cfg/posix.c b/test/cfg/posix.c index 52607fe3a98..6675c51ebb7 100644 --- a/test/cfg/posix.c +++ b/test/cfg/posix.c @@ -1508,3 +1508,100 @@ void invalidFunctionArg_nice(int inc) // cppcheck-suppress invalidFunctionArg nice(+20); } + +void pthread_cond_wait_test(pthread_cond_t *cond, pthread_mutex_t *mutex) +{ + (void)pthread_cond_wait(cond, mutex); +} + +void pthread_cond_timedwait_test(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime) +{ + // cppcheck-suppress nullPointer + (void)pthread_cond_timedwait(cond, mutex, NULL); + (void)pthread_cond_timedwait(cond, mutex, abstime); +} + +void pthread_cond_init_test(pthread_cond_t *cond, const pthread_condattr_t *attr) +{ + // cppcheck-suppress nullPointer + (void)pthread_cond_init(cond, NULL); + (void)pthread_cond_init(cond, attr); +} + +void pthread_cond_destroy_test(pthread_cond_t *cond) +{ + (void)pthread_cond_destroy(cond); +} + +void pthread_cleanup_push_test(void (*routine)(void *), void *arg) +{ + pthread_cleanup_push(routine, arg); + pthread_cleanup_pop(0); +} + +void pthread_mutexattr_init_test(pthread_mutexattr_t *attr) +{ + (void)pthread_mutexattr_init(attr); +} + +void pthread_mutexattr_destroy_test(pthread_mutexattr_t *attr) +{ + (void)pthread_mutexattr_destroy(attr); +} + +void pthread_mutexattr_settype_test(pthread_mutexattr_t *attr, int type) +{ + (void)pthread_mutexattr_settype(attr, type); +} + +void pthread_mutexattr_gettype_test(pthread_mutexattr_t *attr, int *type) +{ + (void)pthread_mutexattr_gettype(attr, type); +} + +void pthread_setcancelstate_test(int state, int *oldstate) +{ + (void)pthread_setcancelstate(state, oldstate); +} + +void pthread_setcanceltype_test(int type, int *oldtype) +{ + (void)pthread_setcanceltype(type, oldtype); +} + +void pthread_cancel_test(pthread_t thread) +{ + (void)pthread_cancel(thread); +} + +void pthread_define_test() +{ + PTHREAD_STACK_MIN; + PTHREAD_CANCEL_ASYNCHRONOUS; + PTHREAD_CANCEL_ENABLE; + PTHREAD_CANCEL_DEFERRED; + PTHREAD_CANCEL_DISABLE; + PTHREAD_CANCELED; + pthread_cond_t cond = PTHREAD_COND_INITIALIZER; + (void)cond; + PTHREAD_CREATE_DETACHED; + PTHREAD_CREATE_JOINABLE; + PTHREAD_EXPLICIT_SCHED; + PTHREAD_INHERIT_SCHED; + PTHREAD_MUTEX_DEFAULT; + PTHREAD_MUTEX_ERRORCHECK; + PTHREAD_MUTEX_NORMAL; + pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; + (void)mutex; + PTHREAD_MUTEX_RECURSIVE; + PTHREAD_ONCE_INIT; + PTHREAD_PRIO_INHERIT; + PTHREAD_PRIO_NONE; + PTHREAD_PRIO_PROTECT; + PTHREAD_PROCESS_SHARED; + PTHREAD_PROCESS_PRIVATE; + pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER; + (void)rwlock; + PTHREAD_SCOPE_PROCESS; + PTHREAD_SCOPE_SYSTEM; +} \ No newline at end of file From 3b6a5331bf0e6805c50dcc834906b5c57b60e81f Mon Sep 17 00:00:00 2001 From: Oleksandr Labetskyi Date: Fri, 28 Aug 2026 11:54:16 +0000 Subject: [PATCH 2/7] Small fix --- cfg/posix.cfg | 4 ++-- test/cfg/posix.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cfg/posix.cfg b/cfg/posix.cfg index 8022a97702b..9050db777e1 100644 --- a/cfg/posix.cfg +++ b/cfg/posix.cfg @@ -6573,7 +6573,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s - + @@ -6589,7 +6589,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s - + diff --git a/test/cfg/posix.c b/test/cfg/posix.c index 6675c51ebb7..9205d146313 100644 --- a/test/cfg/posix.c +++ b/test/cfg/posix.c @@ -1528,7 +1528,7 @@ void pthread_cond_init_test(pthread_cond_t *cond, const pthread_condattr_t *attr (void)pthread_cond_init(cond, attr); } -void pthread_cond_destroy_test(pthread_cond_t *cond) +void pthread_cond_destroy_test(const pthread_cond_t *cond) { (void)pthread_cond_destroy(cond); } @@ -1549,12 +1549,12 @@ void pthread_mutexattr_destroy_test(pthread_mutexattr_t *attr) (void)pthread_mutexattr_destroy(attr); } -void pthread_mutexattr_settype_test(pthread_mutexattr_t *attr, int type) +void pthread_mutexattr_settype_test(const pthread_mutexattr_t *attr, int type) { (void)pthread_mutexattr_settype(attr, type); } -void pthread_mutexattr_gettype_test(pthread_mutexattr_t *attr, int *type) +void pthread_mutexattr_gettype_test(const pthread_mutexattr_t *attr, int *type) { (void)pthread_mutexattr_gettype(attr, type); } From 621b69479c773089ac16359d2f432589d0e543bb Mon Sep 17 00:00:00 2001 From: Oleksandr Labetskyi Date: Fri, 28 Aug 2026 12:06:41 +0000 Subject: [PATCH 3/7] Small fix --- cfg/posix.cfg | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/cfg/posix.cfg b/cfg/posix.cfg index 9050db777e1..1b680e5d3b8 100644 --- a/cfg/posix.cfg +++ b/cfg/posix.cfg @@ -6574,30 +6574,30 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s - - - - - + + + + + - - - - - - - + + + + + + + - + - - - - - + + + + + - - + + From a29864a3f4f1b8e607ae585a0d0090594b8893b0 Mon Sep 17 00:00:00 2001 From: Oleksandr Labetskyi Date: Fri, 28 Aug 2026 12:11:11 +0000 Subject: [PATCH 4/7] value changes --- cfg/posix.cfg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cfg/posix.cfg b/cfg/posix.cfg index 1b680e5d3b8..07721f43a9b 100644 --- a/cfg/posix.cfg +++ b/cfg/posix.cfg @@ -6579,7 +6579,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s - + @@ -6587,7 +6587,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s - + @@ -6595,7 +6595,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s - + From e5442fd0ae4fe6290fc23bf8d3640d498556e022 Mon Sep 17 00:00:00 2001 From: Oleksandr Labetskyi Date: Fri, 28 Aug 2026 12:28:01 +0000 Subject: [PATCH 5/7] value changes 2 --- cfg/posix.cfg | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cfg/posix.cfg b/cfg/posix.cfg index 07721f43a9b..01b4952e856 100644 --- a/cfg/posix.cfg +++ b/cfg/posix.cfg @@ -6579,7 +6579,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s - + @@ -6587,7 +6587,8 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s - + + @@ -6595,7 +6596,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s - + From d4f76da864245f4ddcdebe72f85a4d9883d74047 Mon Sep 17 00:00:00 2001 From: Oleksandr Labetskyi Date: Fri, 28 Aug 2026 14:35:50 +0000 Subject: [PATCH 6/7] Mac OS fix --- test/cfg/posix.c | 1 + 1 file changed, 1 insertion(+) diff --git a/test/cfg/posix.c b/test/cfg/posix.c index 9205d146313..474710b0894 100644 --- a/test/cfg/posix.c +++ b/test/cfg/posix.c @@ -37,6 +37,7 @@ #include #if defined(__APPLE__) #include +#include #endif #if !defined(__APPLE__) #include From ea55c1e0d1c80219c349aee89c56d9392ca75e96 Mon Sep 17 00:00:00 2001 From: Oleksandr Labetskyi Date: Fri, 28 Aug 2026 16:08:45 +0000 Subject: [PATCH 7/7] Mac OS fix 2 --- cfg/posix.cfg | 2 +- test/cfg/posix.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cfg/posix.cfg b/cfg/posix.cfg index 01b4952e856..e0de433e1f1 100644 --- a/cfg/posix.cfg +++ b/cfg/posix.cfg @@ -6590,7 +6590,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s - + diff --git a/test/cfg/posix.c b/test/cfg/posix.c index 474710b0894..82cfd950792 100644 --- a/test/cfg/posix.c +++ b/test/cfg/posix.c @@ -1595,7 +1595,8 @@ void pthread_define_test() pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; (void)mutex; PTHREAD_MUTEX_RECURSIVE; - PTHREAD_ONCE_INIT; + pthread_once_t once_block = PTHREAD_ONCE_INIT; + (void)once_block; PTHREAD_PRIO_INHERIT; PTHREAD_PRIO_NONE; PTHREAD_PRIO_PROTECT;