Skip to content

Commit 69b11f1

Browse files
committed
Correct FALLTHROUGH cases for new compiler warnings
1 parent 731ff93 commit 69b11f1

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

dataflash_textdump_reader.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include "stdlib.h"
77
#include "string.h"
88

9+
#include "tools.h"
10+
911
// BT 42 EN
1012
std::vector<std::string> split_line(const uint8_t *line, uint32_t len)
1113
{
@@ -86,6 +88,7 @@ void DataFlash_TextDump_Reader::handle_line(const uint8_t *line, uint32_t len)
8688
break;
8789
case 'E':
8890
value_integer *= 100;
91+
FALLTHROUGH;
8992
case 'I':
9093
*((uint32_t*)&buf[buf_offset]) = value_integer; // FIXME
9194
buf_offset += sizeof(uint32_t);
@@ -96,23 +99,27 @@ void DataFlash_TextDump_Reader::handle_line(const uint8_t *line, uint32_t len)
9699
break;
97100
case 'e':
98101
value_integer *= 100;
102+
FALLTHROUGH;
99103
case 'i':
100104
*((int32_t*)&buf[buf_offset]) = value_integer; // FIXME
101105
buf_offset += sizeof(int32_t);
102106
break;
103107
case 'c':
104108
value_integer *= 100;
109+
FALLTHROUGH;
105110
case 'h':
106111
*((int16_t*)&buf[buf_offset]) = value_integer; // FIXME
107112
buf_offset += sizeof(int16_t);
108113
break;
109114
case 'C':
110115
value_integer *= 100;
116+
FALLTHROUGH;
111117
case 'H':
112118
*((uint16_t*)&buf[buf_offset]) = value_integer; // FIXME
113119
buf_offset += sizeof(uint16_t);
114120
break;
115121
case 'B':
122+
FALLTHROUGH;
116123
case 'M':
117124
*((uint8_t*)&buf[buf_offset]) = value_integer; // FIXME
118125
buf_offset += sizeof(uint8_t);

tools.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifdef __has_cpp_attribute
2+
# if __has_cpp_attribute(fallthrough)
3+
# define FALLTHROUGH [[fallthrough]]
4+
# elif __has_cpp_attribute(gnu::fallthrough)
5+
# define FALLTHROUGH [[gnu::fallthrough]]
6+
# endif
7+
#endif
8+
#ifndef FALLTHROUGH
9+
# define FALLTHROUGH
10+
#endif

0 commit comments

Comments
 (0)