2018-01-23 17:18:47 +01:00
|
|
|
// To test:
|
|
|
|
// ~/cppcheck/cppcheck --dump cert-test.c && python ../cert.py -verify cert-test.c.dump
|
|
|
|
|
|
|
|
struct S {
|
|
|
|
short a;
|
|
|
|
short b;
|
|
|
|
};
|
|
|
|
|
|
|
|
#pragma pack()
|
|
|
|
struct PackedStruct {
|
|
|
|
short a;
|
|
|
|
short b;
|
|
|
|
};
|
|
|
|
|
|
|
|
void exp42()
|
|
|
|
{
|
|
|
|
struct S s1 = {1,2};
|
|
|
|
struct S s2 = {1,2};
|
|
|
|
memcmp(&s1, &s2, sizeof(struct S)); // cert-EXP42-C
|
|
|
|
|
|
|
|
struct PackedStruct s3 = {1,2};
|
|
|
|
struct PackedStruct s4 = {1,2};
|
|
|
|
memcmp(&s3, &s4, sizeof(struct S));
|
|
|
|
}
|
|
|
|
|
2018-01-23 22:43:29 +01:00
|
|
|
void exp46()
|
|
|
|
{
|
|
|
|
if ((x == y) & z) {} // cert-EXP46-c
|
|
|
|
}
|
|
|
|
|
2018-01-23 17:18:47 +01:00
|
|
|
unsigned char int31(int x)
|
|
|
|
{
|
|
|
|
x = (unsigned char)1000; // cert-INT31-c
|
|
|
|
x = (signed char)0xff; // cert-INT31-c
|
|
|
|
x = (unsigned char)-1; // cert-INT31-c
|
|
|
|
x = (unsigned long long)-1; // cert-INT31-c
|
|
|
|
}
|