From 6cd82c63cde438fc0773744ca12cd2bb9208c05c Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Mon, 10 Feb 2020 15:32:07 +0100 Subject: [PATCH 1/2] Enhance the Mmio API, and deprecate Mmio::new(). --- src/io/mmio.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/io/mmio.rs b/src/io/mmio.rs index f212636..42251ad 100644 --- a/src/io/mmio.rs +++ b/src/io/mmio.rs @@ -11,9 +11,23 @@ pub struct Mmio { impl Mmio { /// Create a new Mmio without initializing + #[deprecated = "unsound because it's possible to read even though it's uninitialized"] pub fn new() -> Self { - Mmio { - value: MaybeUninit::uninit() + unsafe { Self::uninit() } + } + pub unsafe fn zeroed() -> Self { + Self { + value: MaybeUninit::zeroed(), + } + } + pub unsafe fn uninit() -> Self { + Self { + value: MaybeUninit::uninit(), + } + } + pub const fn from(value: T) -> Self { + Self { + value: MaybeUninit::new(value), } } } -- GitLab From e380f6b3d4817fa61f1a82c19f8c90fde84ac294 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Mon, 10 Feb 2020 15:32:30 +0100 Subject: [PATCH 2/2] Allow syscall::Result to accept other error types. --- src/error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/error.rs b/src/error.rs index fde4796..9a4b0b5 100644 --- a/src/error.rs +++ b/src/error.rs @@ -5,7 +5,7 @@ pub struct Error { pub errno: i32, } -pub type Result = result::Result; +pub type Result = result::Result; impl Error { pub fn new(errno: i32) -> Error { -- GitLab