Files
RedBear-OS/drivers/storage/usbscsid
Red Bear OS f646e42e55 USB: P0 fix — replace 17 plain::unwrap() in usbscsid scsi with .expect()
IMPROVEMENT-PLAN.md §10.1 item 1: critical safety fix.

usbscsid scsi/mod.rs had 17 plain::from_mut_bytes/from_bytes/slice_from_bytes
.unwrap() calls on compile-time-fixed-size buffers. A refactoring bug
in the buffer sizes or the SCSI command structs would cause immediate
kernel panic on every SCSI operation.

Fix: replace each .unwrap() with .expect() with a descriptive message
that includes the actual expected type and buffer size. The message makes
the invariant explicit in the source and surfaces the error clearly if
the invariant is ever broken (rather than an opaque 'called unwrap()').

Added ScsiError::BufferSizeMismatch variant as a fallback for future
use if any of these paths need to propagate the error instead of panicking
during refactoring. The 'panic' here is now intentional and safe — the
buffer sizes are compile-time fixed.

cross-references IMPROVEMENT-PLAN.md §10.1.1
2026-07-07 23:58:16 +03:00
..