diff options
author | Brian Cully <bjc@kublai.com> | 2019-07-27 21:43:04 -0400 |
---|---|---|
committer | Brian Cully <bjc@kublai.com> | 2019-07-27 21:43:04 -0400 |
commit | 268062bd6cfb7ec5c4f4548eaefb0e615ac627b7 (patch) | |
tree | 69dac5c1d192006ff1b3b915d83ba044d8fb650a /usbh/src | |
parent | 59ffeec652f56f9eed0a26d1caaa892f47be18fd (diff) | |
download | samd21-demo-268062bd6cfb7ec5c4f4548eaefb0e615ac627b7.tar.gz samd21-demo-268062bd6cfb7ec5c4f4548eaefb0e615ac627b7.zip |
Put size assertions in pcksize writers.
Diffstat (limited to 'usbh/src')
-rw-r--r-- | usbh/src/pipe/pck_size.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/usbh/src/pipe/pck_size.rs b/usbh/src/pipe/pck_size.rs index d8fb4cb..9648381 100644 --- a/usbh/src/pipe/pck_size.rs +++ b/usbh/src/pipe/pck_size.rs @@ -340,6 +340,8 @@ pub(crate) struct MultiPacketSizeW<'a> { } impl<'a> MultiPacketSizeW<'a> { pub unsafe fn bits(self, v: u16) -> &'a mut W { + assert!(v < 16_384); + const POS: u8 = 14; const MASK: u16 = 0x3fff; self.w.bits &= !((MASK as u32) << POS); @@ -355,6 +357,8 @@ impl<'a> ByteCountW<'a> { // Documentation is wrong on this field. Actually 14 bits from // offset 0. pub unsafe fn bits(self, v: u16) -> &'a mut W { + assert!(v < 16_384); + const POS: u8 = 0; const MASK: u16 = 0x3fff; self.w.bits &= !((MASK as u32) << POS); |