From 1ea2f68e6a9af135e6cb3274fdf28d4ddc5812d5 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sat, 1 Aug 2026 18:25:55 +0200 Subject: fix pi-lens warnings: unwraps, shell SC2046, dup code (fmtbuf/scripts/hexdump/cat/ahci/pci) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - memory.rs: self-test Layout::from_size_align no longer panics — the test fails cleanly on an invalid layout - fat.rs: v() no longer unwraps the active-volume slot — invariant violation logs + halts instead of panicking mid-disk-io - strbuf: shared FmtBuf replaces the duplicated PanicBuf/FmtBuf (main.rs + sched.rs) - test-disk.sh: SC2046 — conditional --fresh arg no longer relies on word splitting - scripts: boot.sh/boot-image.sh share lib-boot-args.sh (dup args loop) - shell: cat/hexdump stdin pairs unified with Option<&str> marker; hexdump format_row folded into format_partial - ahci: read/write_sectors unified behind dma_sectors - pci: config_read/write share config_addr --- rsnix/src/fat.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'rsnix/src/fat.rs') diff --git a/rsnix/src/fat.rs b/rsnix/src/fat.rs index bad01cd..eda81ed 100644 --- a/rsnix/src/fat.rs +++ b/rsnix/src/fat.rs @@ -167,8 +167,18 @@ fn write_sector(lba: u64, data: &[u8; SECTOR]) -> Result<(), ()> { // --- cluster math ---------------------------------------------------------- +/// Current volume's metadata — only ever reached with a selected volume +/// (the fs layer calls `select_vol` first), so a missing slot is a kernel +/// invariant violation, not a recoverable error. fn v() -> &'static mut Volume { - vols().get_mut(*active_vol()).unwrap() + let i = *active_vol(); + match vols().get_mut(i) { + Some(v) => v, + None => { + crate::serial_println!("fat: internal error — no volume at slot {}", i); + crate::interrupts::halt(); + } + } } fn spc() -> usize { -- cgit v1.2.3