Skip to content

Commit 9aca092

Browse files
committed
squeeze the usb identification code; manufacturer was being copied to product
1 parent daf415d commit 9aca092

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

shared-bindings/supervisor/__init__.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ STATIC mp_obj_t supervisor_set_usb_identification(size_t n_args, const mp_obj_t
348348
memcpy(identification->manufacturer_name, info.buf, info.len);
349349
identification->manufacturer_name[info.len] = 0;
350350
} else {
351-
memcpy(identification->manufacturer_name, USB_MANUFACTURER, sizeof(USB_MANUFACTURER));
351+
strcpy(identification->manufacturer_name, USB_MANUFACTURER);
352352
}
353353

354354
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
357357
memcpy(identification->product_name, info.buf, info.len);
358358
identification->product_name[info.len] = 0;
359359
} else {
360-
memcpy(identification->product_name, USB_MANUFACTURER, sizeof(USB_MANUFACTURER));
360+
strcpy(identification->product_name, USB_PRODUCT);
361361
}
362362

363363
return mp_const_none;

supervisor/shared/usb/usb.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,12 @@ void usb_get_boot_py_data(uint8_t *temp_storage, size_t temp_storage_size) {
143143
if (usb_identification_allocation) {
144144
memcpy(temp_storage, usb_identification_allocation->ptr, sizeof(usb_identification_t));
145145
free_memory(usb_identification_allocation);
146+
}
146147
#else
147148
if (false) {
148-
// Nothing
149-
#endif
150-
} else {
149+
}
150+
#endif
151+
else {
151152
usb_identification_t defaults;
152153
// This compiles to less code than using a struct initializer.
153154
defaults.vid = USB_VID;

0 commit comments

Comments
 (0)