Skip to content

Commit a2801a1

Browse files
committed
fix tab/space mixtures -- whitespace only change
1 parent 00dd2e0 commit a2801a1

File tree

4 files changed

+120
-122
lines changed

4 files changed

+120
-122
lines changed

libraries/USBHost/src/confdescparser.h

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

22+
23+
2224
#pragma GCC diagnostic push // Available since GCC 4.6.4
2325
/*
2426
* BUGBUG -- Enabled and review all `-Wimplicit-fallthrough` messages
@@ -70,15 +72,15 @@ class ConfigDescParser : public USBReadParser {
7072
uint32_t ifaceNumber; // Interface number
7173
uint32_t ifaceAltSet; // Interface alternate settings
7274

73-
bool UseOr;
75+
bool UseOr;
7476
bool ParseDescriptor(uint8_t **pp, uint32_t *pcntdn);
7577
void PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc);
7678

7779
public:
7880

79-
void SetOR(void) {
80-
UseOr = true;
81-
}
81+
void SetOR(void) {
82+
UseOr = true;
83+
}
8284
ConfigDescParser(UsbConfigXtracter *xtractor);
8385
virtual void Parse(const uint32_t len, const uint8_t *pbuf, const uint32_t &offset);
8486
};
@@ -109,8 +111,8 @@ void ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::Parse(const uin
109111
compare masks for them. When the match is found, calls EndpointXtract passing buffer containing endpoint descriptor */
110112
template <const uint8_t CLASS_ID, const uint8_t SUBCLASS_ID, const uint8_t PROTOCOL_ID, const uint8_t MASK>
111113
bool ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::ParseDescriptor(uint8_t **pp, uint32_t *pcntdn) {
112-
USB_CONFIGURATION_DESCRIPTOR* ucd = reinterpret_cast<USB_CONFIGURATION_DESCRIPTOR*>(varBuffer);
113-
USB_INTERFACE_DESCRIPTOR* uid = reinterpret_cast<USB_INTERFACE_DESCRIPTOR*>(varBuffer);
114+
USB_CONFIGURATION_DESCRIPTOR* ucd = reinterpret_cast<USB_CONFIGURATION_DESCRIPTOR*>(varBuffer);
115+
USB_INTERFACE_DESCRIPTOR* uid = reinterpret_cast<USB_INTERFACE_DESCRIPTOR*>(varBuffer);
114116
switch(stateParseDescr) {
115117
case 0:
116118
theBuffer.valueSize = 2;
@@ -123,22 +125,22 @@ bool ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::ParseDescriptor
123125
dscrType = *((uint8_t*)theBuffer.pValue + 1);
124126
stateParseDescr = 2;
125127
case 2:
126-
// This is a sort of hack. Assuming that two bytes are all ready in the buffer
128+
// This is a sort of hack. Assuming that two bytes are all ready in the buffer
127129
// the pointer is positioned two bytes ahead in order for the rest of descriptor
128130
// to be read right after the size and the type fields.
129131
// This should be used carefully. varBuffer should be used directly to handle data
130132
// in the buffer.
131133
theBuffer.pValue = varBuffer + 2;
132134
stateParseDescr = 3;
133135
case 3:
134-
switch(dscrType) {
135-
case USB_DESCRIPTOR_INTERFACE:
136-
isGoodInterface = false;
137-
case USB_DESCRIPTOR_CONFIGURATION:
138-
theBuffer.valueSize = sizeof (USB_CONFIGURATION_DESCRIPTOR) - 2;
139-
break;
140-
case USB_DESCRIPTOR_ENDPOINT:
141-
theBuffer.valueSize = sizeof (USB_ENDPOINT_DESCRIPTOR) - 2;
136+
switch(dscrType) {
137+
case USB_DESCRIPTOR_INTERFACE:
138+
isGoodInterface = false;
139+
case USB_DESCRIPTOR_CONFIGURATION:
140+
theBuffer.valueSize = sizeof (USB_CONFIGURATION_DESCRIPTOR) - 2;
141+
break;
142+
case USB_DESCRIPTOR_ENDPOINT:
143+
theBuffer.valueSize = sizeof (USB_ENDPOINT_DESCRIPTOR) - 2;
142144
break;
143145
case HID_DESCRIPTOR_HID:
144146
theBuffer.valueSize = dscrLen - 2;
@@ -147,37 +149,37 @@ bool ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::ParseDescriptor
147149
valParser.Initialize(&theBuffer);
148150
stateParseDescr = 4;
149151
case 4:
150-
switch(dscrType) {
152+
switch(dscrType) {
151153
case USB_DESCRIPTOR_CONFIGURATION:
152-
if(!valParser.Parse(pp, pcntdn))
153-
return false;
154-
confValue = ucd->bConfigurationValue;
154+
if(!valParser.Parse(pp, pcntdn))
155+
return false;
156+
confValue = ucd->bConfigurationValue;
155157
break;
156158
case USB_DESCRIPTOR_INTERFACE:
157-
if(!valParser.Parse(pp, pcntdn))
158-
return false;
159-
if((MASK & CP_MASK_COMPARE_CLASS) && uid->bInterfaceClass != CLASS_ID)
160-
break;
161-
if((MASK & CP_MASK_COMPARE_SUBCLASS) && uid->bInterfaceSubClass != SUBCLASS_ID)
162-
break;
163-
if(UseOr) {
164-
if((!((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol)))
165-
break;
166-
} else {
167-
if((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol != PROTOCOL_ID)
168-
break;
169-
}
170-
isGoodInterface = true;
171-
ifaceNumber = uid->bInterfaceNumber;
172-
ifaceAltSet = uid->bAlternateSetting;
173-
protoValue = uid->bInterfaceProtocol;
174-
break;
175-
case USB_DESCRIPTOR_ENDPOINT:
176-
if(!valParser.Parse(pp, pcntdn))
177-
return false;
178-
if(isGoodInterface)
179-
if(theXtractor)
180-
theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (USB_ENDPOINT_DESCRIPTOR*)varBuffer);
159+
if(!valParser.Parse(pp, pcntdn))
160+
return false;
161+
if((MASK & CP_MASK_COMPARE_CLASS) && uid->bInterfaceClass != CLASS_ID)
162+
break;
163+
if((MASK & CP_MASK_COMPARE_SUBCLASS) && uid->bInterfaceSubClass != SUBCLASS_ID)
164+
break;
165+
if(UseOr) {
166+
if((!((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol)))
167+
break;
168+
} else {
169+
if((MASK & CP_MASK_COMPARE_PROTOCOL) && uid->bInterfaceProtocol != PROTOCOL_ID)
170+
break;
171+
}
172+
isGoodInterface = true;
173+
ifaceNumber = uid->bInterfaceNumber;
174+
ifaceAltSet = uid->bAlternateSetting;
175+
protoValue = uid->bInterfaceProtocol;
176+
break;
177+
case USB_DESCRIPTOR_ENDPOINT:
178+
if(!valParser.Parse(pp, pcntdn))
179+
return false;
180+
if(isGoodInterface)
181+
if(theXtractor)
182+
theXtractor->EndpointXtract(confValue, ifaceNumber, ifaceAltSet, protoValue, (USB_ENDPOINT_DESCRIPTOR*)varBuffer);
181183
break;
182184
//case HID_DESCRIPTOR_HID:
183185
// if (!valParser.Parse(pp, pcntdn))
@@ -196,38 +198,38 @@ bool ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::ParseDescriptor
196198

197199
template <const uint8_t CLASS_ID, const uint8_t SUBCLASS_ID, const uint8_t PROTOCOL_ID, const uint8_t MASK>
198200
void ConfigDescParser<CLASS_ID, SUBCLASS_ID, PROTOCOL_ID, MASK>::PrintHidDescriptor(const USB_HID_DESCRIPTOR *pDesc) {
199-
Notify(PSTR("\r\n\r\nHID Descriptor:\r\n"), 0x80);
200-
Notify(PSTR("bDescLength:\t\t"), 0x80);
201-
PrintHex<uint8_t > (pDesc->bLength, 0x80);
201+
Notify(PSTR("\r\n\r\nHID Descriptor:\r\n"), 0x80);
202+
Notify(PSTR("bDescLength:\t\t"), 0x80);
203+
PrintHex<uint8_t > (pDesc->bLength, 0x80);
202204

203-
Notify(PSTR("\r\nbDescriptorType:\t"), 0x80);
204-
PrintHex<uint8_t > (pDesc->bDescriptorType, 0x80);
205+
Notify(PSTR("\r\nbDescriptorType:\t"), 0x80);
206+
PrintHex<uint8_t > (pDesc->bDescriptorType, 0x80);
205207

206-
Notify(PSTR("\r\nbcdHID:\t\t\t"), 0x80);
207-
PrintHex<uint16_t > (pDesc->bcdHID, 0x80);
208+
Notify(PSTR("\r\nbcdHID:\t\t\t"), 0x80);
209+
PrintHex<uint16_t > (pDesc->bcdHID, 0x80);
208210

209-
Notify(PSTR("\r\nbCountryCode:\t\t"), 0x80);
210-
PrintHex<uint8_t > (pDesc->bCountryCode, 0x80);
211+
Notify(PSTR("\r\nbCountryCode:\t\t"), 0x80);
212+
PrintHex<uint8_t > (pDesc->bCountryCode, 0x80);
211213

212-
Notify(PSTR("\r\nbNumDescriptors:\t"), 0x80);
213-
PrintHex<uint8_t > (pDesc->bNumDescriptors, 0x80);
214+
Notify(PSTR("\r\nbNumDescriptors:\t"), 0x80);
215+
PrintHex<uint8_t > (pDesc->bNumDescriptors, 0x80);
214216

215-
//Notify(PSTR("\r\nbDescrType:\t\t"));
216-
//PrintHex<uint8_t>(pDesc->bDescrType);
217-
//
218-
//Notify(PSTR("\r\nwDescriptorLength:\t"));
219-
//PrintHex<uint16_t>(pDesc->wDescriptorLength);
217+
//Notify(PSTR("\r\nbDescrType:\t\t"));
218+
//PrintHex<uint8_t>(pDesc->bDescrType);
219+
//
220+
//Notify(PSTR("\r\nwDescriptorLength:\t"));
221+
//PrintHex<uint16_t>(pDesc->wDescriptorLength);
220222

221223
for (uint32_t i = 0; i < pDesc->bNumDescriptors; i++) {
222224
HID_CLASS_DESCRIPTOR_LEN_AND_TYPE *pLT = (HID_CLASS_DESCRIPTOR_LEN_AND_TYPE*)&(pDesc->bDescrType);
223225

224-
Notify(PSTR("\r\nbDescrType:\t\t"), 0x80);
225-
PrintHex<uint8_t > (pLT[i].bDescrType, 0x80);
226+
Notify(PSTR("\r\nbDescrType:\t\t"), 0x80);
227+
PrintHex<uint8_t > (pLT[i].bDescrType, 0x80);
226228

227-
Notify(PSTR("\r\nwDescriptorLength:\t"), 0x80);
228-
PrintHex<uint16_t > (pLT[i].wDescriptorLength, 0x80);
229-
}
230-
Notify(PSTR("\r\n"), 0x80);
229+
Notify(PSTR("\r\nwDescriptorLength:\t"), 0x80);
230+
PrintHex<uint16_t > (pLT[i].wDescriptorLength, 0x80);
231+
}
232+
Notify(PSTR("\r\n"), 0x80);
231233
}
232234

233235

libraries/USBHost/src/hidescriptorparser.cpp

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,6 @@ void ReportDescParserBase::Parse(const uint32_t len, const uint8_t *pbuf, const
994994
uint32_t cntdn = (uint32_t)len;
995995
uint8_t *p = (uint8_t*)pbuf;
996996

997-
998997
totalSize = 0;
999998

1000999
while(cntdn) {
@@ -1246,18 +1245,18 @@ void ReportDescParserBase::SetUsagePage(uint16_t page) {
12461245
if(VALUE_BETWEEN(page, 0x00, 0x11))
12471246
pfUsage = (usagePageFunctions[page - 1]);
12481247

1249-
// Dead code...
1250-
//
1251-
// pfUsage = (UsagePageFunc)pgm_read_pointer(usagePageFunctions[page - 1]);
1252-
//else if (page > 0x7f && page < 0x84)
1253-
// E_Notify(pstrUsagePageMonitor);
1254-
//else if (page > 0x83 && page < 0x8c)
1255-
// E_Notify(pstrUsagePagePower);
1256-
//else if (page > 0x8b && page < 0x92)
1257-
// E_Notify((char*)pgm_read_pointer(&usagePageTitles1[page - 0x8c]));
1258-
//else if (page > 0xfeff && page <= 0xffff)
1259-
// E_Notify(pstrUsagePageVendorDefined);
1260-
//
1248+
// Dead code...
1249+
//
1250+
// pfUsage = (UsagePageFunc)pgm_read_pointer(usagePageFunctions[page - 1]);
1251+
//else if (page > 0x7f && page < 0x84)
1252+
// E_Notify(pstrUsagePageMonitor);
1253+
//else if (page > 0x83 && page < 0x8c)
1254+
// E_Notify(pstrUsagePagePower);
1255+
//else if (page > 0x8b && page < 0x92)
1256+
// E_Notify((char*)pgm_read_pointer(&usagePageTitles1[page - 0x8c]));
1257+
//else if (page > 0xfeff && page <= 0xffff)
1258+
// E_Notify(pstrUsagePageVendorDefined);
1259+
//
12611260
else
12621261
switch(page) {
12631262
case 0x14:
@@ -1578,8 +1577,7 @@ void ReportDescParser2::OnInputItem(uint8_t itm) {
15781577
// bits_to_copy - number of bits to copy to result buffer
15791578

15801579
// for each bit in a field
1581-
for(uint8_t bits_left = rptSize, bits_to_copy = 0; bits_left;
1582-
bits_left -= bits_to_copy) {
1580+
for(uint8_t bits_left = rptSize, bits_to_copy = 0; bits_left; bits_left -= bits_to_copy) {
15831581
bits_to_copy = (bits_left > bits_of_byte) ? bits_of_byte : bits_left;
15841582

15851583
result.dwResult <<= bits_to_copy; // Result buffer is shifted by the number of bits to be copied into it

libraries/USBHost/src/parsetools.cpp

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ e-mail : [email protected]
1717
#include "Usb.h"
1818

1919
bool MultiByteValueParser::Parse(uint8_t **pp, uint32_t *pcntdn) {
20-
if(!pBuf) {
21-
Notify(PSTR("Buffer pointer is NULL!\r\n"), 0x80);
20+
if(!pBuf) {
21+
Notify(PSTR("Buffer pointer is NULL!\r\n"), 0x80);
2222
return false;
2323
}
2424
for (; countDown && (*pcntdn); countDown--, (*pcntdn)--, (*pp)++)
2525
pBuf[valueSize - countDown] = (**pp);
2626

27-
if(countDown)
27+
if(countDown)
2828
return false;
2929

3030
countDown = valueSize;
@@ -41,35 +41,34 @@ bool MultiByteValueParser::Parse(uint8_t **pp, uint32_t *pcntdn) {
4141
*/
4242
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
4343
bool PTPListParser::Parse(uint8_t **pp, uint32_t *pcntdn, PTP_ARRAY_EL_FUNC pf, const void *me) {
44-
switch(nStage) {
45-
case 0:
46-
pBuf->valueSize = lenSize;
47-
theParser.Initialize(pBuf);
48-
nStage = 1;
44+
switch(nStage) {
45+
case 0:
46+
pBuf->valueSize = lenSize;
47+
theParser.Initialize(pBuf);
48+
nStage = 1;
4949

50-
case 1:
51-
if(!theParser.Parse(pp, pcntdn))
52-
return false;
50+
case 1:
51+
if(!theParser.Parse(pp, pcntdn))
52+
return false;
5353

54-
arLen = 0;
55-
arLen = (pBuf->valueSize >= 4) ? *((uint32_t*)pBuf->pValue) : (uint32_t)(*((uint16_t*)pBuf->pValue));
56-
arLenCntdn = arLen;
57-
nStage = 2;
54+
arLen = 0;
55+
arLen = (pBuf->valueSize >= 4) ? *((uint32_t*)pBuf->pValue) : (uint32_t)(*((uint16_t*)pBuf->pValue));
56+
arLenCntdn = arLen;
57+
nStage = 2;
5858

59-
case 2:
60-
pBuf->valueSize = valSize;
61-
theParser.Initialize(pBuf);
62-
nStage = 3;
59+
case 2:
60+
pBuf->valueSize = valSize;
61+
theParser.Initialize(pBuf);
62+
nStage = 3;
6363

64-
case 3:
65-
for(; arLenCntdn; arLenCntdn--) {
66-
if(!theParser.Parse(pp, pcntdn))
67-
return false;
64+
case 3:
65+
for(; arLenCntdn; arLenCntdn--) {
66+
if(!theParser.Parse(pp, pcntdn))
67+
return false;
6868

6969
if(pf)
7070
pf(pBuf, (arLen - arLenCntdn), me);
7171
}
72-
7372
nStage = 0;
7473
}
7574
return true;

libraries/USBHost/src/parsetools.h

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ class MultiByteValueParser {
4848

4949
public:
5050

51-
MultiByteValueParser() : pBuf(NULL), countDown(0), valueSize(0) {
52-
};
51+
MultiByteValueParser() : pBuf(NULL), countDown(0), valueSize(0) {
52+
};
5353

54-
const uint8_t* GetBuffer() {
55-
return pBuf;
56-
};
54+
const uint8_t* GetBuffer() {
55+
return pBuf;
56+
};
5757

5858
void Initialize(MultiValueBuffer * const pbuf) {
5959
pBuf = (uint8_t*)pbuf->pValue;
@@ -71,23 +71,22 @@ class ByteSkipper {
7171
public:
7272

7373
ByteSkipper() : pBuf(NULL), nStage(0), countDown(0) {
74-
};
74+
};
7575

7676
void Initialize(MultiValueBuffer *pbuf) {
7777
pBuf = (uint8_t*)pbuf->pValue;
7878
countDown = 0;
7979
};
8080

8181
bool Skip(uint8_t **pp, uint32_t *pcntdn, uint32_t bytes_to_skip) {
82-
switch(nStage) {
83-
case 0:
84-
countDown = bytes_to_skip;
85-
nStage++;
86-
case 1:
87-
for(; countDown && (*pcntdn); countDown--, (*pp)++, (*pcntdn)--);
88-
89-
if(!countDown)
90-
nStage = 0;
82+
switch(nStage) {
83+
case 0:
84+
countDown = bytes_to_skip;
85+
nStage++;
86+
case 1:
87+
for(; countDown && (*pcntdn); countDown--, (*pp)++, (*pcntdn)--);
88+
if(!countDown)
89+
nStage = 0;
9190
};
9291
return (!countDown);
9392
};
@@ -99,9 +98,9 @@ typedef void (*PTP_ARRAY_EL_FUNC)(const MultiValueBuffer * const p, uint32_t cou
9998
class PTPListParser {
10099
public:
101100

102-
enum ParseMode {
103-
modeArray, modeRange/*, modeEnum*/
104-
};
101+
enum ParseMode {
102+
modeArray, modeRange/*, modeEnum*/
103+
};
105104

106105
private:
107106
uint32_t nStage;

0 commit comments

Comments
 (0)