From e06169cf8de8a9d2ffe0ed1637360f1cd7afb3dc Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Thu, 21 Apr 2022 16:09:36 +0200 Subject: [PATCH] std.cfg: Added more test for strncmp() and wmemcmp(). --- test/cfg/std.c | 24 ++++++++++++++++++------ test/cfg/std.cpp | 24 ++++++++++++++++++------ 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/test/cfg/std.c b/test/cfg/std.c index dece7062f..89bc75436 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -414,12 +414,6 @@ void nullPointer_memcmp(char *p) (void)memcmp(p, 0, 123); } -void nullPointer_wmemcmp(wchar_t *p) -{ - // cppcheck-suppress nullPointer - (void)wmemcmp(p, 0, 123); -} - void nullPointer_vsnprintf(const char * format, ...) { va_list args; @@ -3616,6 +3610,24 @@ void bufferAccessOutOfBounds_strncmp(void) (void)strncmp(dest,src,3); } +void nullPointer_wmemcmp(const wchar_t* s1, const wchar_t* s2, size_t n) +{ + // cppcheck-suppress nullPointer + (void)wmemcmp(NULL,s2,n); + // cppcheck-suppress nullPointer + (void)wmemcmp(s1,NULL,n); + (void)wmemcmp(s1,s2,n); +} + +void nullPointer_strncmp(const char *s1, const char *s2, size_t n) +{ + // cppcheck-suppress nullPointer + (void)strncmp(NULL,s2,n); + // cppcheck-suppress nullPointer + (void)strncmp(s1,NULL,n); + (void)strncmp(s1,s2,n); +} + void uninitvar_wcsxfrm(void) { wchar_t *ds; diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index 90eb7a7f4..5bf9c7edf 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -1274,6 +1274,24 @@ wchar_t* nullPointer_fgetws(wchar_t* buffer, int n, FILE* stream) return std::fgetws(buffer, n, stream); } +void nullPointer_wmemcmp(const wchar_t* s1, const wchar_t* s2, size_t n) +{ + // cppcheck-suppress nullPointer + (void)std::wmemcmp(NULL,s2,n); + // cppcheck-suppress nullPointer + (void)std::wmemcmp(s1,NULL,n); + (void)std::wmemcmp(s1,s2,n); +} + +void nullPointer_strncmp(const char *s1, const char *s2, size_t n) +{ + // cppcheck-suppress nullPointer + (void)std::strncmp(NULL,s2,n); + // cppcheck-suppress nullPointer + (void)std::strncmp(s1,NULL,n); + (void)std::strncmp(s1,s2,n); +} + char* nullPointer_fgets(char *buffer, int n, FILE *stream) { // cppcheck-suppress nullPointer @@ -3537,12 +3555,6 @@ void nullPointer_memcmp(char *p) (void)std::memcmp(p, 0, 123); } -void nullPointer_wmemcmp(wchar_t *p) -{ - // cppcheck-suppress nullPointer - (void)std::wmemcmp(p, 0, 123); -} - /////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////////