From 9fcd21922f83d51bfc195946d3857779938bbc3c Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Tue, 28 Mar 2017 00:42:24 +0200 Subject: [PATCH] trezorhal: use UNCONST macro in usb stack --- micropython/trezorhal/usb.c | 12 +++++++----- micropython/trezorhal/usb_hid-impl.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/micropython/trezorhal/usb.c b/micropython/trezorhal/usb.c index d2eee8c6..eea6696c 100644 --- a/micropython/trezorhal/usb.c +++ b/micropython/trezorhal/usb.c @@ -5,6 +5,8 @@ #include "usb.h" #include "usbd_core.h" +#define UNCONST(X) ((uint8_t *)(X)) + #define USB_MAX_CONFIG_DESC_SIZE 128 #define USB_MAX_STR_DESC_SIZE 256 @@ -94,27 +96,27 @@ static uint8_t *usb_get_langid_str_descriptor(USBD_SpeedTypeDef speed, uint16_t } static uint8_t *usb_get_manufacturer_str_descriptor(USBD_SpeedTypeDef speed, uint16_t *length) { - USBD_GetString((uint8_t *)usb_str_table.manufacturer_str, usb_str_buf, length); + USBD_GetString(UNCONST(usb_str_table.manufacturer_str), usb_str_buf, length); return usb_str_buf; } static uint8_t *usb_get_product_str_descriptor(USBD_SpeedTypeDef speed, uint16_t *length) { - USBD_GetString((uint8_t *)usb_str_table.product_str, usb_str_buf, length); + USBD_GetString(UNCONST(usb_str_table.product_str), usb_str_buf, length); return usb_str_buf; } static uint8_t *usb_get_serial_str_descriptor(USBD_SpeedTypeDef speed, uint16_t *length) { - USBD_GetString((uint8_t *)usb_str_table.serial_str, usb_str_buf, length); + USBD_GetString(UNCONST(usb_str_table.serial_str), usb_str_buf, length); return usb_str_buf; } static uint8_t *usb_get_config_str_descriptor(USBD_SpeedTypeDef speed, uint16_t *length) { - USBD_GetString((uint8_t *)usb_str_table.config_str, usb_str_buf, length); + USBD_GetString(UNCONST(usb_str_table.config_str), usb_str_buf, length); return usb_str_buf; } static uint8_t *usb_get_interface_str_descriptor(USBD_SpeedTypeDef speed, uint16_t *length) { - USBD_GetString((uint8_t *)usb_str_table.interface_str, usb_str_buf, length); + USBD_GetString(UNCONST(usb_str_table.interface_str), usb_str_buf, length); return usb_str_buf; } diff --git a/micropython/trezorhal/usb_hid-impl.h b/micropython/trezorhal/usb_hid-impl.h index c360ff4d..d1bfc7b6 100644 --- a/micropython/trezorhal/usb_hid-impl.h +++ b/micropython/trezorhal/usb_hid-impl.h @@ -124,7 +124,7 @@ int usb_hid_write(uint8_t iface_num, const uint8_t *buf, uint32_t len) { usb_hid_state_t *state = &usb_ifaces[iface_num].hid; state->in_idle = 0; - USBD_LL_Transmit(&usb_dev_handle, state->ep_in, (uint8_t *)buf, (uint16_t)len); + USBD_LL_Transmit(&usb_dev_handle, state->ep_in, UNCONST(buf), (uint16_t)len); return len; }