diff options
author | Brian Cully <bjc@kublai.com> | 2019-10-08 09:27:48 -0400 |
---|---|---|
committer | Brian Cully <bjc@kublai.com> | 2019-10-08 09:27:48 -0400 |
commit | 6d6fd2617ab909987e5ddecfb36519f0667ecf57 (patch) | |
tree | 67ad93f566845bfbfd661f0bca36081845ec410a /src | |
parent | e0542778e674d623b48ed0de9ab4195d2f1bfc5e (diff) | |
download | atsamd-usb-host-6d6fd2617ab909987e5ddecfb36519f0667ecf57.tar.gz atsamd-usb-host-6d6fd2617ab909987e5ddecfb36519f0667ecf57.zip |
Don't `assume_init` when allocating device descriptor buffer.
Unwrap after `assert` of transfer length.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -407,9 +407,9 @@ where in_toggle: true, out_toggle: true, }; - let mut dev_desc: DeviceDescriptor = - unsafe { MaybeUninit::<DeviceDescriptor>::uninit().assume_init() }; - self.control_transfer( + + let mut dev_desc: MaybeUninit<DeviceDescriptor> = MaybeUninit::uninit(); + let len = self.control_transfer( &mut a0ep0, RequestType::from(( RequestDirection::DeviceToHost, @@ -421,6 +421,8 @@ where 0, Some(unsafe { to_slice_mut(&mut dev_desc) }), )?; + assert!(len == mem::size_of::<DeviceDescriptor>()); + let dev_desc = unsafe { dev_desc.assume_init() }; trace!(" -- dev_desc: {:?}", dev_desc); |