Skip to content

Commit e06169c

Browse files
committed
std.cfg: Added more test for strncmp() and wmemcmp().
1 parent f53ad23 commit e06169c

2 files changed

Lines changed: 36 additions & 12 deletions

File tree

test/cfg/std.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,12 +414,6 @@ void nullPointer_memcmp(char *p)
414414
(void)memcmp(p, 0, 123);
415415
}
416416

417-
void nullPointer_wmemcmp(wchar_t *p)
418-
{
419-
// cppcheck-suppress nullPointer
420-
(void)wmemcmp(p, 0, 123);
421-
}
422-
423417
void nullPointer_vsnprintf(const char * format, ...)
424418
{
425419
va_list args;
@@ -3616,6 +3610,24 @@ void bufferAccessOutOfBounds_strncmp(void)
36163610
(void)strncmp(dest,src,3);
36173611
}
36183612

3613+
void nullPointer_wmemcmp(const wchar_t* s1, const wchar_t* s2, size_t n)
3614+
{
3615+
// cppcheck-suppress nullPointer
3616+
(void)wmemcmp(NULL,s2,n);
3617+
// cppcheck-suppress nullPointer
3618+
(void)wmemcmp(s1,NULL,n);
3619+
(void)wmemcmp(s1,s2,n);
3620+
}
3621+
3622+
void nullPointer_strncmp(const char *s1, const char *s2, size_t n)
3623+
{
3624+
// cppcheck-suppress nullPointer
3625+
(void)strncmp(NULL,s2,n);
3626+
// cppcheck-suppress nullPointer
3627+
(void)strncmp(s1,NULL,n);
3628+
(void)strncmp(s1,s2,n);
3629+
}
3630+
36193631
void uninitvar_wcsxfrm(void)
36203632
{
36213633
wchar_t *ds;

test/cfg/std.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,24 @@ wchar_t* nullPointer_fgetws(wchar_t* buffer, int n, FILE* stream)
12741274
return std::fgetws(buffer, n, stream);
12751275
}
12761276

1277+
void nullPointer_wmemcmp(const wchar_t* s1, const wchar_t* s2, size_t n)
1278+
{
1279+
// cppcheck-suppress nullPointer
1280+
(void)std::wmemcmp(NULL,s2,n);
1281+
// cppcheck-suppress nullPointer
1282+
(void)std::wmemcmp(s1,NULL,n);
1283+
(void)std::wmemcmp(s1,s2,n);
1284+
}
1285+
1286+
void nullPointer_strncmp(const char *s1, const char *s2, size_t n)
1287+
{
1288+
// cppcheck-suppress nullPointer
1289+
(void)std::strncmp(NULL,s2,n);
1290+
// cppcheck-suppress nullPointer
1291+
(void)std::strncmp(s1,NULL,n);
1292+
(void)std::strncmp(s1,s2,n);
1293+
}
1294+
12771295
char* nullPointer_fgets(char *buffer, int n, FILE *stream)
12781296
{
12791297
// cppcheck-suppress nullPointer
@@ -3537,12 +3555,6 @@ void nullPointer_memcmp(char *p)
35373555
(void)std::memcmp(p, 0, 123);
35383556
}
35393557

3540-
void nullPointer_wmemcmp(wchar_t *p)
3541-
{
3542-
// cppcheck-suppress nullPointer
3543-
(void)std::wmemcmp(p, 0, 123);
3544-
}
3545-
35463558
///////////////////////////////////////////////////////////////////////
35473559
// <algorithm>
35483560
///////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)