diff --git a/test/cfg/posix.c b/test/cfg/posix.c index de86d771c..affa721a1 100644 --- a/test/cfg/posix.c +++ b/test/cfg/posix.c @@ -27,6 +27,14 @@ #include #include +void overlappingWriteFunction_swab(char *src, char *dest, ssize_t n) +{ + // No warning shall be shown: + swab(dest, src, n); + // cppcheck-suppress overlappingWriteFunction + swab(src, src+3, 4); +} + bool invalidFunctionArgBool_isascii(bool b, int c) { // cppcheck-suppress invalidFunctionArgBool diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index 474f1f79a..d45c8a695 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -30,6 +30,22 @@ #include #include +void overlappingWriteFunction_wcscat(wchar_t *src, wchar_t *dest) +{ + // No warning shall be shown: + (void)wcscat(dest, src); + // cppcheck-suppress overlappingWriteFunction + (void)wcscat(src, src); +} + +char * overlappingWriteFunction_strcat(char *src, char *dest) +{ + // No warning shall be shown: + (void)strcat(dest, src); + // cppcheck-suppress overlappingWriteFunction + return strcat(src, src); +} + wchar_t * overlappingWriteFunction_wcscpy(wchar_t *src, wchar_t *dest) { // No warning shall be shown: @@ -59,6 +75,13 @@ char * overlappingWriteFunction_strncpy(char *buf, const std::size_t count) return strncpy(&buf[0], &buf[3], 4U); } +void * overlappingWriteFunction_memmove(void) +{ + // No warning shall be shown: + char str[] = "memmove handles overlapping data well"; + return memmove(str,str+3,4); +} + std::bitset<10> std_bitset_test_ignoredReturnValue() { std::bitset<10> b1("1111010000"); diff --git a/test/cfg/windows.cpp b/test/cfg/windows.cpp index 9b78c8286..239770546 100644 --- a/test/cfg/windows.cpp +++ b/test/cfg/windows.cpp @@ -11,6 +11,27 @@ #include #include #include +#include +#include + +unsigned char * overlappingWriteFunction__mbscat(unsigned char *src, unsigned char *dest) +{ + // No warning shall be shown: + (void)_mbscat(dest, src); + // cppcheck-suppress overlappingWriteFunction + return _mbscat(src, src); +} + +unsigned char * overlappingWriteFunction__memccpy(unsigned char *src, unsigned char *dest, int c, size_t count) +{ + // No warning shall be shown: + (void)_memccpy(dest, src, c, count); + (void)_memccpy(dest, src, 42, count); + // cppcheck-suppress overlappingWriteFunction + (void) _memccpy(dest, dest, c, 4); + // cppcheck-suppress overlappingWriteFunction + return _memccpy(dest, dest+3, c, 4); +} unsigned char * overlappingWriteFunction__mbscpy(unsigned char *src, unsigned char *dest) { @@ -20,6 +41,14 @@ unsigned char * overlappingWriteFunction__mbscpy(unsigned char *src, unsigned ch return _mbscpy(src, src); } +void overlappingWriteFunction__swab(char *src, char *dest, int n) +{ + // No warning shall be shown: + _swab(dest, src, n); + // cppcheck-suppress overlappingWriteFunction + _swab(src, src+3, 4); +} + SYSTEM_INFO uninitvar_GetSystemInfo(char * envstr) { // No warning is expected @@ -877,8 +906,6 @@ unsigned char * uninitvar_mbscat(unsigned char *strDestination, const unsigned c (void)_mbscat(uninit_deststr,uninit_srcstr); // cppcheck-suppress uninitvar (void)_mbscat(strDestination,uninit_srcstr); - // cppcheck-suppress uninitvar - (void)_mbscat(uninit_deststr,uninit_deststr); // no warning shall be shown for return _mbscat(strDestination,strSource);