From 9aca092900cceacee8f4fd853bc9144e5f1de1b0 Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Tue, 20 Sep 2022 20:09:30 -0400 Subject: [PATCH] squeeze the usb identification code; manufacturer was being copied to product --- shared-bindings/supervisor/__init__.c | 4 ++-- supervisor/shared/usb/usb.c | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index 0feb5055db..40f8461af4 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -348,7 +348,7 @@ STATIC mp_obj_t supervisor_set_usb_identification(size_t n_args, const mp_obj_t memcpy(identification->manufacturer_name, info.buf, info.len); identification->manufacturer_name[info.len] = 0; } else { - memcpy(identification->manufacturer_name, USB_MANUFACTURER, sizeof(USB_MANUFACTURER)); + strcpy(identification->manufacturer_name, USB_MANUFACTURER); } if (args.product.u_obj != mp_const_none) { @@ -357,7 +357,7 @@ STATIC mp_obj_t supervisor_set_usb_identification(size_t n_args, const mp_obj_t memcpy(identification->product_name, info.buf, info.len); identification->product_name[info.len] = 0; } else { - memcpy(identification->product_name, USB_MANUFACTURER, sizeof(USB_MANUFACTURER)); + strcpy(identification->product_name, USB_PRODUCT); } return mp_const_none; diff --git a/supervisor/shared/usb/usb.c b/supervisor/shared/usb/usb.c index 3e64a79a7d..a51c6c2659 100644 --- a/supervisor/shared/usb/usb.c +++ b/supervisor/shared/usb/usb.c @@ -143,11 +143,12 @@ void usb_get_boot_py_data(uint8_t *temp_storage, size_t temp_storage_size) { if (usb_identification_allocation) { memcpy(temp_storage, usb_identification_allocation->ptr, sizeof(usb_identification_t)); free_memory(usb_identification_allocation); + } #else if (false) { - // Nothing - #endif - } else { + } + #endif + else { usb_identification_t defaults; // This compiles to less code than using a struct initializer. defaults.vid = USB_VID;