Use saturating_sub to make sure we don't overflow
This commit is contained in:
parent
681393150d
commit
0708ce1410
1 changed files with 2 additions and 2 deletions
|
@ -604,8 +604,8 @@ impl<'d, T: Instance> UartRx<'d, T, Async> {
|
||||||
return match (all_full, last_was_break) {
|
return match (all_full, last_was_break) {
|
||||||
(true, true) | (false, _) => {
|
(true, true) | (false, _) => {
|
||||||
// We got less than the full amount + a break, or the full amount
|
// We got less than the full amount + a break, or the full amount
|
||||||
// and the last byte was a break. Subtract the break off.
|
// and the last byte was a break. Subtract the break off by adding one to sval.
|
||||||
Ok((next_addr - 1) - sval)
|
Ok(next_addr.saturating_sub(1 + sval))
|
||||||
}
|
}
|
||||||
(true, false) => {
|
(true, false) => {
|
||||||
// We finished the whole DMA, and the last DMA'd byte was NOT a break
|
// We finished the whole DMA, and the last DMA'd byte was NOT a break
|
||||||
|
|
Loading…
Reference in a new issue