From dad1a68e517075f6a9e2869262f0df89965caf89 Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Thu, 21 Apr 2022 08:31:22 +0200 Subject: [PATCH] posix.cfg: Fixed FP bufferOverlap-warning of bcopy() and added more tests. --- cfg/posix.cfg | 2 +- test/cfg/posix.c | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/cfg/posix.cfg b/cfg/posix.cfg index 37801fe58..bb7f70ca3 100644 --- a/cfg/posix.cfg +++ b/cfg/posix.cfg @@ -3935,11 +3935,11 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s + false - diff --git a/test/cfg/posix.c b/test/cfg/posix.c index ed5e7bb11..49775acce 100644 --- a/test/cfg/posix.c +++ b/test/cfg/posix.c @@ -300,8 +300,20 @@ void overlappingWriteFunction_bcopy(char *buf, const size_t count) // cppcheck-suppress bcopyCalled bcopy(&buf[0], &buf[3], 3U); // no-overlap // cppcheck-suppress bcopyCalled - // cppcheck-suppress overlappingWriteFunction - bcopy(&buf[0], &buf[3], 4U); + bcopy(&buf[0], &buf[3], 4U); // The result is correct, even when both areas overlap. +} + +void nullPointer_bcopy(const void *src, void *dest, size_t n) +{ + // No warning shall be shown: + // cppcheck-suppress bcopyCalled + bcopy(src, dest, n); + // cppcheck-suppress bcopyCalled + // cppcheck-suppress nullPointer + bcopy(NULL, dest, n); + // cppcheck-suppress bcopyCalled + // cppcheck-suppress nullPointer + bcopy(src, NULL, n); } void overlappingWriteFunction_memccpy(unsigned char *src, unsigned char *dest, int c, size_t count)