From 0560a946a80a4c949a9b31993c11a24b3e48cec2 Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Fri, 22 Apr 2022 08:00:45 +0200 Subject: [PATCH] std.cfg: Added more tests --- cfg/std.cfg | 1 + test/cfg/std.c | 18 ++++++++++++++++++ test/cfg/std.cpp | 24 ++++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/cfg/std.cfg b/cfg/std.cfg index 4f043a6ca..bb881cb43 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -5126,6 +5126,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun false + diff --git a/test/cfg/std.c b/test/cfg/std.c index e9cb3e507..28574c979 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -381,6 +381,24 @@ void nullpointer(int value) wscanf(L"%i", NULL); } +int nullPointer_wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n) +{ + // cppcheck-suppress nullPointer + (void) wcsncmp(NULL,s2,n); + // cppcheck-suppress nullPointer + (void) wcsncmp(s1,NULL,n); + return wcsncmp(s1,s2,n); +} + +wchar_t* nullPointer_wcsncpy(wchar_t *s, const wchar_t *cs, size_t n) +{ + // cppcheck-suppress nullPointer + (void) wcsncpy(NULL,cs,n); + // cppcheck-suppress nullPointer + (void) wcsncpy(s,NULL,n); + return wcsncpy(s,cs,n); +} + size_t nullPointer_strlen(const char *s) { // cppcheck-suppress nullPointer diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index ea3d2f32a..6e003f67b 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -110,6 +110,12 @@ void overlappingWriteFunction_wcscat(wchar_t *src, wchar_t *dest) (void)wcscat(src, src); } +void overlappingWriteFunction_wcsxfrm(wchar_t *s1, wchar_t *s2, size_t n) +{ + // No warning shall be shown: + (void)wcsxfrm(s1, s2, n); +} + char * overlappingWriteFunction_strcat(char *src, char *dest) { // No warning shall be shown: @@ -118,6 +124,24 @@ char * overlappingWriteFunction_strcat(char *src, char *dest) return strcat(src, src); } +int nullPointer_wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n) +{ + // cppcheck-suppress nullPointer + (void) std::wcsncmp(NULL,s2,n); + // cppcheck-suppress nullPointer + (void) std::wcsncmp(s1,NULL,n); + return std::wcsncmp(s1,s2,n); +} + +wchar_t* nullPointer_wcsncpy(wchar_t *s, const wchar_t *cs, size_t n) +{ + // cppcheck-suppress nullPointer + (void) std::wcsncpy(NULL,cs,n); + // cppcheck-suppress nullPointer + (void) std::wcsncpy(s,NULL,n); + return std::wcsncpy(s,cs,n); +} + char * overlappingWriteFunction_strncat(char *src, char *dest, const std::size_t count) { // No warning shall be shown: