@@ -402,7 +402,7 @@ void USBDevice::_complete_set_configuration()
402402 if ((_abort_control || !success) && !configured ()) {
403403 // The set configuration request was aborted or failed so
404404 // reset any endpoints which may have been added.
405- memset (_endpoint_info, 0 , sizeof (_endpoint_info) );
405+ _clear_endpoints ( );
406406 _device.configuration = 0 ;
407407 _endpoint_add_remove_allowed = false ;
408408 }
@@ -1348,7 +1348,7 @@ USBDevice::USBDevice(USBPhy *phy, uint16_t vendor_id, uint16_t product_id, uint1
13481348 this ->product_id = product_id;
13491349 this ->product_release = product_release;
13501350
1351- memset (_endpoint_info, 0 , sizeof (_endpoint_info) );
1351+ _clear_endpoints ( );
13521352 memset (&_transfer, 0 , sizeof (_transfer));
13531353 _transfer.user_callback = None;
13541354
@@ -1754,7 +1754,7 @@ void USBDevice::_change_state(DeviceState new_state)
17541754 bool leaving_default_state = (old_state >= Default) && (new_state < Default);
17551755
17561756 if (leaving_configured_state) {
1757- memset (_endpoint_info, 0 , sizeof (_endpoint_info) );
1757+ _clear_endpoints ( );
17581758 _device.configuration = 0 ;
17591759 _endpoint_add_remove_allowed = false ;
17601760 }
@@ -1771,3 +1771,11 @@ void USBDevice::_run_later(void (USBDevice::*function)())
17711771{
17721772 _post_process = function;
17731773}
1774+
1775+ void USBDevice::_clear_endpoints ()
1776+ {
1777+ for (auto & info : _endpoint_info)
1778+ {
1779+ info = endpoint_info_t {};
1780+ }
1781+ }
0 commit comments