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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i
This commit is contained in:
@@ -219,7 +219,7 @@ fn b64_decode(s: &str) -> Option<Vec<u8>> {
|
||||
|
||||
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],
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -253,7 +253,7 @@ fn sysfs_offset(sh: &mut dyn Shell, dev: &str) -> Option<u64> {
|
||||
|
||||
/// 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<BackupManifest, Sto
|
||||
let dtb_len = read_header_u32_be(sh, table, OFF_DTB, 4)? as u64;
|
||||
let rootfs_len = 64 + read_header_u32_be(sh, table, OFF_ROOTFS, 12)? as u64;
|
||||
// Sanity: headers must look like a uImage/fdt, sizes within slots.
|
||||
if kernel_len < 64 || kernel_len > 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"
|
||||
|
||||
Reference in New Issue
Block a user