From eb1f112c81508457fe6c0c23c40b01b5902c3e62 Mon Sep 17 00:00:00 2001 From: Ian Chamberlain Date: Thu, 30 Jun 2022 21:22:18 -0400 Subject: [PATCH] Handle #[must_use] errors where needed --- ctru-rs/src/lib.rs | 14 ++++++++++---- ctru-rs/src/services/fs.rs | 6 +++--- ctru-rs/src/services/soc.rs | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ctru-rs/src/lib.rs b/ctru-rs/src/lib.rs index 721996b..78e90db 100644 --- a/ctru-rs/src/lib.rs +++ b/ctru-rs/src/lib.rs @@ -22,16 +22,22 @@ pub fn init() { linker_fix_3ds::init(); pthread_3ds::init(); + #[cfg(not(test))] + panic_hook_setup(); + // Initialize the PS service for random data generation unsafe { - ctru_sys::psInit(); + let ps_ret = ctru_sys::psInit(); + if ctru_sys::R_FAILED(ps_ret) { + panic!( + "Failed to initialize random data generation: {:?}", + Error::from(ps_ret) + ) + } // Setup the deconstruction at the program's end libc::atexit(services_deinit); } - - #[cfg(not(test))] - panic_hook_setup(); } #[cfg(not(test))] diff --git a/ctru-rs/src/services/fs.rs b/ctru-rs/src/services/fs.rs index 9f3334a..4ff6355 100644 --- a/ctru-rs/src/services/fs.rs +++ b/ctru-rs/src/services/fs.rs @@ -996,7 +996,7 @@ impl Drop for Fs { impl Drop for Archive { fn drop(&mut self) { unsafe { - ctru_sys::FSUSER_CloseArchive(self.handle); + let _ = ctru_sys::FSUSER_CloseArchive(self.handle); } } } @@ -1004,7 +1004,7 @@ impl Drop for Archive { impl Drop for File { fn drop(&mut self) { unsafe { - ctru_sys::FSFILE_Close(self.handle); + let _ = ctru_sys::FSFILE_Close(self.handle); } } } @@ -1012,7 +1012,7 @@ impl Drop for File { impl Drop for Dir { fn drop(&mut self) { unsafe { - ctru_sys::FSDIR_Close(self.0); + let _ = ctru_sys::FSDIR_Close(self.0); } } } diff --git a/ctru-rs/src/services/soc.rs b/ctru-rs/src/services/soc.rs index 13d0dc9..dad4188 100644 --- a/ctru-rs/src/services/soc.rs +++ b/ctru-rs/src/services/soc.rs @@ -50,7 +50,7 @@ impl Soc { // Surely nothing bad will happens :D || unsafe { // The socket buffer is freed automatically by `socExit` - ctru_sys::socExit(); + let _ = ctru_sys::socExit(); }, )?;