From 59d5a43dc3632577a62b7e66f038f47defb27061 Mon Sep 17 00:00:00 2001 From: Anton <anton.frappe@outlook.com> Date: Wed, 3 Mar 2021 18:03:28 +0100 Subject: [PATCH] bare4_2 --- examples/rtic_bare4.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/rtic_bare4.rs b/examples/rtic_bare4.rs index 6b4284b..9f7f176 100644 --- a/examples/rtic_bare4.rs +++ b/examples/rtic_bare4.rs @@ -35,8 +35,8 @@ use address::*; #[inline(always)] fn read_u32(addr: u32) -> u32 { - unsafe { core::ptr::read_volatile(addr as *const _) } - // core::ptr::read_volatile(addr as *const _) + //unsafe { core::ptr::read_volatile(addr as *const _) } + core::ptr::read_volatile(addr as *const _); } #[inline(always)] @@ -100,12 +100,13 @@ const APP: () = { // // What was the error message and explain why. // -// ** your answer here ** +// This operation is unsafe and requires an unsafe function or block. +// The function read_volatile is declared to be unsafe. // // Digging a bit deeper, why do you think `read_volatile` is declared `unsafe`. // (https://doc.rust-lang.org/core/ptr/fn.read_volatile.html, for some food for thought ) // -// ** your answer here ** +// It is unsafe because it can't guarantee the value is the expected value. // // Commit your answers (bare4_2) // -- GitLab