Modern Apps git

← Modern-Apps.git

euicc: clippy hygiene in base64, status ranges and JNI glue

Commit
ff7c19d3f523f976384857ba52d04176d55005f3
Author
Vayun Mathur <[email protected]>
When
2026-12-01 21:56 UTC (4 days ago)
Parents
8701e7e
Workspace clippy flagged: a manual div-ceil in base64 encode
capacity (now div_ceil), a needless & on pkid_value's return
into hex, a manual !Range::contains on the HTTP status check
(now !(200..300).contains), two let _ = exception_clear() unit
bindings (now plain statements, exception still cleared at the
same points), a useless usize cast in a test, and an == false
comparison in a progress_decision assertion (now negation).

Left standing deliberately: repeat_n / is_multiple_of
suggestions stable only since Rust 1.87, above the workspace
MSRV of 1.85 declared in clippy.toml.

Verified: cargo clippy -p euicc --all-targets shows only those
two MSRV items, cargo test -p euicc (107 passed), fmt clean.

Diff

euicc/src/main/rust/src/base64.rs
diff --git a/euicc/src/main/rust/src/base64.rs b/euicc/src/main/rust/src/base64.rsindex fde550fc2a..2afa0de76a 100644--- a/euicc/src/main/rust/src/base64.rs+++ b/euicc/src/main/rust/src/base64.rs@@ -8,7 +8,7 @@ const ALPHABET: &[u8; 64] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwx  /// Standard base64 with padding. pub fn encode(data: &[u8]) -> String {-    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 b0 = chunk[0] as u32;         let b1 = *chunk.get(1).unwrap_or(&0) as u32;
euicc/src/main/rust/src/download.rs
diff --git a/euicc/src/main/rust/src/download.rs b/euicc/src/main/rust/src/download.rsindex 39879a2509..95d0f32379 100644--- a/euicc/src/main/rust/src/download.rs+++ b/euicc/src/main/rust/src/download.rs@@ -31,7 +31,7 @@ fn check_ci_key(info: &es10::EuiccInfo1, field: &[u8]) -> Result<(), String> {     if !info.ci_pkid_verification.is_empty() && !ci_key_known(&info.ci_pkid_verification, field) {         return Err(format!(             "server uses CI key {} unknown to this eUICC (eUICC trusts: {})",-            es10::hex(&pkid_value(field)),+            es10::hex(pkid_value(field)),             info.ci_pkid_verification.join(", "),         ));     }
euicc/src/main/rust/src/es10b_tests.rs
diff --git a/euicc/src/main/rust/src/es10b_tests.rs b/euicc/src/main/rust/src/es10b_tests.rsindex 06c79f5f5b..cda4bb0709 100644--- a/euicc/src/main/rust/src/es10b_tests.rs+++ b/euicc/src/main/rust/src/es10b_tests.rs@@ -100,7 +100,7 @@ fn segment_bpp_full_shape_and_errors() {     assert!(segs[0].starts_with(&bpp[..bpp.len() - body.len()])); // BF36 header verbatim     assert!(segs[0].ends_with(&isc));     assert_eq!(segs[1], a0);-    assert_eq!(segs[2], asn1::header(TAG_BPP_SEQ_88, a1v.len() as usize));+    assert_eq!(segs[2], asn1::header(TAG_BPP_SEQ_88, a1v.len()));     assert_eq!(segs[3], tlv(0x88, &[0x01]));     assert_eq!(segs[5], a2);     // Without optional A2 there are 7 segments.
euicc/src/main/rust/src/es9p.rs
diff --git a/euicc/src/main/rust/src/es9p.rs b/euicc/src/main/rust/src/es9p.rsindex b1e0a4a1e1..a3c495e39c 100644--- a/euicc/src/main/rust/src/es9p.rs+++ b/euicc/src/main/rust/src/es9p.rs@@ -168,7 +168,7 @@ fn handle_response(     body: &[u8],     expect_body: bool, ) -> Result<Value, String> {-    if status < 200 || status >= 300 {+    if !(200..300).contains(&status) {         return Err(format!("SM-DP+ HTTP {} at {url}", status));     }     if body.is_empty() {
euicc/src/main/rust/src/jni.rs
diff --git a/euicc/src/main/rust/src/jni.rs b/euicc/src/main/rust/src/jni.rsindex 373cd56108..50ab1a883d 100644--- a/euicc/src/main/rust/src/jni.rs+++ b/euicc/src/main/rust/src/jni.rs@@ -37,7 +37,7 @@ fn transmit_apdu(env: &mut Env, apdu: &[u8]) -> Result<Vec<u8>, String> {         )         .map_err(|e| {             // A pending exception poisons the next JNI call on this thread.-            let _ = env.exception_clear();+            env.exception_clear();             format!("transmitApdu call failed: {e}")         })?;     let object = result.l().map_err(|e| format!("bad return: {e}"))?;
euicc/src/main/rust/src/jni_download.rs
diff --git a/euicc/src/main/rust/src/jni_download.rs b/euicc/src/main/rust/src/jni_download.rsindex 59f1dd374d..91cd03661f 100644--- a/euicc/src/main/rust/src/jni_download.rs+++ b/euicc/src/main/rust/src/jni_download.rs@@ -375,7 +375,7 @@ impl download::ProgressCallback for JniProgress {             )             .and_then(|v| v.z());         // Clear a pending Kotlin exception so later JNI calls stay valid.-        let _ = env.exception_clear();+        env.exception_clear();         progress_decision(result.ok())     } }
euicc/src/main/rust/src/jni_download_tests.rs
diff --git a/euicc/src/main/rust/src/jni_download_tests.rs b/euicc/src/main/rust/src/jni_download_tests.rsindex ff759d6248..f567b22bbd 100644--- a/euicc/src/main/rust/src/jni_download_tests.rs+++ b/euicc/src/main/rust/src/jni_download_tests.rs@@ -106,7 +106,7 @@ fn download_helpers_json_and_options() {     assert!(nickname_request(&failed, Some("x")).is_none());     let no_iccid = es10b::InstallResult { installed_iccid: String::new(), ..ok.clone() };     assert!(nickname_request(&no_iccid, Some("x")).is_none());-    assert!(progress_decision(Some(false)) == false);+    assert!(!progress_decision(Some(false)));     assert!(progress_decision(Some(true)));     assert!(progress_decision(None)); }