Skip to contentSkip to conversation

rust: hpet: fix fw_cfg handling

PATCH In review Paolo Bonzini 2 participants 2 messages Oct 13, 2025 – Oct 14, 2025 Rust

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rust: hpet: fix fw_cfg handling

HPET ids for fw_cfg are not assigned correctly, because there is a read but no write. This is caught by nightly Rust as an unused-assignments warning, so fix it.

---
 rust/hw/timer/hpet/src/fw_cfg.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
rust/hw/timer/hpet/src/fw_cfg.rs +2 -2
index e569b57b93b..bb4ea8909ad 100644
@@ -40,7 +40,7 @@ pub(crate) fn assign_hpet_id() -> Result<usize, &'static str> {
         assert!(bql::is_locked());
         // SAFETY: all accesses go through these methods, which guarantee
         // that the accesses are protected by the BQL.
-        let mut fw_cfg = unsafe { *addr_of_mut!(hpet_fw_cfg) };
+        let fw_cfg = unsafe { &mut *addr_of_mut!(hpet_fw_cfg) };
 
         if fw_cfg.count == u8::MAX {
             // first instance
@@ -60,7 +60,7 @@ pub(crate) fn update_hpet_cfg(hpet_id: usize, timer_block_id: u32, address: u64)
         assert!(bql::is_locked());
         // SAFETY: all accesses go through these methods, which guarantee
         // that the accesses are protected by the BQL.
-        let mut fw_cfg = unsafe { *addr_of_mut!(hpet_fw_cfg) };
+        let fw_cfg = unsafe { &mut *addr_of_mut!(hpet_fw_cfg) };
 
         fw_cfg.hpet[hpet_id].event_timer_block_id = timer_block_id;
         fw_cfg.hpet[hpet_id].address = address;
Signature · 1 line
2.51.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Paolo Bonzini

Date: Mon, 13 Oct 2025 18:52:51 +0200
From: Paolo Bonzini <[email protected]>
Subject: [PATCH] rust: hpet: fix fw_cfg handling
X-Mailer: git-send-email 2.51.0

Quoted 8 lines

HPET ids for fw_cfg are not assigned correctly, because there is a read but no write. This is caught by nightly Rust as an unused-assignments warning, so fix it.

---
 rust/hw/timer/hpet/src/fw_cfg.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Oops, thanks for this fix.