diff --git a/addons/test/cert-test.c b/addons/test/cert-test.c index 46276f616..2b6d826b1 100644 --- a/addons/test/cert-test.c +++ b/addons/test/cert-test.c @@ -1,5 +1,12 @@ // To test: // ~/cppcheck/cppcheck --dump cert-test.c && python ../cert.py -verify cert-test.c.dump + +#include +#include +#include +#include +#include + struct S { short a; short b; @@ -18,17 +25,17 @@ void api01() { char name[String_Size]; struct bad_node_s* next; // cert-API01-C - } + }; struct good_node_s { struct good_node_s* next; char name[String_Size]; - } + }; struct also_good_node_s { struct also_good_node_s* next; char *name; - } + }; } void dostuff(int *data); @@ -61,7 +68,7 @@ void exp42() memcmp(&s3, &s4, sizeof(struct S)); } -void exp46() +void exp46(int x, int y, int z) { if ((x == y) & z) {} // cert-EXP46-c } @@ -103,9 +110,9 @@ void msc24() s.fopen = 123; f = fopen ("myfile.txt","w+"); //cert-MSC24-C - setbuf ( f , buffer ) //cert-MSC24-C + setbuf ( f , buffer ); //cert-MSC24-C for ( i='A' ; i<='Z' ; i++) - fputc ( n, f); + fputc ( i, f); rewind (f); //cert-MSC24-C fclose (f); @@ -113,8 +120,8 @@ void msc24() timeinfo = localtime ( &rawtime ); printf ( "The current date/time is: %s", asctime (timeinfo) ); //cert-MSC24-C - n = atof (buffer); //cert-MSC24-C - m = sin (n*pi/180); + float n = atof (buffer); //cert-MSC24-C + float m = sin (n*M_PI/180); i = atoi (buffer); //cert-MSC24-C @@ -172,11 +179,11 @@ void str05() void str07(char *buf, const char *newBuf) { - const char *str="test"; + const char *str = "test"; strcat(buf,"bla"); strcat(buf, str); //cert-STR07-C strcat(buf, newBuf); //cert-STR07-C - strcpy(str, newBuf); //cert-STR07-C + strcpy(buf, newBuf); //cert-STR07-C } void str11() diff --git a/addons/test/misc-test.cpp b/addons/test/misc-test.cpp index 3ea89bbd1..df1f8352c 100644 --- a/addons/test/misc-test.cpp +++ b/addons/test/misc-test.cpp @@ -1,6 +1,9 @@ // To test: // ~/cppcheck/cppcheck --dump misc-test.cpp && python ../misc.py -verify misc-test.cpp.dump +#include +#include + // Warn about string concatenation in array initializers.. const char *a[] = {"a" "b"}; // stringConcatInArrayInit const char *b[] = {"a","b" "c"}; // stringConcatInArrayInit diff --git a/addons/test/naming_test.c b/addons/test/naming_test.c index e3155e622..928d51dab 100644 --- a/addons/test/naming_test.c +++ b/addons/test/naming_test.c @@ -2,4 +2,4 @@ // ~/cppcheck/cppcheck --dump naming_test.c && python ../naming.py --var='[a-z].*' --function='[a-z].*' naming_test.c.dump // Should not crash when there is no name -void func(int number, bool); +void func(int number, int); diff --git a/addons/test/namingng_test.c b/addons/test/namingng_test.c index e5915b91a..2eaf38996 100644 --- a/addons/test/namingng_test.c +++ b/addons/test/namingng_test.c @@ -1,7 +1,7 @@ #include -#include +#include -uint32_t ui32Good (int a) +uint32_t ui32Good (int abc) { uint32_t ui32good; int32_t i32good;