From 7b02b45a76cb3923431a4e7a489269acbde7592d Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 31 Jan 2018 10:58:30 +0100 Subject: [PATCH] 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. --- cfg/posix.cfg | 13 ++----------- test/cfg/posix.c | 8 ++++++++ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/cfg/posix.cfg b/cfg/posix.cfg index 4064dc9d5..b8dc27a92 100644 --- a/cfg/posix.cfg +++ b/cfg/posix.cfg @@ -1834,17 +1834,8 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s - - - false - - - - - - - - + Non reentrant function 'strtok' called. For threadsafe applications it is recommended to use the reentrant replacement function 'strtok_r'. diff --git a/test/cfg/posix.c b/test/cfg/posix.c index 22df7c1ff..4070a7a17 100644 --- a/test/cfg/posix.c +++ b/test/cfg/posix.c @@ -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)