evaluate *reg & MCH_HOST_BRIDGE_F_SMBASE_LCK once into lck
and then use lck afterwards.

Suggested-by: "Michael S. Tsirkin" <[email protected]>
Signed-off-by: Igor Mammedov <[email protected]>
---
 hw/pci-host/q35.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index e85e4227b3..8c0404f3c5 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -444,13 +444,13 @@ static void mch_update_smbase_smram(MCHPCIState *mch)
         pd->wmask[MCH_HOST_BRIDGE_F_SMBASE] = MCH_HOST_BRIDGE_F_SMBASE_LCK;
         return;
     }
-    if (*reg & MCH_HOST_BRIDGE_F_SMBASE_LCK) {
+    lck = *reg & MCH_HOST_BRIDGE_F_SMBASE_LCK;
+    if (lck) {
         /* lock register at 0x2 and disable all writes */
         pd->wmask[MCH_HOST_BRIDGE_F_SMBASE] = 0;
         *reg = MCH_HOST_BRIDGE_F_SMBASE_LCK;
     }
 
-    lck = *reg & MCH_HOST_BRIDGE_F_SMBASE_LCK;
     memory_region_transaction_begin();
     memory_region_set_enabled(&mch->smbase_blackhole, lck);
     memory_region_set_enabled(&mch->smbase_window, lck);
-- 
2.47.3


Reply via email to