From a47f0b8a4b7f57a8ae83235567401f339a2c0efb Mon Sep 17 00:00:00 2001 From: Dominic Fischer <14130965+Dominaezzz@users.noreply.github.com> Date: Thu, 25 Sep 2025 01:36:26 -0600 Subject: [PATCH] Replace unsafe with new std API (#4178) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Replace unsafe with new std API * bump * Fix link in readme --------- Co-authored-by: Dániel Buga --- esp-bootloader-esp-idf/Cargo.toml | 2 +- esp-bootloader-esp-idf/README.md | 2 +- esp-bootloader-esp-idf/src/partitions.rs | 11 ++--------- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/esp-bootloader-esp-idf/Cargo.toml b/esp-bootloader-esp-idf/Cargo.toml index 9ac4b1062..e1c86a7a7 100644 --- a/esp-bootloader-esp-idf/Cargo.toml +++ b/esp-bootloader-esp-idf/Cargo.toml @@ -2,7 +2,7 @@ name = "esp-bootloader-esp-idf" version = "0.2.0" edition = "2024" -rust-version = "1.86.0" +rust-version = "1.88.0" description = "Functionality related to the esp-idf bootloader" documentation = "https://docs.espressif.com/projects/rust/esp-bootloader-esp-idf/latest/" keywords = ["esp32", "espressif", "no-std"] diff --git a/esp-bootloader-esp-idf/README.md b/esp-bootloader-esp-idf/README.md index 317032d25..bfb343609 100644 --- a/esp-bootloader-esp-idf/README.md +++ b/esp-bootloader-esp-idf/README.md @@ -2,7 +2,7 @@ [![Crates.io](https://img.shields.io/crates/v/esp-bootloader-esp-idf?labelColor=1C2C2E&color=C96329&logo=Rust&style=flat-square)](https://crates.io/crates/esp-bootloader-esp-idf) [![docs.rs](https://img.shields.io/docsrs/esp-bootloader-esp-idf?labelColor=1C2C2E&color=C96329&logo=rust&style=flat-square)](https://docs.espressif.com/projects/rust/esp-bootloader-esp-idf/latest/) -![MSRV](https://img.shields.io/badge/MSRV-1.86.0-blue?labelColor=1C2C2E&style=flat-square) +![MSRV](https://img.shields.io/badge/MSRV-1.88.0-blue?labelColor=1C2C2E&style=flat-square) ![Crates.io](https://img.shields.io/crates/l/esp-bootloader-esp-idf?labelColor=1C2C2E&style=flat-square) [![Matrix](https://img.shields.io/matrix/esp-rs:matrix.org?label=join%20matrix&labelColor=1C2C2E&color=BEC5C9&logo=matrix&style=flat-square)](https://matrix.to/#/#esp-rs:matrix.org) diff --git a/esp-bootloader-esp-idf/src/partitions.rs b/esp-bootloader-esp-idf/src/partitions.rs index 36c185033..14e215d77 100644 --- a/esp-bootloader-esp-idf/src/partitions.rs +++ b/esp-bootloader-esp-idf/src/partitions.rs @@ -199,7 +199,8 @@ impl<'a> PartitionTable<'a> { return Err(Error::Invalid); } - if binary.len() % RAW_ENTRY_LEN != 0 { + let (binary, rem) = binary.as_chunks::(); + if !rem.is_empty() { return Err(Error::Invalid); } @@ -210,14 +211,6 @@ impl<'a> PartitionTable<'a> { }); } - // we checked binary before - let binary = unsafe { - core::slice::from_raw_parts( - binary.as_ptr() as *const [u8; RAW_ENTRY_LEN], - binary.len() / RAW_ENTRY_LEN, - ) - }; - let mut raw_table = Self { binary, entries: binary.len(),