refactor(core): move `bt_le_addr_t` zeroing into a helper method
What changed, and why it matters
This is a minor code cleanup in the Trezor firmware's Bluetooth module. A developer moved a small chunk of repeated code—creating an empty Bluetooth address—into a reusable helper method. The behavior of the program is unchanged; it is purely a refactoring for readability and maintainability.
No security action needed. Treat as routine refactoring.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors the initialization of bt_le_addr_t in core/embed/rust/src/trezorhal/ble/mod.rs. Previously, state() constructed a zeroed bt_le_addr_t inline. The change introduces an associated zero() method on bt_le_addr_t and replaces the inline construction with a call to that method. There is no functional change, no change to unsafe boundaries, and no security-relevant behavior modification.
Changed components
core/embed/rust/src/trezorhal/ble/mod.rsInspect captured patch +10 / −6
diff --git a/core/embed/rust/src/trezorhal/ble/mod.rs b/core/embed/rust/src/trezorhal/ble/mod.rs
index b2035cdfc..acea77b73 100644
--- a/core/embed/rust/src/trezorhal/ble/mod.rs
+++ b/core/embed/rust/src/trezorhal/ble/mod.rs
@@ -46,6 +46,15 @@ pub fn ble_parse_event(event: ffi::ble_event_t) -> BLEEvent {
}
}
+impl bt_le_addr_t {
+ fn zero() -> bt_le_addr_t {
+ bt_le_addr_t {
+ type_: 0,
+ addr: [0; 6],
+ }
+ }
+}
+
fn state() -> ffi::ble_state_t {
let mut state = ffi::ble_state_t {
connected: false,
@@ -54,12 +63,7 @@ fn state() -> ffi::ble_state_t {
pairing: false,
pairing_requested: false,
state_known: false,
- connected_addr: {
- bt_le_addr_t {
- type_: 0,
- addr: [0; 6],
- }
- },
+ connected_addr: bt_le_addr_t::zero(),
};
unsafe { ffi::ble_get_state(&mut state as _) };
state
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.