squeeze the usb identification code; manufacturer was being copied to product

This commit is contained in:
Dan Halbert 2022-09-20 20:09:30 -04:00
parent daf415d9c7
commit 9aca092900
2 changed files with 6 additions and 5 deletions

View File

@ -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;

View File

@ -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;