Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/test_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ mod sizes {
pub const INTERRUPT_ENDPOINT: u16 = 31;
}

static mut CONTROL_BUFFER: UnsafeCell<[u8; 256]> = UnsafeCell::new([0; 256]);
pub struct ControlBuffer(UnsafeCell<[u8; 256]>);

unsafe impl Sync for ControlBuffer {}

static CONTROL_BUFFER: ControlBuffer = ControlBuffer(UnsafeCell::new([0; 256]));

/// Test USB class for testing USB driver implementations. Supports various endpoint types and
/// requests for testing USB peripheral drivers on actual hardware.
Expand Down Expand Up @@ -115,7 +119,7 @@ impl<B: UsbBus> TestClass<'_, B> {
usb_bus: &'a UsbBusAllocator<B>,
) -> UsbDeviceBuilder<'a, B> {
UsbDeviceBuilder::new(usb_bus, UsbVidPid(VID, PID), unsafe {
CONTROL_BUFFER.get_mut()
&mut *(CONTROL_BUFFER.0.get())
})
.strings(&[StringDescriptors::default()
.manufacturer(MANUFACTURER)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_class_host/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn open_device(ctx: &Context) -> rusb::Result<DeviceHandles> {
continue;
}

let mut handle = device.open()?;
let handle = device.open()?;

let langs = handle.read_languages(TIMEOUT)?;
if langs.is_empty() || langs[0].lang_id() != EN_US {
Expand Down