From 8b86dd9fb5bc9ad0fd90f467a5d85e783b0948e9 Mon Sep 17 00:00:00 2001 From: Demi Marie Obenour Date: Wed, 11 Mar 2026 20:47:52 -0400 Subject: [PATCH] pci: Reduce use of magic number 4 No functional change intended. Signed-off-by: Demi Marie Obenour --- pci/src/configuration.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pci/src/configuration.rs b/pci/src/configuration.rs index 2a905e19b..8973c3883 100644 --- a/pci/src/configuration.rs +++ b/pci/src/configuration.rs @@ -987,7 +987,7 @@ impl PciConfiguration { return None; } - let bar_idx = reg_idx - 4; + let bar_idx = reg_idx - BAR0_REG; // Handle special case where the address being written is // different from the address initially provided. This is a // BAR reprogramming case which needs to be properly caught. @@ -1025,7 +1025,7 @@ impl PciConfiguration { len, region_type, }); - } else if (reg_idx > BAR0_REG) + } else if (bar_idx > 0) && ((self.registers[reg_idx - 1] & self.writable_bits[reg_idx - 1]) != (self.bars[bar_idx - 1].addr & self.writable_bits[reg_idx - 1]) || (value & mask) != (self.bars[bar_idx].addr & mask))