From ed9fad8c7e71d7a868683957bbfdf64c0eca7ffe Mon Sep 17 00:00:00 2001 From: Til Blechschmidt Date: Wed, 23 Feb 2022 22:51:01 +0100 Subject: [PATCH] Skip EasyDMA slice location check if slice is empty --- embassy-nrf/src/lib.rs | 2 +- embassy-nrf/src/util.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs index b448f6ab..a9df231e 100644 --- a/embassy-nrf/src/lib.rs +++ b/embassy-nrf/src/lib.rs @@ -1,7 +1,7 @@ #![no_std] #![cfg_attr( feature = "nightly", - feature(generic_associated_types, type_alias_impl_trait) + feature(generic_associated_types, type_alias_impl_trait, slice_ptr_len) )] #[cfg(not(any( diff --git a/embassy-nrf/src/util.rs b/embassy-nrf/src/util.rs index b24bc452..84848e87 100644 --- a/embassy-nrf/src/util.rs +++ b/embassy-nrf/src/util.rs @@ -19,10 +19,10 @@ pub(crate) fn slice_in_ram(slice: *const [T]) -> bool { ptr >= SRAM_LOWER && (ptr + len * core::mem::size_of::()) < SRAM_UPPER } -/// Return an error if slice is not in RAM. +/// Return an error if slice is not in RAM. Skips check if slice is zero-length. #[cfg(not(feature = "nrf51"))] pub(crate) fn slice_in_ram_or(slice: *const [T], err: E) -> Result<(), E> { - if slice_in_ram(slice) { + if slice.len() > 0 && slice_in_ram(slice) { Ok(()) } else { Err(err)