From c0a647237a5d105d02a3f0e52d409030d4a03432 Mon Sep 17 00:00:00 2001 From: Noah <2+noah@noreply.gitea.bluefla.re> Date: Mon, 16 Nov 2026 17:33:23 -0600 Subject: [PATCH] fix(clippy): satisfy -D warnings on the a113d flash engine #52's verify never ran before (offline runner), so clippy -D warnings was never enforced. Fix the Claude-domain lints: - aml_ubi.rs: use u64::div_ceil for the base64 length - zynq_nand.rs: elide needless lifetime; is_multiple_of; RangeInclusive ::contains for the slot bounds and allow clippy::question_mark on the sealed stock_method module (its internal layout is DSH-owned and not restyled here; the module already carries a targeted allow list). No behavioural change. Verified locally: cargo clippy --workspace --exclude alkane-gui --exclude wx-rs --all-targets -- -D warnings is clean, and the non-gui test suite passes. stock_method.rs is byte-for-byte unchanged. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i --- crates/alkane-flash/src/aml_ubi.rs | 2 +- crates/alkane-flash/src/lib.rs | 3 ++- crates/alkane-flash/src/zynq_nand.rs | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/alkane-flash/src/aml_ubi.rs b/crates/alkane-flash/src/aml_ubi.rs index 30044bcb..f78dfade 100644 --- a/crates/alkane-flash/src/aml_ubi.rs +++ b/crates/alkane-flash/src/aml_ubi.rs @@ -219,7 +219,7 @@ fn b64_decode(s: &str) -> Option> { fn b64_encode(data: &[u8]) -> String { const T: &[u8; 64] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - let mut out = String::with_capacity((data.len() + 2) / 3 * 4); + let mut out = String::with_capacity(data.len().div_ceil(3) * 4); for chunk in data.chunks(3) { let b = [ chunk[0], diff --git a/crates/alkane-flash/src/lib.rs b/crates/alkane-flash/src/lib.rs index a05d4760..a5bb293a 100644 --- a/crates/alkane-flash/src/lib.rs +++ b/crates/alkane-flash/src/lib.rs @@ -30,7 +30,8 @@ pub mod zynq_nand; clippy::too_many_arguments, clippy::manual_repeat_n, clippy::manual_is_multiple_of, - clippy::unnecessary_map_or + clippy::unnecessary_map_or, + clippy::question_mark )] mod stock_method; pub mod transport; diff --git a/crates/alkane-flash/src/zynq_nand.rs b/crates/alkane-flash/src/zynq_nand.rs index 10d7a5ed..726c233c 100644 --- a/crates/alkane-flash/src/zynq_nand.rs +++ b/crates/alkane-flash/src/zynq_nand.rs @@ -253,7 +253,7 @@ fn sysfs_offset(sh: &mut dyn Shell, dev: &str) -> Option { /// Find the partition that contains `abs` and holding at least `len` bytes from /// there; return (device, relative offset). -fn locate<'a>(table: &'a [Mtd], abs: u64, len: u64) -> Result<(&'a str, u64), StockError> { +fn locate(table: &[Mtd], abs: u64, len: u64) -> Result<(&str, u64), StockError> { for m in table { if abs >= m.base && abs < m.base + m.size { let rel = abs - m.base; @@ -300,7 +300,7 @@ fn write_abs( "refusing to write {label} at 0x{abs:x}: inside preserved BOOT.bin" ))); } - if abs % ERASE != 0 { + if !abs.is_multiple_of(ERASE) { return Err(StockError::Method(format!( "{label} offset 0x{abs:x} is not erase-block aligned" ))); @@ -482,7 +482,7 @@ fn carve_backup(sh: &mut dyn Shell, table: &[Mtd]) -> Result SLOT_KERNEL || rootfs_len < 64 || rootfs_len > SLOT_ROOTFS { + if !(64..=SLOT_KERNEL).contains(&kernel_len) || !(64..=SLOT_ROOTFS).contains(&rootfs_len) { return Err(StockError::Method(format!( "stock image sizes implausible (kernel {kernel_len}, rootfs {rootfs_len}); \ refusing to back up"