posix.cfg: Added support for pthread_attr_getstack() and pthread_attr_setstack().

This commit is contained in:
orbitcowboy 2022-12-22 10:07:50 +01:00
parent ccbc6a3b72
commit 5991c33b0e
2 changed files with 72 additions and 11 deletions

View File

@ -2045,8 +2045,8 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
<function name="srandom">
<noreturn>false</noreturn>
<returnValue type="void"/>
<!-- It is common practice to call srandom with an uninitialized
variable. Therefore, no warning shall be generated in this
<!-- It is common practice to call srandom with an uninitialized
variable. Therefore, no warning shall be generated in this
very special case. -->
<arg nr="1"/>
</function>
@ -2324,7 +2324,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
<not-uninit/>
<not-bool/>
</arg>
</function>
</function>
<!-- ssize_t recv(int sockfd, void *buf, size_t len, int flags); -->
<function name="recv">
<returnValue type="ssize_t"/>
@ -4672,6 +4672,23 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
</arg>
<warn severity="style" reason="Obsolescent" alternatives="pthread_attr_setstack"/>
</function>
<!-- https://man7.org/linux/man-pages/man3/pthread_attr_setstack.3.html -->
<!-- int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, size_t stacksize); -->
<function name="pthread_attr_setstack">
<returnValue type="int"/>
<noreturn>false</noreturn>
<use-retval/>
<arg nr="1" direction="in">
<not-uninit/>
<not-null/>
</arg>
<arg nr="2" direction="in">
<not-uninit/>
</arg>
<arg nr="3" direction="in">
<not-uninit/>
</arg>
</function>
<!-- int pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr); -->
<function name="pthread_attr_getstackaddr">
<noreturn>false</noreturn>
@ -4703,6 +4720,25 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
<valid>0:</valid>
</arg>
</function>
<!-- https://man7.org/linux/man-pages/man3/pthread_attr_getstack.3.html -->
<!-- int pthread_attr_getstack(const pthread_attr_t *restrict attr, void **restrict stackaddr, size_t *restrict stacksize); -->
<function name="pthread_attr_getstack">
<returnValue type="int"/>
<noreturn>false</noreturn>
<use-retval/>
<arg nr="1" direction="in">
<not-uninit/>
<not-null/>
</arg>
<arg nr="2" direction="out">
<not-null/>
<not-uninit/>
</arg>
<arg nr="3" direction="out">
<not-null/>
<not-uninit/>
</arg>
</function>
<!-- int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize); -->
<!-- int pthread_attr_getguardsize(const pthread_attr_t *attr, size_t *guardsize); -->
<function name="pthread_attr_getstacksize,pthread_attr_getguardsize">
@ -5016,7 +5052,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
</arg>
<arg nr="5" direction="out">
<not-null/>
</arg>
</arg>
</function>
<!-- https://man7.org/linux/man-pages/man3/getgrnam.3.html -->
<!-- int getgrgid_r(gid_t gid, struct group *restrict grp, char *restrict buf, size_t buflen, struct group **restrict result); -->
@ -5043,8 +5079,8 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
</arg>
<arg nr="5" direction="out">
<not-null/>
</arg>
</function>
</arg>
</function>
<!-- char *getlogin(void); -->
<function name="getlogin">
<returnValue type="char *"/>
@ -5158,8 +5194,8 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
<not-null/>
<not-uninit/>
<not-bool/>
<minsize type="argvalue" arg="2"/>
<strz/>
<minsize type="argvalue" arg="2"/>
<strz/>
</arg>
<arg nr="2" direction="in">
<not-uninit/>
@ -5168,7 +5204,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
</arg>
</function>
<!-- http://man7.org/linux/man-pages/man3/scandir.3.html -->
<!-- int scandir(const char *dirp,
<!-- int scandir(const char *dirp,
struct dirent ***namelist,
int (*filter)(const struct dirent *),
int (*compar)(const struct dirent **, const struct dirent **));-->
@ -5240,7 +5276,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
</arg>
</function>
<!-- https://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html -->
<!-- int execv(const char *path, char *const argv[]);
<!-- int execv(const char *path, char *const argv[]);
int execvp(const char *file, char *const argv[]); -->
<function name="execv,execvp">
<returnValue type="int"/>
@ -6230,7 +6266,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
<define name="S_IFDIR" value="0040000"/>
<define name="S_IFCHR" value="0020000"/>
<define name="S_IFIFO" value="0010000"/>
<!-- see http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html
<!-- see http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html
Some other signals are defined in std.cfg! -->
<define name="SIGHUP" value="1"/>
<define name="SIGQUIT" value="3"/>

View File

@ -36,6 +36,31 @@
#include <string.h>
#include <strings.h>
void nullPointer_pthread_attr_getstack(const pthread_attr_t *attr, void *stackaddr, size_t stacksize) {
// cppcheck-suppress nullPointer
(void) pthread_attr_getstack(NULL, &stackaddr, &stacksize);
// cppcheck-suppress nullPointer
(void) pthread_attr_getstack(attr, NULL, &stacksize);
// cppcheck-suppress nullPointer
(void) pthread_attr_getstack(attr, &stackaddr, NULL);
// cppcheck-suppress nullPointer
(void) pthread_attr_getstack(NULL, NULL, &stacksize);
// cppcheck-suppress nullPointer
(void) pthread_attr_getstack(NULL, &stackaddr, NULL);
// cppcheck-suppress nullPointer
(void) pthread_attr_getstack(attr, NULL, NULL);
// cppcheck-suppress nullPointer
(void) pthread_attr_getstack(NULL, NULL, NULL);
}
void nullPointer_pthread_attr_setstack(pthread_attr_t *attr) {
// cppcheck-suppress nullPointer
(void) pthread_attr_setstack(NULL, NULL, 0);
(void) pthread_attr_setstack(attr, NULL, 0);
// cppcheck-suppress nullPointer
(void) pthread_attr_setstack(NULL, (void*) 1, 0);
}
void nullPointer_setkey(const char *key)
{
// cppcheck-suppress nullPointer