posix.cfg: Add some pthread_mutex_* functions. (#1320)
References: http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_init.html http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_lock.html
This commit is contained in:
parent
a44b4ba441
commit
f862cf603f
|
@ -2928,6 +2928,56 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
|
||||||
</arg>
|
</arg>
|
||||||
<warn severity="style" reason="Obsolescent" alternatives="pthread_attr_getstack"/>
|
<warn severity="style" reason="Obsolescent" alternatives="pthread_attr_getstack"/>
|
||||||
</function>
|
</function>
|
||||||
|
<!-- int pthread_mutex_init(pthread_mutex_t *restrict mutex, const pthread_mutexattr_t *restrict attr); -->
|
||||||
|
<function name="pthread_mutex_init">
|
||||||
|
<noreturn>false</noreturn>
|
||||||
|
<returnValue type="int"/>
|
||||||
|
<arg nr="1">
|
||||||
|
<not-null/>
|
||||||
|
</arg>
|
||||||
|
<arg nr="2">
|
||||||
|
<!-- NULL is valid -->
|
||||||
|
</arg>
|
||||||
|
</function>
|
||||||
|
<!-- int pthread_mutex_destroy(pthread_mutex_t *mutex); -->
|
||||||
|
<function name="pthread_mutex_destroy">
|
||||||
|
<noreturn>false</noreturn>
|
||||||
|
<returnValue type="int"/>
|
||||||
|
<arg nr="1">
|
||||||
|
<not-null/>
|
||||||
|
<not-uninit/>
|
||||||
|
</arg>
|
||||||
|
</function>
|
||||||
|
<!-- int pthread_mutex_lock(pthread_mutex_t *mutex); -->
|
||||||
|
<function name="pthread_mutex_lock">
|
||||||
|
<noreturn>false</noreturn>
|
||||||
|
<leak-ignore/>
|
||||||
|
<returnValue type="int"/>
|
||||||
|
<arg nr="1">
|
||||||
|
<not-null/>
|
||||||
|
<not-uninit/>
|
||||||
|
</arg>
|
||||||
|
</function>
|
||||||
|
<!-- int pthread_mutex_trylock(pthread_mutex_t *mutex); -->
|
||||||
|
<function name="pthread_mutex_trylock">
|
||||||
|
<noreturn>false</noreturn>
|
||||||
|
<leak-ignore/>
|
||||||
|
<returnValue type="int"/>
|
||||||
|
<arg nr="1">
|
||||||
|
<not-null/>
|
||||||
|
<not-uninit/>
|
||||||
|
</arg>
|
||||||
|
</function>
|
||||||
|
<!-- int pthread_mutex_unlock(pthread_mutex_t *mutex); -->
|
||||||
|
<function name="pthread_mutex_unlock">
|
||||||
|
<noreturn>false</noreturn>
|
||||||
|
<leak-ignore/>
|
||||||
|
<returnValue type="int"/>
|
||||||
|
<arg nr="1">
|
||||||
|
<not-null/>
|
||||||
|
<not-uninit/>
|
||||||
|
</arg>
|
||||||
|
</function>
|
||||||
<!-- char *tempnam(const char *dir, const char *pfx); -->
|
<!-- char *tempnam(const char *dir, const char *pfx); -->
|
||||||
<function name="tempnam">
|
<function name="tempnam">
|
||||||
<use-retval/>
|
<use-retval/>
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
void bufferAccessOutOfBounds(int fd)
|
void bufferAccessOutOfBounds(int fd)
|
||||||
{
|
{
|
||||||
|
@ -54,7 +55,7 @@ void bufferAccessOutOfBounds(int fd)
|
||||||
gethostname(a, 6);
|
gethostname(a, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nullPointer(char *p, int fd)
|
void nullPointer(char *p, int fd, pthread_mutex_t mutex)
|
||||||
{
|
{
|
||||||
// cppcheck-suppress ignoredReturnValue
|
// cppcheck-suppress ignoredReturnValue
|
||||||
isatty(0);
|
isatty(0);
|
||||||
|
@ -88,6 +89,19 @@ void nullPointer(char *p, int fd)
|
||||||
// cppcheck-suppress strtokCalled
|
// cppcheck-suppress strtokCalled
|
||||||
// cppcheck-suppress nullPointer
|
// cppcheck-suppress nullPointer
|
||||||
strtok(p, NULL);
|
strtok(p, NULL);
|
||||||
|
|
||||||
|
// cppcheck-suppress nullPointer
|
||||||
|
pthread_mutex_init(NULL, NULL);
|
||||||
|
// Second argument can be NULL
|
||||||
|
pthread_mutex_init(&mutex, NULL);
|
||||||
|
// cppcheck-suppress nullPointer
|
||||||
|
pthread_mutex_destroy(NULL);
|
||||||
|
// cppcheck-suppress nullPointer
|
||||||
|
pthread_mutex_lock(NULL);
|
||||||
|
// cppcheck-suppress nullPointer
|
||||||
|
pthread_mutex_trylock(NULL);
|
||||||
|
// cppcheck-suppress nullPointer
|
||||||
|
pthread_mutex_unlock(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void memleak_getaddrinfo()
|
void memleak_getaddrinfo()
|
||||||
|
@ -207,6 +221,7 @@ void uninitvar(int fd)
|
||||||
int decimal, sign;
|
int decimal, sign;
|
||||||
double d;
|
double d;
|
||||||
void *p;
|
void *p;
|
||||||
|
pthread_mutex_t mutex;
|
||||||
// cppcheck-suppress uninitvar
|
// cppcheck-suppress uninitvar
|
||||||
write(x,"ab",2);
|
write(x,"ab",2);
|
||||||
// TODO cppcheck-suppress uninitvar
|
// TODO cppcheck-suppress uninitvar
|
||||||
|
@ -259,6 +274,18 @@ void uninitvar(int fd)
|
||||||
// cppcheck-suppress strtokCalled
|
// cppcheck-suppress strtokCalled
|
||||||
// cppcheck-suppress uninitvar
|
// cppcheck-suppress uninitvar
|
||||||
strtok(strtok_arg1, ";");
|
strtok(strtok_arg1, ";");
|
||||||
|
|
||||||
|
// cppcheck-suppress uninitvar
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
|
// cppcheck-suppress uninitvar
|
||||||
|
pthread_mutex_trylock(&mutex);
|
||||||
|
// cppcheck-suppress uninitvar
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
|
// after initialization it must be OK to call lock, trylock and unlock for this mutex
|
||||||
|
pthread_mutex_init(&mutex, NULL);
|
||||||
|
pthread_mutex_lock(&mutex);
|
||||||
|
pthread_mutex_trylock(&mutex);
|
||||||
|
pthread_mutex_unlock(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uninitvar_getcwd(void)
|
void uninitvar_getcwd(void)
|
||||||
|
|
Loading…
Reference in New Issue