From 7c5603b2fed27be86982665a8b10dcd8f1c5a483 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sat, 1 Aug 2026 03:47:51 +0200 Subject: Bump workspace to edition 2024 - edition = "2024" in the workspace manifest and rsdosedit - extern blocks must be unsafe: interrupts.rs ISR stubs -> unsafe extern "C" - #[no_mangle] -> #[unsafe(no_mangle)] (efi_main, isr_dispatch) - One missed static-mut read in free_list_insert wrapped in an explicit unsafe block (edition 2024 removed the implicit unsafe context inside unsafe fns) - rustfmt reflows for 2024: nested if-lets become let-chains, imports re-sorted, rsdosedit help-screen box rows wrapped No codegen-affecting changes. Validated: cargo check/clippy/fmt clean (host + uefi target), make test-disk PASS, editor round-trip PASS. --- rsnix/src/fat.rs | 6 +----- rsnix/src/fs.rs | 10 +++++----- rsnix/src/interrupts.rs | 4 ++-- rsnix/src/memory.rs | 2 +- rsnix/src/paging.rs | 2 +- rsnix/src/pci.rs | 6 +----- rsnix/src/power.rs | 2 +- rsnix/src/vt.rs | 8 +------- 8 files changed, 13 insertions(+), 27 deletions(-) (limited to 'rsnix') diff --git a/rsnix/src/fat.rs b/rsnix/src/fat.rs index 13d19df..335a160 100644 --- a/rsnix/src/fat.rs +++ b/rsnix/src/fat.rs @@ -153,11 +153,7 @@ fn is_eoc(c: u32) -> bool { fn next_cluster(c: u32) -> Result { let n = read_fat_entry(c); - if is_eoc(n) { - Err(()) - } else { - Ok(n) - } + if is_eoc(n) { Err(()) } else { Ok(n) } } /// Allocate a fresh cluster: mark it EOC in the FAT and zero its data. diff --git a/rsnix/src/fs.rs b/rsnix/src/fs.rs index 2a1a3e3..a71e51a 100644 --- a/rsnix/src/fs.rs +++ b/rsnix/src/fs.rs @@ -92,10 +92,10 @@ fn add(name: &str, parent: Option, kind: FileType, data: NodeData) -> usi data, removed: false, }); - if let Some(p) = parent { - if let NodeData::Dir(v) = &mut nodes()[p].data { - v.push(h); - } + if let Some(p) = parent + && let NodeData::Dir(v) = &mut nodes()[p].data + { + v.push(h); } h } @@ -224,7 +224,7 @@ pub fn resolve(path: &str) -> Option { return None; } let mut cur = 0usize; // root - // (vol, cluster, parent, name) of directories descended into under /disk. + // (vol, cluster, parent, name) of directories descended into under /disk. let mut dstack: Vec<(usize, u32, u32, String)> = Vec::new(); for seg in path.split('/') { match seg { diff --git a/rsnix/src/interrupts.rs b/rsnix/src/interrupts.rs index cbd234e..2b82a3d 100644 --- a/rsnix/src/interrupts.rs +++ b/rsnix/src/interrupts.rs @@ -256,7 +256,7 @@ struct IntFrame { } /// Called from the asm common handler — dispatches to the right Rust handler. -#[no_mangle] +#[unsafe(no_mangle)] unsafe extern "C" fn isr_dispatch(frame: &IntFrame) { unsafe { match frame.vector { @@ -344,7 +344,7 @@ pub fn init() { // --------------------------------------------------------------------------- // Extern symbols from global_asm! // --------------------------------------------------------------------------- -extern "C" { +unsafe extern "C" { fn isr_stub_32(); fn isr_stub_33(); fn isr_stub_spurious(); diff --git a/rsnix/src/memory.rs b/rsnix/src/memory.rs index 54ff7be..7c3eda0 100644 --- a/rsnix/src/memory.rs +++ b/rsnix/src/memory.rs @@ -89,7 +89,7 @@ fn align_up(x: usize, a: usize) -> usize { unsafe fn free_list_insert(block: *mut Header) { let addr = block as usize; let mut prev: *mut Header = ptr::null_mut(); - let mut cur = FREE_LIST; + let mut cur = unsafe { FREE_LIST }; while !cur.is_null() && (cur as usize) < addr { prev = cur; cur = unsafe { (*(*cur).links()).next }; diff --git a/rsnix/src/paging.rs b/rsnix/src/paging.rs index 766bde3..d786dee 100644 --- a/rsnix/src/paging.rs +++ b/rsnix/src/paging.rs @@ -12,7 +12,7 @@ // refcounting) — fine for a kernel that owns all memory. // --------------------------------------------------------------------------- -use crate::memory::{alloc_pages, free_pages, PAGE_SIZE}; +use crate::memory::{PAGE_SIZE, alloc_pages, free_pages}; pub const PAGE_PRESENT: u64 = 1 << 0; pub const PAGE_WRITABLE: u64 = 1 << 1; diff --git a/rsnix/src/pci.rs b/rsnix/src/pci.rs index efdbc01..21d7536 100644 --- a/rsnix/src/pci.rs +++ b/rsnix/src/pci.rs @@ -83,11 +83,7 @@ pub fn bar64(bus: u8, device: u8, func: u8, bar_index: u8) -> Option { 0 }; let base = ((hi as u64) << 32) | (lo as u64 & 0xFFFF_FFF0); - if base == 0 { - None - } else { - Some(base) - } + if base == 0 { None } else { Some(base) } } /// Enumerate every device/function present on all buses. diff --git a/rsnix/src/power.rs b/rsnix/src/power.rs index cb5d296..3ca0f25 100644 --- a/rsnix/src/power.rs +++ b/rsnix/src/power.rs @@ -9,7 +9,7 @@ // QEMU this makes the VM exit, on real hardware the power drops. // --------------------------------------------------------------------------- -use crate::uefi::{RuntimeServices, EFI_SUCCESS, RESET_SHUTDOWN}; +use crate::uefi::{EFI_SUCCESS, RESET_SHUTDOWN, RuntimeServices}; static mut RUNTIME_SERVICES: *mut RuntimeServices = core::ptr::null_mut(); diff --git a/rsnix/src/vt.rs b/rsnix/src/vt.rs index 2cfb0f3..709ea71 100644 --- a/rsnix/src/vt.rs +++ b/rsnix/src/vt.rs @@ -224,13 +224,7 @@ fn put_byte(b: u8) { } fn param(i: usize, default: usize) -> usize { - unsafe { - if i < NPARAMS { - PARAMS[i] - } else { - default - } - } + unsafe { if i < NPARAMS { PARAMS[i] } else { default } } } /// Place a printable glyph at the cursor and advance (wrapping/scrolling). -- cgit v1.2.3