From 1280073c044fd082a1808cd720f7169b2b7db21a Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Thu, 25 Jan 2018 15:34:45 +0100 Subject: [PATCH] trezorhal: remove unnecessary casting for usb strings --- embed/bootloader/main.c | 10 +++++----- embed/extmod/modtrezorio/modtrezorio-usb.h | 10 +++++----- embed/prodtest/main.c | 10 +++++----- embed/trezorhal/usb.c | 14 +++++++------- embed/trezorhal/usb.h | 20 ++++++++++---------- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/embed/bootloader/main.c b/embed/bootloader/main.c index 3a494fc64..039b78620 100644 --- a/embed/bootloader/main.c +++ b/embed/bootloader/main.c @@ -34,11 +34,11 @@ static void usb_init_all(void) { .vendor_id = 0x1209, .product_id = 0x53C0, .release_num = 0x0002, - .manufacturer = (const uint8_t *)"SatoshiLabs", - .product = (const uint8_t *)"TREZOR Bootloader", - .serial_number = (const uint8_t *)"", - .configuration = (const uint8_t *)"", - .interface = (const uint8_t *)"TREZOR Interface", + .manufacturer = "SatoshiLabs", + .product = "TREZOR Bootloader", + .serial_number = "", + .configuration = "", + .interface = "TREZOR Interface", }; static uint8_t rx_buffer[USB_PACKET_SIZE]; diff --git a/embed/extmod/modtrezorio/modtrezorio-usb.h b/embed/extmod/modtrezorio/modtrezorio-usb.h index f02e81b14..c5d1ab3aa 100644 --- a/embed/extmod/modtrezorio/modtrezorio-usb.h +++ b/embed/extmod/modtrezorio/modtrezorio-usb.h @@ -92,11 +92,11 @@ STATIC mp_obj_t mod_trezorio_USB_make_new(const mp_obj_type_t *type, size_t n_ar o->info.vendor_id = (uint16_t)(vendor_id); o->info.product_id = (uint16_t)(product_id); o->info.release_num = (uint16_t)(release_num); - o->info.manufacturer = (const uint8_t *)(manufacturer); - o->info.product = (const uint8_t *)(product); - o->info.serial_number = (const uint8_t *)(serial_number); - o->info.configuration = (const uint8_t *)(configuration); - o->info.interface = (const uint8_t *)(interface); + o->info.manufacturer = manufacturer; + o->info.product = product; + o->info.serial_number = serial_number; + o->info.configuration = configuration; + o->info.interface = interface; mp_obj_list_init(&o->ifaces, 0); return MP_OBJ_FROM_PTR(o); diff --git a/embed/prodtest/main.c b/embed/prodtest/main.c index dd614cd2a..6f192d0a4 100644 --- a/embed/prodtest/main.c +++ b/embed/prodtest/main.c @@ -89,11 +89,11 @@ static void usb_init_all(void) .vendor_id = 0x1209, .product_id = 0x53C1, .release_num = 0x0002, - .manufacturer = (const uint8_t *)"SatoshiLabs", - .product = (const uint8_t *)"TREZOR", - .serial_number = (const uint8_t *)"000000000000", - .configuration = (const uint8_t *)"", - .interface = (const uint8_t *)"TREZOR Interface", + .manufacturer = "SatoshiLabs", + .product = "TREZOR", + .serial_number = "000000000000", + .configuration = "", + .interface = "TREZOR Interface", }; static uint8_t tx_packet[VCP_PACKET_LEN]; diff --git a/embed/trezorhal/usb.c b/embed/trezorhal/usb.c index cc3fdc847..401fc7114 100644 --- a/embed/trezorhal/usb.c +++ b/embed/trezorhal/usb.c @@ -52,9 +52,9 @@ static USBD_HandleTypeDef usb_dev_handle; static const USBD_DescriptorsTypeDef usb_descriptors; static const USBD_ClassTypeDef usb_class; -static secbool __wur check_desc_str(const uint8_t *s) { +static secbool __wur check_desc_str(const char *s) { if (NULL == s) return secfalse; - if (strlen((const char *)s) > USB_MAX_STR_SIZE) return secfalse; + if (strlen(s) > USB_MAX_STR_SIZE) return secfalse; return sectrue; } @@ -189,27 +189,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(usb_str_table.manufacturer, usb_str_buf, length); + USBD_GetString((uint8_t *)usb_str_table.manufacturer, usb_str_buf, length); return usb_str_buf; } static uint8_t *usb_get_product_str_descriptor(USBD_SpeedTypeDef speed, uint16_t *length) { - USBD_GetString(usb_str_table.product, usb_str_buf, length); + USBD_GetString((uint8_t *)usb_str_table.product, usb_str_buf, length); return usb_str_buf; } static uint8_t *usb_get_serial_str_descriptor(USBD_SpeedTypeDef speed, uint16_t *length) { - USBD_GetString(usb_str_table.serial_number, usb_str_buf, length); + USBD_GetString((uint8_t *)usb_str_table.serial_number, usb_str_buf, length); return usb_str_buf; } static uint8_t *usb_get_configuration_str_descriptor(USBD_SpeedTypeDef speed, uint16_t *length) { - USBD_GetString(usb_str_table.configuration, usb_str_buf, length); + USBD_GetString((uint8_t *)usb_str_table.configuration, usb_str_buf, length); return usb_str_buf; } static uint8_t *usb_get_interface_str_descriptor(USBD_SpeedTypeDef speed, uint16_t *length) { - USBD_GetString(usb_str_table.interface, usb_str_buf, length); + USBD_GetString((uint8_t *)usb_str_table.interface, usb_str_buf, length); return usb_str_buf; } diff --git a/embed/trezorhal/usb.h b/embed/trezorhal/usb.h index 3f690def3..bdd3a4609 100644 --- a/embed/trezorhal/usb.h +++ b/embed/trezorhal/usb.h @@ -86,22 +86,22 @@ typedef enum { } usb_language_id_t; typedef struct { - const uint8_t *manufacturer; - const uint8_t *product; - const uint8_t *serial_number; - const uint8_t *configuration; - const uint8_t *interface; + const char *manufacturer; + const char *product; + const char *serial_number; + const char *configuration; + const char *interface; } usb_dev_string_table_t; typedef struct { uint16_t vendor_id; uint16_t product_id; uint16_t release_num; - const uint8_t *manufacturer; - const uint8_t *product; - const uint8_t *serial_number; - const uint8_t *configuration; - const uint8_t *interface; + const char *manufacturer; + const char *product; + const char *serial_number; + const char *configuration; + const char *interface; } usb_dev_info_t; typedef enum {