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.
This commit is contained in:
Henry Gabryjelski 2020-01-17 00:34:40 -08:00
parent 5cbfd74f4d
commit c68c0b19ae
2 changed files with 30 additions and 0 deletions

View file

@ -1088,6 +1088,15 @@ void ReportDescParserBase::PrintItemTitle(uint8_t prefix) {
} // switch (**pp & (TYPE_MASK | TAG_MASK))
}
#pragma GCC diagnostic push // Available since GCC 4.6.4
/*
* BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages
* This code has multiple switch statements that "fall through" to the
* next case -- but it's not always clear if this is intentional or not.
* Review and commenting of code, and reducing cyclomatic complexity
* are highly recommended....
*/
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint32_t *pcntdn) {
//uint8_t ret = enErrorSuccess;
//reinterpret_cast<>(varBuffer);
@ -1210,6 +1219,7 @@ uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint32_t *pcntdn) {
itemParseState = 0;
return enErrorSuccess;
}
#pragma GCC diagnostic pop
ReportDescParserBase::UsagePageFunc ReportDescParserBase::usagePageFunctions[] /*PROGMEM*/ = {
&ReportDescParserBase::PrintGenericDesktopPageUsage,
@ -1437,6 +1447,15 @@ void ReportDescParserBase::PrintMedicalInstrumentPageUsage(uint16_t usage) {
else E_Notify(pstrUsagePageUndefined, 0x80);
}
#pragma GCC diagnostic push // Available since GCC 4.6.4
/*
* BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages
* This code has multiple switch statements that "fall through" to the
* next case -- but it's not always clear if this is intentional or not.
* Review and commenting of code, and reducing cyclomatic complexity
* are highly recommended....
*/
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint32_t *pcntdn) {
//uint8_t ret = enErrorSuccess;
@ -1522,6 +1541,7 @@ uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint32_t *pcntdn) {
itemParseState = 0;
return enErrorSuccess;
}
#pragma GCC diagnostic pop
void ReportDescParser2::OnInputItem(uint8_t itm) {
uint8_t byte_offset = (totalSize >> 3); // calculate offset to the next unhandled byte i = (int)(totalCount / 8);

View file

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