From 6a9ae3b7c36fcbe5a03c4f3481ee42a2c0847e01 Mon Sep 17 00:00:00 2001 From: Riccardo Date: Mon, 24 Jun 2019 18:12:23 -0700 Subject: [PATCH 1/2] The comma operator should not be used --- board/drivers/usb.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/board/drivers/usb.h b/board/drivers/usb.h index 97b962a28..5fa4b7985 100644 --- a/board/drivers/usb.h +++ b/board/drivers/usb.h @@ -397,7 +397,8 @@ void *USB_ReadPacket(void *dest, uint16_t len) { uint32_t i=0; uint32_t count32b = (len + 3) / 4; - for ( i = 0; i < count32b; i++, dest += 4 ) { + for ( i = 0; i < count32b; i++) { + dest += 4; // packed? *(__attribute__((__packed__)) uint32_t *)dest = USBx_DFIFO(0); } @@ -420,7 +421,8 @@ void USB_WritePacket(const uint8_t *src, uint16_t len, uint32_t ep) { USBx_INEP(ep)->DIEPCTL |= (USB_OTG_DIEPCTL_CNAK | USB_OTG_DIEPCTL_EPENA); // load the FIFO - for (i = 0; i < count32b; i++, src += 4) { + for (i = 0; i < count32b; i++) { + src += 4; USBx_DFIFO(ep) = *((__attribute__((__packed__)) uint32_t *)src); } } From 541f8beee378613dc26762934d9265e8d8f066b2 Mon Sep 17 00:00:00 2001 From: Riccardo Date: Mon, 24 Jun 2019 19:16:04 -0700 Subject: [PATCH 2/2] Fix bad bug --- board/drivers/usb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/board/drivers/usb.h b/board/drivers/usb.h index 5fa4b7985..ca0d1f7b6 100644 --- a/board/drivers/usb.h +++ b/board/drivers/usb.h @@ -398,9 +398,9 @@ void *USB_ReadPacket(void *dest, uint16_t len) { uint32_t count32b = (len + 3) / 4; for ( i = 0; i < count32b; i++) { - dest += 4; // packed? *(__attribute__((__packed__)) uint32_t *)dest = USBx_DFIFO(0); + dest += 4; } return ((void *)dest); } @@ -422,8 +422,8 @@ void USB_WritePacket(const uint8_t *src, uint16_t len, uint32_t ep) { // load the FIFO for (i = 0; i < count32b; i++) { - src += 4; USBx_DFIFO(ep) = *((__attribute__((__packed__)) uint32_t *)src); + src += 4; } }