From 268062bd6cfb7ec5c4f4548eaefb0e615ac627b7 Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Sat, 27 Jul 2019 21:43:04 -0400 Subject: Put size assertions in pcksize writers. --- usbh/src/pipe/pck_size.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'usbh/src/pipe') 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); -- cgit v1.2.3