From dd30f376429e18409c5a2bf2db2f9b4774eb9045 Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Thu, 14 Nov 2019 08:43:31 +0100 Subject: [PATCH] std.cfg: Merged 'wcscmp' and 'strcmp' configurations and added better tests. --- cfg/std.cfg | 21 +++------------------ test/cfg/std.c | 36 ++++++++++++++++++++++++++++++------ 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/cfg/std.cfg b/cfg/std.cfg index c65f16c1d..e3d90ab0a 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -4621,25 +4621,8 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun - - - - - false - - - - - - - - - - - - - + @@ -4648,10 +4631,12 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun + + diff --git a/test/cfg/std.c b/test/cfg/std.c index 4610966d5..4e0f87486 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -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)