diff --git a/cfg/bsd.cfg b/cfg/bsd.cfg index cb655f151..f4502f2cc 100644 --- a/cfg/bsd.cfg +++ b/cfg/bsd.cfg @@ -39,24 +39,6 @@ - - false - - - - - - - - - - - - - - - - diff --git a/cfg/gnu.cfg b/cfg/gnu.cfg index 339e1d99c..4aeb309d1 100644 --- a/cfg/gnu.cfg +++ b/cfg/gnu.cfg @@ -128,24 +128,6 @@ - - false - - - - - - - - - - - - - - - - diff --git a/test/cfg/bsd.c b/test/cfg/bsd.c index be350f284..725f6cfe1 100644 --- a/test/cfg/bsd.c +++ b/test/cfg/bsd.c @@ -22,6 +22,26 @@ void verify_timercmp(struct timeval t) (void)timercmp(&t, &t, >); } +// False negative: #9346 +void uninitvar_timercmp(struct timeval t) +{ + struct timeval uninit; + (void)timercmp(&t, &uninit, <); + (void)timercmp(&uninit, &t, <=); + (void)timercmp(&uninit, &uninit, ==); +} + +void nullPointer_timercmp(struct timeval t) +{ + struct timeval *p=0; + // cppcheck-suppress nullPointer + (void)timercmp(&t, p, <); + // cppcheck-suppress nullPointer + (void)timercmp(p, &t, <=); + // cppcheck-suppress nullPointer + (void)timercmp(p, p, ==); +} + // size_t strlcat(char *dst, const char *src, size_t size); void uninitvar_strlcat(char *Ct, const char *S, size_t N) { diff --git a/test/cfg/gnu.c b/test/cfg/gnu.c index 67995f7b7..d97f6e459 100644 --- a/test/cfg/gnu.c +++ b/test/cfg/gnu.c @@ -18,7 +18,7 @@ #endif // #9323, #9331 -void verify_timercmp(struct timeval t) +void syntaxError_timercmp(struct timeval t) { (void)timercmp(&t, &t, <); (void)timercmp(&t, &t, <=); @@ -28,6 +28,26 @@ void verify_timercmp(struct timeval t) (void)timercmp(&t, &t, >); } +// False negative: #9346 +void uninitvar_timercmp(struct timeval t) +{ + struct timeval uninit; + (void)timercmp(&t, &uninit, <); + (void)timercmp(&uninit, &t, <=); + (void)timercmp(&uninit, &uninit, ==); +} + +void nullPointer_timercmp(struct timeval t) +{ + struct timeval *p=0; + // cppcheck-suppress nullPointer + (void)timercmp(&t, p, <); + // cppcheck-suppress nullPointer + (void)timercmp(p, &t, <=); + // cppcheck-suppress nullPointer + (void)timercmp(p, p, ==); +} + // Declaration necessary because there is no specific / portable header. extern void *xcalloc(size_t nmemb, size_t size); extern void *xmalloc(size_t size);