From 25072c5792b2a2f5551414c922a276ee193d8a99 Mon Sep 17 00:00:00 2001
From: anttib-5 <anttib-5@student.ltu.se>
Date: Fri, 8 Mar 2019 14:00:11 +0100
Subject: [PATCH] bare4_2

---
 examples/bare4.rs | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/examples/bare4.rs b/examples/bare4.rs
index 37dd6fc..eee44e0 100644
--- a/examples/bare4.rs
+++ b/examples/bare4.rs
@@ -36,8 +36,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)]
@@ -107,12 +107,14 @@ fn main() -> ! {
 //
 //    What was the error message and explain why.
 //
-//    ** your answer here **
+//    call to unsafe function is unsafe and requires unsafe function or block.
+//    This happens because the variable is volatile. 
 //
 //    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 **
+//    The volatile value might not be guaranteed to be the same between reads. So it is declared unsafe since it might not
+//    be the same as intended.
 //
 //    Commit your answers (bare4_2)
 //
-- 
GitLab