2021-09-17 14:21:25 +02:00
|
|
|
// To test:
|
2023-08-22 14:49:08 +02:00
|
|
|
// ~/cppcheck/cppcheck--dump -DDUMMY --suppress=uninitvar misra/misra-test-avr8.c --std=c89 --platform=avr8 && python3 ../misra.py -verify misra/misra-test-avr8.c.dump
|
2021-09-17 14:21:25 +02:00
|
|
|
|
2021-09-22 13:02:11 +02:00
|
|
|
static void misra_10_4(void)
|
|
|
|
{
|
|
|
|
// #10480
|
2023-08-22 14:49:08 +02:00
|
|
|
const char buf1[1] = {a};
|
2021-09-22 13:02:11 +02:00
|
|
|
const char c = '0';
|
2023-08-22 14:49:08 +02:00
|
|
|
x = buf1[0] - c;
|
2023-08-22 12:18:12 +02:00
|
|
|
|
2023-08-22 14:49:08 +02:00
|
|
|
const char buf2[2] = {x,y};
|
|
|
|
x = 'a' == buf2[0]; // no-warning
|
2023-08-22 12:18:12 +02:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int t;
|
|
|
|
char buf[2];
|
|
|
|
} foo_t;
|
|
|
|
const foo_t cmd = {0};
|
|
|
|
x = 'b' == cmd.buf[0]; // no-warning
|
|
|
|
|
|
|
|
const foo_t * pcmd = &cmd;
|
|
|
|
x='c' == pcmd->buf[0]; // no-warning
|
|
|
|
(void)cmd.t;
|
2021-09-22 13:02:11 +02:00
|
|
|
}
|
|
|
|
|
2021-09-17 14:21:25 +02:00
|
|
|
static void misra_12_2(void) {
|
|
|
|
a = (((uint64_t)0xFF) << 32);
|
|
|
|
}
|
|
|
|
|