diff --git a/ctru-rs/src/applets/swkbd.rs b/ctru-rs/src/applets/swkbd.rs index 93f69ec..cf9aa5d 100644 --- a/ctru-rs/src/applets/swkbd.rs +++ b/ctru-rs/src/applets/swkbd.rs @@ -847,7 +847,6 @@ impl SoftwareKeyboard { // A reimplementation of `swkbdMessageCallback` from `libctru/source/applets/swkbd.c`. // This function sets up and then calls the callback set by `swkbdSetFilterCallback` - #[deny(unsafe_op_in_unsafe_fn)] unsafe extern "C" fn swkbd_message_callback( user: *mut libc::c_void, sender: NS_APPID, diff --git a/ctru-rs/src/console.rs b/ctru-rs/src/console.rs index bee9dc5..02702cc 100644 --- a/ctru-rs/src/console.rs +++ b/ctru-rs/src/console.rs @@ -6,7 +6,6 @@ //! Have a look at [`Soc::redirect_to_3dslink()`](crate::services::soc::Soc::redirect_to_3dslink) for a better alternative when debugging applications. use std::cell::{RefMut, UnsafeCell}; -use std::default::Default; use ctru_sys::{consoleClear, consoleInit, consoleSelect, consoleSetWindow, PrintConsole}; diff --git a/ctru-rs/src/lib.rs b/ctru-rs/src/lib.rs index 2874839..eafd530 100644 --- a/ctru-rs/src/lib.rs +++ b/ctru-rs/src/lib.rs @@ -18,6 +18,7 @@ #![crate_type = "rlib"] #![crate_name = "ctru"] #![warn(missing_docs)] +#![deny(unsafe_op_in_unsafe_fn)] #![feature(custom_test_frameworks)] #![feature(try_trait_v2)] #![feature(allocator_api)] diff --git a/ctru-rs/src/linear.rs b/ctru-rs/src/linear.rs index 927d556..548f0ad 100644 --- a/ctru-rs/src/linear.rs +++ b/ctru-rs/src/linear.rs @@ -42,6 +42,8 @@ unsafe impl Allocator for LinearAllocator { #[doc(alias = "linearFree")] unsafe fn deallocate(&self, ptr: NonNull, _layout: Layout) { - ctru_sys::linearFree(ptr.as_ptr().cast()); + unsafe { + ctru_sys::linearFree(ptr.as_ptr().cast()); + } } } diff --git a/ctru-rs/src/services/ir_user.rs b/ctru-rs/src/services/ir_user.rs index 672fe20..0a03f4d 100644 --- a/ctru-rs/src/services/ir_user.rs +++ b/ctru-rs/src/services/ir_user.rs @@ -347,9 +347,11 @@ impl IrUser { let mut shared_mem_guard = IR_USER_STATE.lock().unwrap(); let shared_mem = shared_mem_guard.as_mut().unwrap(); - shared_mem - .service_handle - .send_service_request(request, expected_response_len) + unsafe { + shared_mem + .service_handle + .send_service_request(request, expected_response_len) + } } } diff --git a/ctru-rs/src/services/ndsp/mod.rs b/ctru-rs/src/services/ndsp/mod.rs index 3e96184..beb3772 100644 --- a/ctru-rs/src/services/ndsp/mod.rs +++ b/ctru-rs/src/services/ndsp/mod.rs @@ -21,7 +21,6 @@ use crate::error::ResultCode; use crate::services::ServiceReference; use std::cell::{RefCell, RefMut}; -use std::default::Default; use std::error; use std::fmt; use std::sync::Mutex; diff --git a/ctru-rs/src/services/svc.rs b/ctru-rs/src/services/svc.rs index 11530f0..9b036a3 100644 --- a/ctru-rs/src/services/svc.rs +++ b/ctru-rs/src/services/svc.rs @@ -50,19 +50,28 @@ impl HandleExt for Handle { ) -> crate::Result> { // Copy over the request let cmd_buffer_ptr = unsafe { ctru_sys::getThreadCommandBuffer() }; - std::ptr::copy_nonoverlapping(request.as_ptr(), cmd_buffer_ptr, request.len()); - // Send the request - ResultCode(ctru_sys::svcSendSyncRequest(self))?; + unsafe { + std::ptr::copy_nonoverlapping(request.as_ptr(), cmd_buffer_ptr, request.len()); + + // Send the request + ResultCode(ctru_sys::svcSendSyncRequest(self))?; - // Handle the result returned by the service - let result = unsafe { std::ptr::read(cmd_buffer_ptr.add(1)) }; - ResultCode(result as ctru_sys::Result)?; + // Handle the result returned by the service + let result = std::ptr::read(cmd_buffer_ptr.add(1)); + ResultCode(result as ctru_sys::Result)?; + } // Copy back the response request.clear(); request.resize(expected_response_len, 0); - std::ptr::copy_nonoverlapping(cmd_buffer_ptr, request.as_mut_ptr(), expected_response_len); + unsafe { + std::ptr::copy_nonoverlapping( + cmd_buffer_ptr, + request.as_mut_ptr(), + expected_response_len, + ); + } Ok(request) }