Skip to content

Commit 5991c33

Browse files
committed
posix.cfg: Added support for pthread_attr_getstack() and pthread_attr_setstack().
1 parent ccbc6a3 commit 5991c33

2 files changed

Lines changed: 72 additions & 11 deletions

File tree

cfg/posix.cfg

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,8 +2045,8 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
20452045
<function name="srandom">
20462046
<noreturn>false</noreturn>
20472047
<returnValue type="void"/>
2048-
<!-- It is common practice to call srandom with an uninitialized
2049-
variable. Therefore, no warning shall be generated in this
2048+
<!-- It is common practice to call srandom with an uninitialized
2049+
variable. Therefore, no warning shall be generated in this
20502050
very special case. -->
20512051
<arg nr="1"/>
20522052
</function>
@@ -2324,7 +2324,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
23242324
<not-uninit/>
23252325
<not-bool/>
23262326
</arg>
2327-
</function>
2327+
</function>
23282328
<!-- ssize_t recv(int sockfd, void *buf, size_t len, int flags); -->
23292329
<function name="recv">
23302330
<returnValue type="ssize_t"/>
@@ -4672,6 +4672,23 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
46724672
</arg>
46734673
<warn severity="style" reason="Obsolescent" alternatives="pthread_attr_setstack"/>
46744674
</function>
4675+
<!-- https://man7.org/linux/man-pages/man3/pthread_attr_setstack.3.html -->
4676+
<!-- int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, size_t stacksize); -->
4677+
<function name="pthread_attr_setstack">
4678+
<returnValue type="int"/>
4679+
<noreturn>false</noreturn>
4680+
<use-retval/>
4681+
<arg nr="1" direction="in">
4682+
<not-uninit/>
4683+
<not-null/>
4684+
</arg>
4685+
<arg nr="2" direction="in">
4686+
<not-uninit/>
4687+
</arg>
4688+
<arg nr="3" direction="in">
4689+
<not-uninit/>
4690+
</arg>
4691+
</function>
46754692
<!-- int pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr); -->
46764693
<function name="pthread_attr_getstackaddr">
46774694
<noreturn>false</noreturn>
@@ -4703,6 +4720,25 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
47034720
<valid>0:</valid>
47044721
</arg>
47054722
</function>
4723+
<!-- https://man7.org/linux/man-pages/man3/pthread_attr_getstack.3.html -->
4724+
<!-- int pthread_attr_getstack(const pthread_attr_t *restrict attr, void **restrict stackaddr, size_t *restrict stacksize); -->
4725+
<function name="pthread_attr_getstack">
4726+
<returnValue type="int"/>
4727+
<noreturn>false</noreturn>
4728+
<use-retval/>
4729+
<arg nr="1" direction="in">
4730+
<not-uninit/>
4731+
<not-null/>
4732+
</arg>
4733+
<arg nr="2" direction="out">
4734+
<not-null/>
4735+
<not-uninit/>
4736+
</arg>
4737+
<arg nr="3" direction="out">
4738+
<not-null/>
4739+
<not-uninit/>
4740+
</arg>
4741+
</function>
47064742
<!-- int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize); -->
47074743
<!-- int pthread_attr_getguardsize(const pthread_attr_t *attr, size_t *guardsize); -->
47084744
<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
50165052
</arg>
50175053
<arg nr="5" direction="out">
50185054
<not-null/>
5019-
</arg>
5055+
</arg>
50205056
</function>
50215057
<!-- https://man7.org/linux/man-pages/man3/getgrnam.3.html -->
50225058
<!-- 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
50435079
</arg>
50445080
<arg nr="5" direction="out">
50455081
<not-null/>
5046-
</arg>
5047-
</function>
5082+
</arg>
5083+
</function>
50485084
<!-- char *getlogin(void); -->
50495085
<function name="getlogin">
50505086
<returnValue type="char *"/>
@@ -5158,8 +5194,8 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
51585194
<not-null/>
51595195
<not-uninit/>
51605196
<not-bool/>
5161-
<minsize type="argvalue" arg="2"/>
5162-
<strz/>
5197+
<minsize type="argvalue" arg="2"/>
5198+
<strz/>
51635199
</arg>
51645200
<arg nr="2" direction="in">
51655201
<not-uninit/>
@@ -5168,7 +5204,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
51685204
</arg>
51695205
</function>
51705206
<!-- http://man7.org/linux/man-pages/man3/scandir.3.html -->
5171-
<!-- int scandir(const char *dirp,
5207+
<!-- int scandir(const char *dirp,
51725208
struct dirent ***namelist,
51735209
int (*filter)(const struct dirent *),
51745210
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
52405276
</arg>
52415277
</function>
52425278
<!-- https://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html -->
5243-
<!-- int execv(const char *path, char *const argv[]);
5279+
<!-- int execv(const char *path, char *const argv[]);
52445280
int execvp(const char *file, char *const argv[]); -->
52455281
<function name="execv,execvp">
52465282
<returnValue type="int"/>
@@ -6230,7 +6266,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
62306266
<define name="S_IFDIR" value="0040000"/>
62316267
<define name="S_IFCHR" value="0020000"/>
62326268
<define name="S_IFIFO" value="0010000"/>
6233-
<!-- see http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html
6269+
<!-- see http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html
62346270
Some other signals are defined in std.cfg! -->
62356271
<define name="SIGHUP" value="1"/>
62366272
<define name="SIGQUIT" value="3"/>

test/cfg/posix.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,31 @@
3636
#include <string.h>
3737
#include <strings.h>
3838

39+
void nullPointer_pthread_attr_getstack(const pthread_attr_t *attr, void *stackaddr, size_t stacksize) {
40+
// cppcheck-suppress nullPointer
41+
(void) pthread_attr_getstack(NULL, &stackaddr, &stacksize);
42+
// cppcheck-suppress nullPointer
43+
(void) pthread_attr_getstack(attr, NULL, &stacksize);
44+
// cppcheck-suppress nullPointer
45+
(void) pthread_attr_getstack(attr, &stackaddr, NULL);
46+
// cppcheck-suppress nullPointer
47+
(void) pthread_attr_getstack(NULL, NULL, &stacksize);
48+
// cppcheck-suppress nullPointer
49+
(void) pthread_attr_getstack(NULL, &stackaddr, NULL);
50+
// cppcheck-suppress nullPointer
51+
(void) pthread_attr_getstack(attr, NULL, NULL);
52+
// cppcheck-suppress nullPointer
53+
(void) pthread_attr_getstack(NULL, NULL, NULL);
54+
}
55+
56+
void nullPointer_pthread_attr_setstack(pthread_attr_t *attr) {
57+
// cppcheck-suppress nullPointer
58+
(void) pthread_attr_setstack(NULL, NULL, 0);
59+
(void) pthread_attr_setstack(attr, NULL, 0);
60+
// cppcheck-suppress nullPointer
61+
(void) pthread_attr_setstack(NULL, (void*) 1, 0);
62+
}
63+
3964
void nullPointer_setkey(const char *key)
4065
{
4166
// cppcheck-suppress nullPointer

0 commit comments

Comments
 (0)