posix library: Add strtok tests (#1069)

* posix library: Add strtok tests

In the posix library there is the same configuration for strtok but a
warning is added.

* posix.cfg: Remove redundant configuration for strtok, add comment.
This commit is contained in:
Sebastian 2018-01-31 10:58:30 +01:00 committed by amai2012
parent a8a35fab2e
commit 7b02b45a76
2 changed files with 10 additions and 11 deletions

View File

@ -1834,17 +1834,8 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
</function> </function>
<!-- char *strtok(char *s, const char *ct); --> <!-- char *strtok(char *s, const char *ct); -->
<function name="strtok,std::strtok"> <function name="strtok,std::strtok">
<returnValue type="char *"/> <!-- Already configured in std.cfg. Add only a warning for POSIX that a
<pure/> threadsafe function exists that should be used. -->
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
<not-uninit/>
</arg>
<arg nr="2">
<not-null/>
<not-uninit/>
</arg>
<warn severity="portability">Non reentrant function 'strtok' called. For threadsafe applications it is recommended to use the reentrant replacement function 'strtok_r'.</warn> <warn severity="portability">Non reentrant function 'strtok' called. For threadsafe applications it is recommended to use the reentrant replacement function 'strtok_r'.</warn>
</function> </function>
<!-- char *strtok_r(char *str, const char *delim, char **saveptr); --> <!-- char *strtok_r(char *str, const char *delim, char **saveptr); -->

View File

@ -75,6 +75,9 @@ void nullPointer(char *p, int fd)
// cppcheck-suppress leakReturnValNotUsed // cppcheck-suppress leakReturnValNotUsed
// cppcheck-suppress nullPointer // cppcheck-suppress nullPointer
fdopen(fd, NULL); fdopen(fd, NULL);
// cppcheck-suppress strtokCalled
// cppcheck-suppress nullPointer
strtok(p, NULL);
} }
void memleak_getaddrinfo() void memleak_getaddrinfo()
@ -239,6 +242,11 @@ void uninitvar(int fd)
// cppcheck-suppress leakReturnValNotUsed // cppcheck-suppress leakReturnValNotUsed
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
fdopen(x, "rw"); fdopen(x, "rw");
char *strtok_arg1;
// cppcheck-suppress strtokCalled
// cppcheck-suppress uninitvar
strtok(strtok_arg1, ";");
} }
void uninitvar_getcwd(void) void uninitvar_getcwd(void)