projects
/
pub
/
USBasp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Tighten up the Bootloader GetDescriptor() function, as the descriptor size can be...
[pub/USBasp.git]
/
Bootloaders
/
CDC
/
Descriptors.c
diff --git
a/Bootloaders/CDC/Descriptors.c
b/Bootloaders/CDC/Descriptors.c
index
5cffe2f
..
267c5dc
100644
(file)
--- a/
Bootloaders/CDC/Descriptors.c
+++ b/
Bootloaders/CDC/Descriptors.c
@@
-206,38
+206,29
@@
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
const uint8_t wIndex,
const void** const DescriptorAddress)
{
const uint8_t wIndex,
const void** const DescriptorAddress)
{
- const uint8_t
DescriptorType = (wValue >> 8);
- const uint8_t
DescriptorNumber = (wValue & 0xFF);
+ const uint8_t DescriptorType = (wValue >> 8);
+ const uint8_t DescriptorNumber = (wValue & 0xFF);
const void* Address = NULL;
const void* Address = NULL;
- uint16_t Size = NO_DESCRIPTOR;
switch (DescriptorType)
{
case DTYPE_Device:
Address = &DeviceDescriptor;
switch (DescriptorType)
{
case DTYPE_Device:
Address = &DeviceDescriptor;
- Size = sizeof(USB_Descriptor_Device_t);
break;
case DTYPE_Configuration:
Address = &ConfigurationDescriptor;
break;
case DTYPE_Configuration:
Address = &ConfigurationDescriptor;
- Size = sizeof(USB_Descriptor_Configuration_t);
break;
case DTYPE_String:
if (!(DescriptorNumber))
break;
case DTYPE_String:
if (!(DescriptorNumber))
- {
- Address = &LanguageString;
- Size = LanguageString.Header.Size;
- }
+ Address = &LanguageString;
else
else
- {
- Address = &ProductString;
- Size = ProductString.Header.Size;
- }
+ Address = &ProductString;
break;
}
*DescriptorAddress = Address;
break;
}
*DescriptorAddress = Address;
- return
Size
;
+ return
(Address != NULL) ? ((USB_Descriptor_Header_t*)Address)->Size : NO_DESCRIPTOR
;
}
}