From 833eefcb9b5291e63743522af48d5b509428ec86 Mon Sep 17 00:00:00 2001 From: Pana Date: Tue, 7 Jan 2025 13:33:33 +0800 Subject: [PATCH] change the lint warning fix way --- Cargo.toml | 6 +++--- src/main.rs | 2 -- src/settings.rs | 12 ++++++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a7ffaab..806c533 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,9 +21,6 @@ rustc-hex = { version = "2.1.0", default-features = false } opt-level = 'z' lto = true -[lints.rust] -unexpected_cfgs = { level = "warn", check-cfg = ['cfg(fuzzing)'] } - [features] default = ["pending_review_screen"] pending_review_screen = [] @@ -45,3 +42,6 @@ icon = "icons/cfx_32.gif" [package.metadata.ledger.flex] icon = "icons/cfx_40.gif" + +[lints.rust] +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(target_os, values("stax", "flex", "nanos", "nanox", "nanosplus"))'] } diff --git a/src/main.rs b/src/main.rs index 66a312f..b4acd97 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,8 +17,6 @@ #![no_std] #![no_main] -#![allow(static_mut_refs)] -#![allow(unexpected_cfgs)] mod utils; mod app_ui { diff --git a/src/settings.rs b/src/settings.rs index e6e608e..afa28c8 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -21,13 +21,15 @@ impl Settings { #[inline(never)] #[allow(unused)] pub fn get_mut(&mut self) -> &mut AtomicStorage<[u8; SETTINGS_SIZE]> { - unsafe { DATA.get_mut() } + let data = &raw mut DATA; + unsafe { (*data).get_mut() } } #[inline(never)] #[allow(unused)] pub fn get_ref(&mut self) -> &AtomicStorage<[u8; SETTINGS_SIZE]> { - unsafe { DATA.get_ref() } + let data = &raw const DATA; + unsafe { (*data).get_ref() } } #[allow(unused)] @@ -35,7 +37,8 @@ impl Settings { if index >= SETTINGS_SIZE { return Err(AppSW::InternalError); } - let storage = unsafe { DATA.get_ref() }; + let data = &raw const DATA; + let storage = unsafe { (*data).get_ref() }; let settings = storage.get_ref(); Ok(settings[index]) } @@ -46,7 +49,8 @@ impl Settings { if index >= SETTINGS_SIZE { return Err(AppSW::InternalError); } - let storage = unsafe { DATA.get_mut() }; + let data = &raw mut DATA; + let storage = unsafe { (*data).get_mut() }; let mut updated_data = *storage.get_ref(); updated_data[index] = value; storage.update(&updated_data);