From ea4e5c3047fe95876fb328bc7415978200618320 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com>
Date: Wed, 2 Aug 2023 07:46:33 +0100
Subject: [PATCH] fix: clippy unsafe issue

---
 frontends/libretro/src/lib.rs | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/frontends/libretro/src/lib.rs b/frontends/libretro/src/lib.rs
index 408b95e4..1b133630 100644
--- a/frontends/libretro/src/lib.rs
+++ b/frontends/libretro/src/lib.rs
@@ -365,14 +365,17 @@ pub extern "C" fn retro_cheat_reset() {
     emulator.reset_cheats();
 }
 
+/// # Safety
+///
+/// This function should not be called only within Lib Retro context.
 #[no_mangle]
-pub extern "C" fn retro_cheat_set(_index: c_uint, enabled: bool, code: *const c_char) {
+pub unsafe extern "C" fn retro_cheat_set(_index: c_uint, enabled: bool, code: *const c_char) {
     debugln!("retro_cheat_set()");
     if !enabled {
         return;
     }
-    let emulator = unsafe { EMULATOR.as_mut().unwrap() };
-    let code_c = unsafe { CStr::from_ptr(code) };
+    let emulator = EMULATOR.as_mut().unwrap();
+    let code_c = CStr::from_ptr(code);
     let code_s = code_c.to_string_lossy().into_owned();
     emulator.add_cheat_code(&code_s).unwrap();
 }
-- 
GitLab