hw/pci-host/q35.c: Avoid early return in mch_write_config()
In mch_write_config() we return early if has_smm_ranges is false. This is slightly bug-prone because it leaves the door open to somebody later adding non-SMM-specific code at the bottom of the function. This case isn't as bad as the one in realize, because the function is a lot shorter. But putting the handling of the three SMM specific ranges into an if() rather than having an early return seems better. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-ID: <20260708121011.1653365-4-peter.maydell@linaro.org>
Peter Maydell committed
Jul 8, 2026 at 13:10 UTC
e07c67584c69da44a4d52df747a6fff1f411500d
1 file changed
+12
-14
hw/pci-host/q35.c
+12
-14
@@ -485,22 +485,20 @@ static void mch_write_config(PCIDevice *d,
485
mch_update_pciexbar(mch);
486
}
487
488
- if (!mch->has_smm_ranges) {
489
- return;
490
- }
491
-
492
- if (ranges_overlap(address, len, MCH_HOST_BRIDGE_SMRAM,
493
- MCH_HOST_BRIDGE_SMRAM_SIZE)) {
494
- mch_update_smram(mch);
495
- }
488
+ if (mch->has_smm_ranges) {
489
+ if (ranges_overlap(address, len, MCH_HOST_BRIDGE_SMRAM,
490
+ MCH_HOST_BRIDGE_SMRAM_SIZE)) {
491
+ mch_update_smram(mch);
492
+ }
493
497
- if (ranges_overlap(address, len, MCH_HOST_BRIDGE_EXT_TSEG_MBYTES,
498
- MCH_HOST_BRIDGE_EXT_TSEG_MBYTES_SIZE)) {
499
- mch_update_ext_tseg_mbytes(mch);
500
- }
494
+ if (ranges_overlap(address, len, MCH_HOST_BRIDGE_EXT_TSEG_MBYTES,
495
+ MCH_HOST_BRIDGE_EXT_TSEG_MBYTES_SIZE)) {
496
+ mch_update_ext_tseg_mbytes(mch);
497
+ }
498
502
- if (ranges_overlap(address, len, MCH_HOST_BRIDGE_F_SMBASE, 1)) {
503
- mch_update_smbase_smram(mch);
499
+ if (ranges_overlap(address, len, MCH_HOST_BRIDGE_F_SMBASE, 1)) {
500
+ mch_update_smbase_smram(mch);
501
+ }
502
}
503
}
504