Skip to content

Commit 55a9930

Browse files
committed
reduce affected area of diagnostic push/pop
1 parent 134ebe7 commit 55a9930

File tree

4 files changed

+39
-40
lines changed

4 files changed

+39
-40
lines changed

libraries/USBHost/src/confdescparser.h

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,6 @@ e-mail : [email protected]
1919
#error "Never include confdescparser.h directly; include Usb.h instead"
2020
#else
2121

22-
23-
24-
#pragma GCC diagnostic push // Available since GCC 4.6.4
25-
/*
26-
* BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages
27-
* This code has multiple switch statements that "fall through" to the
28-
* next case -- but it's not always clear if this is intentional or not.
29-
* Review and commenting of code, and reducing cyclomatic complexity
30-
* are highly recommended....
31-
*/
32-
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
33-
34-
3522
#define __CONFDESCPARSER_H__
3623

3724
#include <stdint.h>
@@ -113,6 +100,17 @@ template <const uint8_t CLASS_ID, const uint8_t SUBCLASS_ID, const uint8_t PROTO
113100
bool ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::ParseDescriptor(uint8_t **pp, uint32_t *pcntdn) {
114101
USB_CONFIGURATION_DESCRIPTOR* ucd = reinterpret_cast<USB_CONFIGURATION_DESCRIPTOR*>(varBuffer);
115102
USB_INTERFACE_DESCRIPTOR* uid = reinterpret_cast<USB_INTERFACE_DESCRIPTOR*>(varBuffer);
103+
104+
105+
#pragma GCC diagnostic push // Available since GCC 4.6.4
106+
/*
107+
* BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages
108+
* This code has multiple switch statements that "fall through" to the
109+
* next case -- but it's not always clear if this is intentional or not.
110+
* Review and commenting of code, and reducing cyclomatic complexity
111+
* are highly recommended....
112+
*/
113+
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
116114
switch(stateParseDescr) {
117115
case 0:
118116
theBuffer.valueSize = 2;
@@ -193,6 +191,8 @@ bool ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::ParseDescriptor
193191
theBuffer.pValue = varBuffer;
194192
stateParseDescr = 0;
195193
}
194+
#pragma GCC diagnostic pop
195+
196196
return true;
197197
}
198198

@@ -233,6 +233,5 @@ void ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::PrintHidDescrip
233233
}
234234

235235

236-
#pragma GCC diagnostic pop
237236

238237
#endif // __CONFDESCPARSER_H__

libraries/USBHost/src/hidescriptorparser.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,11 @@ void ReportDescParserBase::PrintItemTitle(uint8_t prefix) {
10871087
} // switch (**pp & (TYPE_MASK | TAG_MASK))
10881088
}
10891089

1090+
uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint32_t *pcntdn) {
1091+
//uint8_t ret = enErrorSuccess;
1092+
//reinterpret_cast<>(varBuffer);
1093+
1094+
10901095
#pragma GCC diagnostic push // Available since GCC 4.6.4
10911096
/*
10921097
* BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages
@@ -1096,9 +1101,6 @@ void ReportDescParserBase::PrintItemTitle(uint8_t prefix) {
10961101
* are highly recommended....
10971102
*/
10981103
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
1099-
uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint32_t *pcntdn) {
1100-
//uint8_t ret = enErrorSuccess;
1101-
//reinterpret_cast<>(varBuffer);
11021104
switch(itemParseState) {
11031105
case 0:
11041106
if(**pp == HID_LONG_ITEM_PREFIX)
@@ -1215,10 +1217,10 @@ uint8_t ReportDescParserBase::ParseItem(uint8_t **pp, uint32_t *pcntdn) {
12151217
} // switch (**pp & (TYPE_MASK | TAG_MASK))
12161218
}
12171219
} // switch (itemParseState)
1220+
#pragma GCC diagnostic pop
12181221
itemParseState = 0;
12191222
return enErrorSuccess;
12201223
}
1221-
#pragma GCC diagnostic pop
12221224

