Skip to content

Commit 7f48127

Browse files
committed
std.cfg: Added more test for strncat().
1 parent a6f87e6 commit 7f48127

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

test/cfg/std.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3449,6 +3449,16 @@ void uninitvar_strncat(char *d, char *s, size_t n)
34493449
(void)strncat(d,s,n);
34503450
}
34513451

3452+
void nullPointer_strncat(char *d, char *s, size_t n)
3453+
{
3454+
// cppcheck-suppress nullPointer
3455+
(void)strncat(NULL,s,n);
3456+
// cppcheck-suppress nullPointer
3457+
(void)strncat(d,NULL,n);
3458+
// no warning is expected for
3459+
(void)strncat(d,s,n);
3460+
}
3461+
34523462
// errno_t strcat_s(char *restrict dest, rsize_t destsz, const char *restrict src); // since C11
34533463
void uninitvar_strcat_s(char *Ct, size_t N, char *S)
34543464
{

test/cfg/std.cpp

Lines changed: 10 additions & 0 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+
void nullPointer_strncat(char *d, char *s, size_t n)
1287+
{
1288+
// cppcheck-suppress nullPointer
1289+
(void)std::strncat(NULL,s,n);
1290+
// cppcheck-suppress nullPointer
1291+
(void)std::strncat(d,NULL,n);
1292+
// no warning is expected for
1293+
(void)std::strncat(d,s,n);
1294+
}
1295+
12861296
void nullPointer_strncmp(const char *s1, const char *s2, size_t n)
12871297
{
12881298
// cppcheck-suppress nullPointer

0 commit comments

Comments
 (0)