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 --- scripts/lib-boot-args.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 scripts/lib-boot-args.sh (limited to 'scripts/lib-boot-args.sh') diff --git a/scripts/lib-boot-args.sh b/scripts/lib-boot-args.sh new file mode 100644 index 0000000..ec97500 --- /dev/null +++ b/scripts/lib-boot-args.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# +# scripts/lib-boot-args.sh — shared CLI parsing for the QEMU boot scripts. +# Sourced, not executed. The caller sets default values for GUI/DEBUG/ +# MEM/SMP first, then calls `parse_boot_args "$@"`. A caller with extra +# flags defines its own `handle_arg()` to intercept them before the +# shared cases run (unknown args still fail loudly). +set -euo pipefail + +parse_boot_args() { + while [ $# -gt 0 ]; do + case "$1" in + --gui | -g) GUI="-vga std" ;; + --debug | -d) DEBUG="-s -S" ;; + --mem) + shift + MEM="$1" + ;; + --smp) + shift + SMP="$1" + ;; + --help | -h) + head -20 "$0" | grep "^#" | sed 's/^# //' + exit 0 + ;; + *) handle_arg "$1" ;; + esac + shift + done +} + +# Default: no extra flags. A script with more defines its own before +# calling parse_boot_args. +handle_arg() { + echo "unknown: $1" + exit 1 +} -- cgit v1.2.3