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 --- rsdos/src/main.rs | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) (limited to 'rsdos') diff --git a/rsdos/src/main.rs b/rsdos/src/main.rs index 7ca031c..700dcc7 100644 --- a/rsdos/src/main.rs +++ b/rsdos/src/main.rs @@ -9,20 +9,9 @@ use rsnix::uefi::*; // Panic handler // --------------------------------------------------------------------------- -/// Small fmt::Write over a byte slice (no allocation, bounded). -struct PanicBuf<'a> { - b: &'a mut [u8], - n: usize, -} - -impl core::fmt::Write for PanicBuf<'_> { - fn write_str(&mut self, s: &str) -> core::fmt::Result { - let m = s.len().min(self.b.len() - self.n); - self.b[self.n..self.n + m].copy_from_slice(&s.as_bytes()[..m]); - self.n += m; - Ok(()) - } -} +// --------------------------------------------------------------------------- +// Panic handler +// --------------------------------------------------------------------------- #[panic_handler] fn panic(info: &PanicInfo) -> ! { @@ -35,12 +24,12 @@ fn panic(info: &PanicInfo) -> ! { if rsnix::sched::is_ready() && !rsnix::sched::in_isr() && rsnix::sched::current() >= 2 { let mut buf = [0u8; 192]; let n = { - let mut w = PanicBuf { b: &mut buf, n: 0 }; + let mut w = rsnix::strbuf::FmtBuf::new(&mut buf); let _ = write!(&mut w, "{}", info.message()); if let Some(loc) = info.location() { let _ = write!(&mut w, " at {}:{}", loc.file(), loc.line()); } - w.n + w.len() }; let msg = core::str::from_utf8(&buf[..n]).unwrap_or("task panic"); rsnix::sched::abort_current(msg); -- cgit v1.2.3