Fixed #9971 (missing system includes in addon/test test files)

This commit is contained in:
Daniel Marjamäki 2020-11-15 12:46:12 +01:00
parent 7c3afa0b36
commit 43c4a48d48
4 changed files with 23 additions and 13 deletions

View File

@ -1,5 +1,12 @@
// To test: // To test:
// ~/cppcheck/cppcheck --dump cert-test.c && python ../cert.py -verify cert-test.c.dump // ~/cppcheck/cppcheck --dump cert-test.c && python ../cert.py -verify cert-test.c.dump
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
struct S { struct S {
short a; short a;
short b; short b;
@ -18,17 +25,17 @@ void api01()
{ {
char name[String_Size]; char name[String_Size];
struct bad_node_s* next; // cert-API01-C struct bad_node_s* next; // cert-API01-C
} };
struct good_node_s struct good_node_s
{ {
struct good_node_s* next; struct good_node_s* next;
char name[String_Size]; char name[String_Size];
} };
struct also_good_node_s struct also_good_node_s
{ {
struct also_good_node_s* next; struct also_good_node_s* next;
char *name; char *name;
} };
} }
void dostuff(int *data); void dostuff(int *data);
@ -61,7 +68,7 @@ void exp42()
memcmp(&s3, &s4, sizeof(struct S)); memcmp(&s3, &s4, sizeof(struct S));
} }
void exp46() void exp46(int x, int y, int z)
{ {
if ((x == y) & z) {} // cert-EXP46-c if ((x == y) & z) {} // cert-EXP46-c
} }
@ -103,9 +110,9 @@ void msc24()
s.fopen = 123; s.fopen = 123;
f = fopen ("myfile.txt","w+"); //cert-MSC24-C 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++) for ( i='A' ; i<='Z' ; i++)
fputc ( n, f); fputc ( i, f);
rewind (f); //cert-MSC24-C rewind (f); //cert-MSC24-C
fclose (f); fclose (f);
@ -113,8 +120,8 @@ void msc24()
timeinfo = localtime ( &rawtime ); timeinfo = localtime ( &rawtime );
printf ( "The current date/time is: %s", asctime (timeinfo) ); //cert-MSC24-C printf ( "The current date/time is: %s", asctime (timeinfo) ); //cert-MSC24-C
n = atof (buffer); //cert-MSC24-C float n = atof (buffer); //cert-MSC24-C
m = sin (n*pi/180); float m = sin (n*M_PI/180);
i = atoi (buffer); //cert-MSC24-C i = atoi (buffer); //cert-MSC24-C
@ -172,11 +179,11 @@ void str05()
void str07(char *buf, const char *newBuf) void str07(char *buf, const char *newBuf)
{ {
const char *str="test"; const char *str = "test";
strcat(buf,"bla"); strcat(buf,"bla");
strcat(buf, str); //cert-STR07-C strcat(buf, str); //cert-STR07-C
strcat(buf, newBuf); //cert-STR07-C strcat(buf, newBuf); //cert-STR07-C
strcpy(str, newBuf); //cert-STR07-C strcpy(buf, newBuf); //cert-STR07-C
} }
void str11() void str11()

View File

@ -1,6 +1,9 @@
// To test: // To test:
// ~/cppcheck/cppcheck --dump misc-test.cpp && python ../misc.py -verify misc-test.cpp.dump // ~/cppcheck/cppcheck --dump misc-test.cpp && python ../misc.py -verify misc-test.cpp.dump
#include <string>
#include <vector>
// Warn about string concatenation in array initializers.. // Warn about string concatenation in array initializers..
const char *a[] = {"a" "b"}; // stringConcatInArrayInit const char *a[] = {"a" "b"}; // stringConcatInArrayInit
const char *b[] = {"a","b" "c"}; // stringConcatInArrayInit const char *b[] = {"a","b" "c"}; // stringConcatInArrayInit

View File

@ -2,4 +2,4 @@
// ~/cppcheck/cppcheck --dump naming_test.c && python ../naming.py --var='[a-z].*' --function='[a-z].*' naming_test.c.dump // ~/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 // Should not crash when there is no name
void func(int number, bool); void func(int number, int);

View File

@ -1,7 +1,7 @@
#include <stddef.h> #include <stddef.h>
#include <inttypes.h> #include <stdint.h>
uint32_t ui32Good (int a) uint32_t ui32Good (int abc)
{ {
uint32_t ui32good; uint32_t ui32good;
int32_t i32good; int32_t i32good;