Add USB_STATUS_CODE_SIZE and use it to kill the magic numbers of usb_command_read_config()

This commit is contained in:
László Monda
2017-11-06 00:44:32 +01:00
parent 003f313947
commit 9910fe536f
2 changed files with 4 additions and 2 deletions

View File

@@ -8,7 +8,7 @@ void UsbCommand_ReadConfig(bool isHardware)
uint8_t length = GET_USB_BUFFER_UINT8(1);
uint16_t offset = GET_USB_BUFFER_UINT16(2);
if (length > USB_GENERIC_HID_OUT_BUFFER_LENGTH-1) {
if (length > USB_GENERIC_HID_OUT_BUFFER_LENGTH - USB_STATUS_CODE_SIZE) {
SET_USB_BUFFER_UINT8(0, UsbStatusCode_ReadConfig_LengthTooLarge);
return;
}
@@ -21,5 +21,5 @@ void UsbCommand_ReadConfig(bool isHardware)
return;
}
memcpy(GenericHidOutBuffer+1, buffer+offset, length);
memcpy(GenericHidOutBuffer + USB_STATUS_CODE_SIZE, buffer + offset, length);
}