Skip to content

Commit 1bf7b3b

Browse files
committed
std.cfg: Added more tests for memcmp(), memcpy() and memmove().
1 parent 3feecc5 commit 1bf7b3b

2 files changed

Lines changed: 51 additions & 8 deletions

File tree

test/cfg/std.c

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,12 +408,6 @@ void nullPointer_memchr(char *p)
408408
(void)p;
409409
}
410410

411-
void nullPointer_memcmp(char *p)
412-
{
413-
// cppcheck-suppress nullPointer
414-
(void)memcmp(p, 0, 123);
415-
}
416-
417411
void nullPointer_vsnprintf(const char * format, ...)
418412
{
419413
va_list args;
@@ -3670,6 +3664,33 @@ void nullPointer_wmemcmp(const wchar_t* s1, const wchar_t* s2, size_t n)
36703664
(void)wmemcmp(s1,s2,n);
36713665
}
36723666

3667+
void nullPointer_memmove(void *s1, void *s2, size_t n)
3668+
{
3669+
// cppcheck-suppress nullPointer
3670+
(void)memmove(NULL,s2,n);
3671+
// cppcheck-suppress nullPointer
3672+
(void)memmove(s1,NULL,n);
3673+
(void)memmove(s1,s2,n);
3674+
}
3675+
3676+
void nullPointer_memcmp(const void *s1, const void *s2, size_t n)
3677+
{
3678+
// cppcheck-suppress nullPointer
3679+
(void)memcmp(NULL,s2,n);
3680+
// cppcheck-suppress nullPointer
3681+
(void)memcmp(s1,NULL,n);
3682+
(void)memcmp(s1,s2,n);
3683+
}
3684+
3685+
void nullPointer_memcpy(void *s1, const void *s2, size_t n)
3686+
{
3687+
// cppcheck-suppress nullPointer
3688+
(void)memcpy(NULL,s2,n);
3689+
// cppcheck-suppress nullPointer
3690+
(void)memcpy(s1,NULL,n);
3691+
(void)memcpy(s1,s2,n);
3692+
}
3693+
36733694
void nullPointer_strncmp(const char *s1, const char *s2, size_t n)
36743695
{
36753696
// cppcheck-suppress nullPointer

test/cfg/std.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,16 @@ void nullPointer_wmemcmp(const wchar_t* s1, const wchar_t* s2, size_t n)
12831283
(void)std::wmemcmp(s1,s2,n);
12841284
}
12851285

1286+
1287+
void nullPointer_memcmp(const void *s1, const void *s2, size_t n)
1288+
{
1289+
// cppcheck-suppress nullPointer
1290+
(void)std::memcmp(NULL,s2,n);
1291+
// cppcheck-suppress nullPointer
1292+
(void)std::memcmp(s1,NULL,n);
1293+
(void)std::memcmp(s1,s2,n);
1294+
}
1295+
12861296
void nullPointer_strncat(char *d, char *s, size_t n)
12871297
{
12881298
// cppcheck-suppress nullPointer
@@ -3591,10 +3601,22 @@ void nullPointer_atof(void)
35913601
(void)std::atof(0);
35923602
}
35933603

3594-
void nullPointer_memcmp(char *p)
3604+
void nullPointer_memcpy(void *s1, const void *s2, size_t n)
35953605
{
35963606
// cppcheck-suppress nullPointer
3597-
(void)std::memcmp(p, 0, 123);
3607+
(void)std::memcpy(NULL,s2,n);
3608+
// cppcheck-suppress nullPointer
3609+
(void)std::memcpy(s1,NULL,n);
3610+
(void)std::memcpy(s1,s2,n);
3611+
}
3612+
3613+
void nullPointer_memmove(void *s1, void *s2, size_t n)
3614+
{
3615+
// cppcheck-suppress nullPointer
3616+
(void)std::memmove(NULL,s2,n);
3617+
// cppcheck-suppress nullPointer
3618+
(void)std::memmove(s1,NULL,n);
3619+
(void)std::memmove(s1,s2,n);
35983620
}
35993621

36003622
///////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)