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/memory.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'rsnix/src/memory.rs') diff --git a/rsnix/src/memory.rs b/rsnix/src/memory.rs index 7c3eda0..e03af8b 100644 --- a/rsnix/src/memory.rs +++ b/rsnix/src/memory.rs @@ -458,7 +458,9 @@ pub fn self_test() -> bool { seed = seed.wrapping_mul(6364136223846793005).wrapping_add(1); let align = 16usize << (seed as usize % 8); seed = seed.wrapping_mul(6364136223846793005).wrapping_add(1); - let layout = Layout::from_size_align(size, align).unwrap(); + let Ok(layout) = Layout::from_size_align(size, align) else { + return false; // impossible: size <= 2048, align <= 2048 + }; let p = ALLOCATOR.alloc(layout); if p.is_null() { break; // heap exhausted — stop @@ -493,7 +495,9 @@ pub fn self_test() -> bool { seed = seed.wrapping_mul(6364136223846793005).wrapping_add(1); let align = 16usize << (seed as usize % 8); seed = seed.wrapping_mul(6364136223846793005).wrapping_add(1); - let layout = Layout::from_size_align(size, align).unwrap(); + let Ok(layout) = Layout::from_size_align(size, align) else { + return false; // impossible: size <= 2048, align <= 2048 + }; let p = ALLOCATOR.alloc(layout); if p.is_null() { return false; // failed to reuse freed space @@ -510,7 +514,9 @@ pub fn self_test() -> bool { if *ptr == 0 { continue; } - let layout = Layout::from_size_align(*size, *align).unwrap(); + let Ok(layout) = Layout::from_size_align(*size, *align) else { + return false; // impossible: sizes/aligns came from the loop above + }; ALLOCATOR.dealloc(*ptr as *mut u8, layout); } let stats = heap_stats(); -- cgit v1.2.3