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/sched.rs | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'rsnix/src/sched.rs') diff --git a/rsnix/src/sched.rs b/rsnix/src/sched.rs index 4b10503..6ffa745 100644 --- a/rsnix/src/sched.rs +++ b/rsnix/src/sched.rs @@ -372,7 +372,7 @@ pub fn page_fault(cr2: u64, frame_ptr: usize) -> usize { let rip = unsafe { (frame_ptr as *const IntFrame).read().rip }; let mut buf = [0u8; 96]; let n = { - let mut f = FmtBuf { b: &mut buf, n: 0 }; + let mut f = crate::strbuf::FmtBuf::new(&mut buf); let _ = fmt::write( &mut f, core::format_args!( @@ -386,7 +386,7 @@ pub fn page_fault(cr2: u64, frame_ptr: usize) -> usize { rip ), ); - f.n + f.len() }; abort_current(core::str::from_utf8(&buf[..n]).unwrap_or("task fault")) } @@ -528,17 +528,3 @@ fn idle_main() { } } } - -struct FmtBuf<'a> { - b: &'a mut [u8], - n: usize, -} - -impl fmt::Write for FmtBuf<'_> { - fn write_str(&mut self, s: &str) -> 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(()) - } -} -- cgit v1.2.3