std.cfg: Fixed false negatives regarding uninitialized variable usage and added test cases.

This commit is contained in:
Martin Ettl 2015-09-30 13:10:31 +02:00
parent 0b782853fe
commit 12b4bf75e0
3 changed files with 86 additions and 8 deletions

View File

@ -3087,6 +3087,7 @@
<not-uninit/> <not-uninit/>
</arg> </arg>
<arg nr="3"> <arg nr="3">
<not-uninit/>
<not-bool/> <not-bool/>
<valid>0:</valid> <valid>0:</valid>
</arg> </arg>
@ -3098,12 +3099,15 @@
<arg nr="1"> <arg nr="1">
<not-null/> <not-null/>
<not-uninit/> <not-uninit/>
<strz/>
<minsize type="argvalue" arg="3"/>
</arg> </arg>
<arg nr="2"> <arg nr="2">
<not-null/> <not-null/>
<not-uninit/> <not-uninit/>
</arg> </arg>
<arg nr="3"> <arg nr="3">
<not-uninit/>
<not-bool/> <not-bool/>
<valid>0:</valid> <valid>0:</valid>
</arg> </arg>
@ -3123,6 +3127,7 @@
<not-uninit/> <not-uninit/>
</arg> </arg>
<arg nr="3"> <arg nr="3">
<not-uninit/>
<not-bool/> <not-bool/>
<valid>0:</valid> <valid>0:</valid>
</arg> </arg>
@ -3142,6 +3147,7 @@
<not-uninit/> <not-uninit/>
</arg> </arg>
<arg nr="3"> <arg nr="3">
<not-uninit/>
<not-bool/> <not-bool/>
<valid>0:</valid> <valid>0:</valid>
</arg> </arg>

View File

@ -2975,40 +2975,76 @@ void uninivar_strpbrk(void)
(void)strpbrk(cs,ct); (void)strpbrk(cs,ct);
} }
void uninivar_strncat(void) void uninivar_strncat(char *Ct, char *S, size_t N)
{ {
char *ct; char *ct;
char *s; char *s;
size_t n; size_t n;
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)strncat(ct,s,n); (void)strncat(ct,s,n);
// cppcheck-suppress uninitvar
(void)strncat(ct,S,N);
// cppcheck-suppress uninitvar
(void)strncat(Ct,s,N);
// cppcheck-suppress uninitvar
(void)strncat(Ct,S,n);
// no warning is expected for
(void)strncat(Ct,S,N);
} }
void uninivar_wcsncat(void) void uninivar_wcsncat(wchar_t *Ct, wchar_t *S, size_t N)
{ {
wchar_t *ct; wchar_t *ct;
wchar_t *s; wchar_t *s;
size_t n; size_t n;
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)wcsncat(ct,s,n); (void)wcsncat(ct,s,n);
// cppcheck-suppress uninitvar
(void)wcsncat(ct,S,N);
// cppcheck-suppress uninitvar
(void)wcsncat(Ct,s,N);
// cppcheck-suppress uninitvar
(void)wcsncat(Ct,S,n);
// no warning is expected for
(void)wcsncat(Ct,S,N);
} }
void uninivar_strncmp(void) void uninivar_strncmp(char *Ct, char *S, size_t N)
{ {
char *ct; char *ct;
char *s; char *s;
size_t n; size_t n;
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)strncmp(ct,s,n); (void)strncmp(ct,s,n);
// cppcheck-suppress uninitvar
(void)strncmp(ct,S,N);
// cppcheck-suppress uninitvar
(void)strncmp(Ct,s,N);
// cppcheck-suppress uninitvar
(void)strncmp(Ct,S,n);
// no warning is expected for
(void)strncmp(Ct,S,N);
} }
void uninivar_wcsncmp(void) void uninivar_wcsncmp(wchar_t *Ct, wchar_t *S, size_t N)
{ {
wchar_t *ct; wchar_t *ct;
wchar_t *s; wchar_t *s;
size_t n; size_t n;
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)wcsncmp(ct,s,n); (void)wcsncmp(ct,s,n);
// cppcheck-suppress uninitvar
(void)wcsncmp(ct,S,N);
// cppcheck-suppress uninitvar
(void)wcsncmp(Ct,s,N);
// cppcheck-suppress uninitvar
(void)wcsncmp(Ct,S,n);
// no warning is expected for
(void)wcsncmp(Ct,S,N);
} }
void uninivar_strstr(void) void uninivar_strstr(void)

View File

@ -2304,40 +2304,76 @@ void uninivar_strpbrk(void)
(void)std::strpbrk(cs,ct); (void)std::strpbrk(cs,ct);
} }
void uninivar_strncat(void) void uninivar_strncat(char *Ct, char *S, size_t N)
{ {
char *ct; char *ct;
char *s; char *s;
size_t n; size_t n;
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)std::strncat(ct,s,n); (void)std::strncat(ct,s,n);
// cppcheck-suppress uninitvar
(void)std::strncat(ct,S,N);
// cppcheck-suppress uninitvar
(void)std::strncat(Ct,s,N);
// cppcheck-suppress uninitvar
(void)std::strncat(Ct,S,n);
// no warning is expected for
(void)std::strncat(Ct,S,N);
} }
void uninivar_wcsncat(void) void uninivar_wcsncat(wchar_t *Ct, wchar_t *S, size_t N)
{ {
wchar_t *ct; wchar_t *ct;
wchar_t *s; wchar_t *s;
size_t n; size_t n;
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)std::wcsncat(ct,s,n); (void)std::wcsncat(ct,s,n);
// cppcheck-suppress uninitvar
(void)std::wcsncat(ct,S,N);
// cppcheck-suppress uninitvar
(void)std::wcsncat(Ct,s,N);
// cppcheck-suppress uninitvar
(void)std::wcsncat(Ct,S,n);
// no warning is expected for
(void)std::wcsncat(Ct,S,N);
} }
void uninivar_strncmp(void) void uninivar_strncmp(char *Ct, char *S, size_t N)
{ {
char *ct; char *ct;
char *s; char *s;
size_t n; size_t n;
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)std::strncmp(ct,s,n); (void)std::strncmp(ct,s,n);
// cppcheck-suppress uninitvar
(void)std::strncmp(ct,S,N);
// cppcheck-suppress uninitvar
(void)std::strncmp(Ct,s,N);
// cppcheck-suppress uninitvar
(void)std::strncmp(Ct,S,n);
// no warning is expected for
(void)std::strncmp(Ct,S,N);
} }
void uninivar_wcsncmp(void) void uninivar_wcsncmp(wchar_t *Ct, wchar_t *S, size_t N)
{ {
wchar_t *ct; wchar_t *ct;
wchar_t *s; wchar_t *s;
size_t n; size_t n;
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)std::wcsncmp(ct,s,n); (void)std::wcsncmp(ct,s,n);
// cppcheck-suppress uninitvar
(void)std::wcsncmp(ct,S,N);
// cppcheck-suppress uninitvar
(void)std::wcsncmp(Ct,s,N);
// cppcheck-suppress uninitvar
(void)std::wcsncmp(Ct,S,n);
// no warning is expected for
(void)std::wcsncmp(Ct,S,N);
} }
void uninivar_strstr(void) void uninivar_strstr(void)