Skip to content

Commit 0560a94

Browse files
committed
std.cfg: Added more tests
1 parent 051512d commit 0560a94

3 files changed

Lines changed: 43 additions & 0 deletions

File tree

cfg/std.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5126,6 +5126,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
51265126
<returnValue type="size_t"/>
51275127
<noreturn>false</noreturn>
51285128
<leak-ignore/>
5129+
<not-overlapping-data ptr1-arg="1" ptr2-arg="2" size-arg="3"/>
51295130
<!-- In case the 3rd argument is 0, the 1st argument is permitted to be a null pointer. (#6306) -->
51305131
<arg nr="1" direction="out"/>
51315132
<arg nr="2" direction="in">

test/cfg/std.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,24 @@ void nullpointer(int value)
381381
wscanf(L"%i", NULL);
382382
}
383383

384+
int nullPointer_wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n)
385+
{
386+
// cppcheck-suppress nullPointer
387+
(void) wcsncmp(NULL,s2,n);
388+
// cppcheck-suppress nullPointer
389+
(void) wcsncmp(s1,NULL,n);
390+
return wcsncmp(s1,s2,n);
391+
}
392+
393+
wchar_t* nullPointer_wcsncpy(wchar_t *s, const wchar_t *cs, size_t n)
394+
{
395+
// cppcheck-suppress nullPointer
396+
(void) wcsncpy(NULL,cs,n);
397+
// cppcheck-suppress nullPointer
398+
(void) wcsncpy(s,NULL,n);
399+
return wcsncpy(s,cs,n);
400+
}
401+
384402
size_t nullPointer_strlen(const char *s)
385403
{
386404
// cppcheck-suppress nullPointer

test/cfg/std.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ void overlappingWriteFunction_wcscat(wchar_t *src, wchar_t *dest)
110110
(void)wcscat(src, src);
111111
}
112112

113+
void overlappingWriteFunction_wcsxfrm(wchar_t *s1, wchar_t *s2, size_t n)
114+
{
115+
// No warning shall be shown:
116+
(void)wcsxfrm(s1, s2, n);
117+
}
118+
113119
char * overlappingWriteFunction_strcat(char *src, char *dest)
114120
{
115121
// No warning shall be shown:
@@ -118,6 +124,24 @@ char * overlappingWriteFunction_strcat(char *src, char *dest)
118124
return strcat(src, src);
119125
}
120126

127+
int nullPointer_wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n)
128+
{
129+
// cppcheck-suppress nullPointer
130+
(void) std::wcsncmp(NULL,s2,n);
131+
// cppcheck-suppress nullPointer
132+
(void) std::wcsncmp(s1,NULL,n);
133+
return std::wcsncmp(s1,s2,n);
134+
}
135+
136+
wchar_t* nullPointer_wcsncpy(wchar_t *s, const wchar_t *cs, size_t n)
137+
{
138+
// cppcheck-suppress nullPointer
139+
(void) std::wcsncpy(NULL,cs,n);
140+
// cppcheck-suppress nullPointer
141+
(void) std::wcsncpy(s,NULL,n);
142+
return std::wcsncpy(s,cs,n);
143+
}
144+
121145
char * overlappingWriteFunction_strncat(char *src, char *dest, const std::size_t count)
122146
{
123147
// No warning shall be shown:

0 commit comments

Comments
 (0)