From edc5198976fafe323e52d4818ce8f105000598d1 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Sun, 15 Nov 2020 23:27:08 +0100 Subject: [PATCH] Fix 'warning: this statement may fall through [-Wimplicit-fallthrough=]' Closes #532 --- confdescparser.h | 4 ++++ hidescriptorparser.cpp | 6 ++++++ parsetools.cpp | 3 +++ parsetools.h | 1 + usbh_midi.cpp | 1 + 5 files changed, 15 insertions(+) diff --git a/confdescparser.h b/confdescparser.h index 54053545..5991182a 100644 --- a/confdescparser.h +++ b/confdescparser.h @@ -108,12 +108,14 @@ bool ConfigDescParser::ParseDescriptor theBuffer.valueSize = 2; valParser.Initialize(&theBuffer); stateParseDescr = 1; + // fall through case 1: if(!valParser.Parse(pp, pcntdn)) return false; dscrLen = *((uint8_t*)theBuffer.pValue); dscrType = *((uint8_t*)theBuffer.pValue + 1); stateParseDescr = 2; + // fall through case 2: // This is a sort of hack. Assuming that two bytes are all ready in the buffer // the pointer is positioned two bytes ahead in order for the rest of descriptor @@ -122,6 +124,7 @@ bool ConfigDescParser::ParseDescriptor // in the buffer. theBuffer.pValue = varBuffer + 2; stateParseDescr = 3; + // fall through case 3: switch(dscrType) { case USB_DESCRIPTOR_INTERFACE: @@ -135,6 +138,7 @@ bool ConfigDescParser::ParseDescriptor theBuffer.valueSize = dscrLen - 2; valParser.Initialize(&theBuffer); stateParseDescr = 4; + // fall through case 4: switch(dscrType) { case USB_DESCRIPTOR_CONFIGURATION: diff --git a/hidescriptorparser.cpp b/hidescriptorparser.cpp index 43e3f7d6..42e3103b 100644 --- a/hidescriptorparser.cpp +++ b/hidescriptorparser.cpp @@ -1113,16 +1113,19 @@ uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint16_t *pcntdn) { if(!pcntdn) return enErrorIncomplete; + // fall through case 1: //USBTRACE2("\r\niSz:",itemSize); theBuffer.valueSize = itemSize; valParser.Initialize(&theBuffer); itemParseState = 2; + // fall through case 2: if(!valParser.Parse(pp, pcntdn)) return enErrorIncomplete; itemParseState = 3; + // fall through case 3: { uint8_t data = *((uint8_t*)varBuffer); @@ -1448,14 +1451,17 @@ uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint16_t *pcntdn) { if(!pcntdn) return enErrorIncomplete; + // fall through case 1: theBuffer.valueSize = itemSize; valParser.Initialize(&theBuffer); itemParseState = 2; + // fall through case 2: if(!valParser.Parse(pp, pcntdn)) return enErrorIncomplete; itemParseState = 3; + // fall through case 3: { uint8_t data = *((uint8_t*)varBuffer); diff --git a/parsetools.cpp b/parsetools.cpp index 1b5efaf3..47c0d2a1 100644 --- a/parsetools.cpp +++ b/parsetools.cpp @@ -44,6 +44,7 @@ bool PTPListParser::Parse(uint8_t **pp, uint16_t *pcntdn, PTP_ARRAY_EL_FUNC pf, pBuf->valueSize = lenSize; theParser.Initialize(pBuf); nStage = 1; + // fall through case 1: if(!theParser.Parse(pp, pcntdn)) @@ -53,11 +54,13 @@ bool PTPListParser::Parse(uint8_t **pp, uint16_t *pcntdn, PTP_ARRAY_EL_FUNC pf, arLen = (pBuf->valueSize >= 4) ? *((uint32_t*)pBuf->pValue) : (uint32_t)(*((uint16_t*)pBuf->pValue)); arLenCntdn = arLen; nStage = 2; + // fall through case 2: pBuf->valueSize = valSize; theParser.Initialize(pBuf); nStage = 3; + // fall through case 3: for(; arLenCntdn; arLenCntdn--) { diff --git a/parsetools.h b/parsetools.h index f7525369..7812e938 100644 --- a/parsetools.h +++ b/parsetools.h @@ -79,6 +79,7 @@ public: case 0: countDown = bytes_to_skip; nStage++; + // fall through case 1: for(; countDown && (*pcntdn); countDown--, (*pp)++, (*pcntdn)--); diff --git a/usbh_midi.cpp b/usbh_midi.cpp index 104eb816..a9f0f719 100644 --- a/usbh_midi.cpp +++ b/usbh_midi.cpp @@ -589,6 +589,7 @@ uint8_t USBH_MIDI::SendSysEx(uint8_t *dataptr, uint16_t datasize, uint8_t nCable break; case 3 : buf[wptr] = (nCable << 4) | 0x7; //x7 SysEx ends with following three bytes. + // fall through default : wptr++; buf[wptr++] = *(dataptr++);