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>
<!-- char *strtok(char *s, const char *ct); -->
<function name="strtok,std::strtok">
<returnValue type="char *"/>
<pure/>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
<not-uninit/>
</arg>
<arg nr="2">
<not-null/>
<not-uninit/>
</arg>
<!-- Already configured in std.cfg. Add only a warning for POSIX that a
threadsafe function exists that should be used. -->
<warn severity="portability">Non reentrant function 'strtok' called. For threadsafe applications it is recommended to use the reentrant replacement function 'strtok_r'.</warn>
</function>
<!-- 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 nullPointer
fdopen(fd, NULL);
// cppcheck-suppress strtokCalled
// cppcheck-suppress nullPointer
strtok(p, NULL);
}
void memleak_getaddrinfo()
@ -239,6 +242,11 @@ void uninitvar(int fd)
// cppcheck-suppress leakReturnValNotUsed
// cppcheck-suppress uninitvar
fdopen(x, "rw");
char *strtok_arg1;
// cppcheck-suppress strtokCalled
// cppcheck-suppress uninitvar
strtok(strtok_arg1, ";");
}
void uninitvar_getcwd(void)