std.cfg: Merged 'wcscmp' and 'strcmp' configurations and added better tests.

This commit is contained in:
orbitcowboy 2019-11-14 08:43:31 +01:00
parent 20e2c513b6
commit dd30f37642
2 changed files with 33 additions and 24 deletions

View File

@ -4621,25 +4621,8 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
</arg>
</function>
<!-- int strcmp(const char *str1, const char *str2); -->
<function name="strcmp,std::strcmp">
<use-retval/>
<pure/>
<returnValue type="int"/>
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>
<strz/>
</arg>
<arg nr="2" direction="in">
<not-null/>
<not-uninit/>
<strz/>
</arg>
</function>
<!-- int wcscmp(const wchar_t *str1, const wchar_t c); -->
<function name="wcscmp,std::wcscmp">
<function name="strcmp,std::strcmp,wcscmp,std::wcscmp">
<use-retval/>
<pure/>
<returnValue type="int"/>
@ -4648,10 +4631,12 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>
<strz/>
</arg>
<arg nr="2" direction="in">
<not-null/>
<not-uninit/>
<strz/>
</arg>
</function>
<!-- char *strcpy(char *desstr, const char *srcstr); -->

View File

@ -3041,28 +3041,52 @@ void uninitvar_wcschr(void)
(void)wcschr(cs,c);
}
void uninitvar_strcmp(void)
void uninitvar_strcmp(char *s1, char *s2)
{
char *str1;
char *str2;
// cppcheck-suppress uninitvar
(void)strcmp(str1,s2);
// cppcheck-suppress uninitvar
(void)strcmp(s1,str2);
// cppcheck-suppress uninitvar
(void)strcmp(str1,str2);
// No warning is expected
(void)strcmp(s1,s2);
}
void uninitvar_wcscmp(void)
void uninitvar_wcscmp(wchar_t *s1, wchar_t *s2)
{
wchar_t *str1;
wchar_t *str2;
// cppcheck-suppress uninitvar
(void)wcscmp(str1,s2);
// cppcheck-suppress uninitvar
(void)wcscmp(s1,str2);
// cppcheck-suppress uninitvar
(void)wcscmp(str1,str2);
// No warning is expected
(void)wcscmp(s1,s2);
}
void uninitvar_strcpy(void)
void uninitvar_strcpy(char *d, char *s)
{
char *str1;
char *str2;
char *dest;
char *src;
// cppcheck-suppress uninitvar
(void)strcpy(str1,str2);
(void)strcpy(dest,s);
// cppcheck-suppress uninitvar
(void)strcpy(d,src);
// cppcheck-suppress uninitvar
(void)strcpy(dest,src);
// No warning is expected
(void)strcpy(d,s);
}
void uninitvar_strcpy_s(char * strDest)