From e683f3ce287adfe81c63fb87edab5a9e5fadf566 Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Thu, 21 Apr 2022 16:47:19 +0200 Subject: [PATCH] std.cfg: Added more test for strncpy(). --- test/cfg/std.c | 10 ++++++++++ test/cfg/std.cpp | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/test/cfg/std.c b/test/cfg/std.c index 8c96ae5ae..6c0ec4f04 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -3459,6 +3459,16 @@ void nullPointer_strncat(char *d, char *s, size_t n) (void)strncat(d,s,n); } +void nullPointer_strncpy(char *d, const char *s, size_t n) +{ + // cppcheck-suppress nullPointer + (void)strncpy(NULL,s,n); + // cppcheck-suppress nullPointer + (void)strncpy(d,NULL,n); + // no warning is expected for + (void)strncpy(d,s,n); +} + // errno_t strcat_s(char *restrict dest, rsize_t destsz, const char *restrict src); // since C11 void uninitvar_strcat_s(char *Ct, size_t N, char *S) { diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index 057629e56..636340acf 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -1293,6 +1293,16 @@ void nullPointer_strncat(char *d, char *s, size_t n) (void)std::strncat(d,s,n); } +void nullPointer_strncpy(char *d, const char *s, size_t n) +{ + // cppcheck-suppress nullPointer + (void)std::strncpy(NULL,s,n); + // cppcheck-suppress nullPointer + (void)std::strncpy(d,NULL,n); + // no warning is expected for + (void)std::strncpy(d,s,n); +} + void nullPointer_strncmp(const char *s1, const char *s2, size_t n) { // cppcheck-suppress nullPointer