12231225
ReportDescParserBase::UsagePageFunc ReportDescParserBase::usagePageFunctions[] /*PROGMEM*/ = {
12241226
&ReportDescParserBase::PrintGenericDesktopPageUsage,
@@ -1446,6 +1448,9 @@ void ReportDescParserBase::PrintMedicalInstrumentPageUsage(uint16_t usage) {
14461448
else E_Notify(pstrUsagePageUndefined, 0x80);
14471449
}
14481450

1451+
uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint32_t *pcntdn) {
1452+
//uint8_t ret = enErrorSuccess;
1453+
14491454
#pragma GCC diagnostic push // Available since GCC 4.6.4
14501455
/*
14511456
* BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages
@@ -1455,9 +1460,6 @@ void ReportDescParserBase::PrintMedicalInstrumentPageUsage(uint16_t usage) {
14551460
* are highly recommended....
14561461
*/
14571462
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
1458-
uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint32_t *pcntdn) {
1459-
//uint8_t ret = enErrorSuccess;
1460-
14611463
switch(itemParseState) {
14621464
case 0:
14631465
if(**pp == HID_LONG_ITEM_PREFIX)
@@ -1537,10 +1539,11 @@ uint8_t ReportDescParser2::ParseItem(uint8_t **pp, uint32_t *pcntdn) {
15371539
} // switch (**pp & (TYPE_MASK | TAG_MASK))
15381540
}
15391541
} // switch (itemParseState)
1542+
#pragma GCC diagnostic pop
1543+
15401544
itemParseState = 0;
15411545
return enErrorSuccess;
15421546
}
1543-
#pragma GCC diagnostic pop
15441547

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

libraries/USBHost/src/parsetools.cpp

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

34+
bool PTPListParser::Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me) {
35+
3436
#pragma GCC diagnostic push // Available since GCC 4.6.4
3537
/*
3638
* BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages
@@ -40,7 +42,7 @@ bool MultiByteValueParser::Parse(uint8_t **pp, uint32_t *pcntdn) {
4042
* are highly recommended....
4143
*/
4244
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
43-
bool PTPListParser::Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me) {
45+
4446
switch(nStage) {
4547
case 0:
4648
pBuf->valueSize = lenSize;
@@ -71,6 +73,7 @@ bool PTPListParser::Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf,
7173
}
7274
nStage = 0;
7375
}
76+
#pragma GCC diagnostic pop
77+
7478
return true;
7579
}
76-
#pragma GCC diagnostic pop

libraries/USBHost/src/parsetools.h

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,6 @@ e-mail : [email protected]
2323
#include <stdint.h>
2424
//#include "Arduino.h"
2525

26-
#pragma GCC diagnostic push // Available since GCC 4.6.4
27-
/*
28-
* BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages
29-
* This code has multiple switch statements that "fall through" to the
30-
* next case -- but it's not always clear if this is intentional or not.
31-
* Review and commenting of code, and reducing cyclomatic complexity
32-
* are highly recommended....
33-
*/
34-
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
35-
36-
37-
38-
3926
struct MultiValueBuffer {
4027
uint8_t valueSize;
4128
void *pValue;
@@ -79,6 +66,15 @@ class ByteSkipper {
7966
};
8067

8168
bool Skip(uint8_t **pp, uint32_t *pcntdn, uint32_t bytes_to_skip) {
69+
#pragma GCC diagnostic push // Available since GCC 4.6.4
70+
/*
71+
* BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages
72+
* This code has multiple switch statements that "fall through" to the
73+
* next case -- but it's not always clear if this is intentional or not.
74+
* Review and commenting of code, and reducing cyclomatic complexity
75+
* are highly recommended....
76+
*/
77+
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
8278
switch(nStage) {
8379
case 0:
8480
countDown = bytes_to_skip;
@@ -88,6 +84,7 @@ class ByteSkipper {
8884
if(!countDown)
8985
nStage = 0;
9086
};
87+
#pragma GCC diagnostic pop
9188
return (!countDown);
9289
};
9390
};
@@ -152,7 +149,4 @@ class PTPListParser {
152149
bool Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me = NULL);
153150
};
154151

155-
156-
#pragma GCC diagnostic pop
157-
158152
#endif // __PARSETOOLS_H__

0 commit comments

Comments
 (0)