diff options
author | Cristian Maglie <c.maglie@arduino.cc> | 2015-10-01 12:35:24 +0200 |
---|---|---|
committer | Cristian Maglie <c.maglie@arduino.cc> | 2015-10-02 11:59:23 +0200 |
commit | bad9b58ce3e3770e12b9053c670b22c95aba8b45 (patch) | |
tree | ca6cb9d6eb6a268eb697b7d5e5598bc933b38933 /libraries/HID/HID.cpp | |
parent | 10512b3f9b2e30759d08af77960ab0ead539a055 (diff) |
[PUSB] Fixed checks on return values
Diffstat (limited to 'libraries/HID/HID.cpp')
-rw-r--r-- | libraries/HID/HID.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/libraries/HID/HID.cpp b/libraries/HID/HID.cpp index a871415..a109574 100644 --- a/libraries/HID/HID.cpp +++ b/libraries/HID/HID.cpp @@ -35,19 +35,23 @@ int HID_::getInterface(uint8_t* interfaceNum) return USB_SendControl(0, &hidInterface, sizeof(hidInterface)); } -int HID_::getDescriptor(int8_t t) +int HID_::getDescriptor(int8_t type) { - if (HID_REPORT_DESCRIPTOR_TYPE == t) { + if (HID_REPORT_DESCRIPTOR_TYPE == type) { HIDDescriptorListNode* current = rootNode; int total = 0; - while(current != NULL) { - total += USB_SendControl(TRANSFER_PGM,current->data,current->length); + while (current != NULL) { + int res = USB_SendControl(TRANSFER_PGM, current->data, current->length); + if (res == -1) + return -1; + total += res; current = current->next; } return total; - } else { - return 0; } + + // Ignored + return 0; } void HID_::AppendDescriptor(HIDDescriptorListNode *node) @@ -71,9 +75,9 @@ void HID_::SendReport(uint8_t id, const void* data, int len) USB_Send(endpoint() | TRANSFER_RELEASE,data,len); } -bool HID_::setup(USBSetup& setup, uint8_t i) +bool HID_::setup(USBSetup& setup, uint8_t interfaceNum) { - if (interface() != i) { + if (interface() != interfaceNum) { return false; } else { uint8_t r = setup.bRequest; |