From 8c583cc978b1e9b0bfcca3e395e300ed7e15818d Mon Sep 17 00:00:00 2001 From: Peter Limkilde Svendsen <peter.limkilde@gmail.com> Date: Wed, 11 Sep 2024 21:14:33 +0000 Subject: [PATCH] Use unsafe blocks in assert.h implementation --- src/header/assert/mod.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/header/assert/mod.rs b/src/header/assert/mod.rs index 64af2af7..6c755d94 100644 --- a/src/header/assert/mod.rs +++ b/src/header/assert/mod.rs @@ -1,5 +1,8 @@ //! assert implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/assert.h.html +// TODO: set this for entire crate when possible +#![deny(unsafe_op_in_unsafe_fn)] + use crate::{c_str::CStr, platform::types::*}; #[no_mangle] @@ -9,9 +12,9 @@ pub unsafe extern "C" fn __assert_fail( line: c_int, cond: *const c_char, ) -> ! { - let func = CStr::from_ptr(func).to_str().unwrap(); - let file = CStr::from_ptr(file).to_str().unwrap(); - let cond = CStr::from_ptr(cond).to_str().unwrap(); + let func = unsafe { CStr::from_ptr(func) }.to_str().unwrap(); + let file = unsafe { CStr::from_ptr(file) }.to_str().unwrap(); + let cond = unsafe { CStr::from_ptr(cond) }.to_str().unwrap(); eprintln!("{}: {}:{}: Assertion `{}` failed.", func, file, line, cond); -- GitLab