Skip to content

Commit c68c0b1

Browse files
committed
Disable -Wimplicit-fallthrough in sections
These two files contain code with switch statements, where one case "fall through" to the next case. As it's not currently clear if this is intentional or not, rather than modifying the code in any way (regression risk), use GCC diagnostic pragmas to disable this warning for only these two files, with BUGBUG marking to encourage review by someone more familiar with this code.
1 parent 5cbfd74 commit c68c0b1

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

libraries/USBHost/src/hidescriptorparser.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,15 @@ void ReportDescParserBase::PrintItemTitle(uint8_t prefix) {
10881088
} // switch (**pp & (TYPE_MASK | TAG_MASK))
10891089
}
10901090

1091+
#pragma GCC diagnostic push // Available since GCC 4.6.4
1092+
/*
1093+
* BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages
1094+
* This code has multiple switch statements that "fall through" to the
1095+
* next case -- but it's not always clear if this is intentional or not.
1096+
* Review and commenting of code, and reducing cyclomatic complexity
1097+
* are highly recommended....
1098+
*/
1099+
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
10911100
uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint32_t *pcntdn) {
10921101
//uint8_t ret = enErrorSuccess;
10931102
//reinterpret_cast<>(varBuffer);
@@ -1210,6 +1219,7 @@ uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint32_t *pcntdn) {
12101219
itemParseState = 0;
12111220
return enErrorSuccess;
12121221
}
1222+
#pragma GCC diagnostic pop
12131223

12141224
ReportDescParserBase::UsagePageFunc ReportDescParserBase::usagePageFunctions[] /*PROGMEM*/ = {
12151225
&ReportDescParserBase::PrintGenericDesktopPageUsage,
@@ -1437,6 +1447,15 @@ void ReportDescParserBase::PrintMedicalInstrumentPageUsage(uint16_t usage) {
14371447
else E_Notify(pstrUsagePageUndefined, 0x80);
14381448
}
14391449

1450+
#pragma GCC diagnostic push // Available since GCC 4.6.4
1451+
/*
1452+
* BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages
1453+
* This code has multiple switch statements that "fall through" to the
1454+
* next case -- but it's not always clear if this is intentional or not.
1455+
* Review and commenting of code, and reducing cyclomatic complexity
1456+
* are highly recommended....
1457+
*/
1458+
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
14401459
uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint32_t *pcntdn) {
14411460
//uint8_t ret = enErrorSuccess;
14421461

@@ -1522,6 +1541,7 @@ uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint32_t *pcntdn) {
15221541
itemParseState = 0;
15231542
return enErrorSuccess;
15241543
}
1544+
#pragma GCC diagnostic pop
15251545

15261546
void ReportDescParser2::OnInputItem(uint8_t itm) {
15271547
uint8_t byte_offset = (totalSize >> 3); // calculate offset to the next unhandled byte i = (int)(totalCount / 8);

libraries/USBHost/src/parsetools.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ bool MultiByteValueParser::Parse(uint8_t **pp, uint32_t *pcntdn) {
3131
return true;
3232
}
3333

34+
#pragma GCC diagnostic push // Available since GCC 4.6.4
35+
/*
36+
* BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages
37+
* This code has multiple switch statements that "fall through" to the
38+
* next case -- but it's not always clear if this is intentional or not.
39+
* Review and commenting of code, and reducing cyclomatic complexity
40+
* are highly recommended....
41+
*/
42+
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
3443
bool PTPListParser::Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me) {
3544
switch(nStage) {
3645
case 0:
@@ -65,3 +74,4 @@ bool PTPListParser::Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf,
6574
}
6675
return true;
6776
}
77+
#pragma GCC diagnostic pop

0 commit comments

Comments
 (0)