bmc: move memory region size variable to method

Use an accessor method with hard-coded values instead of inlining all
the values.  This avoids the situation where the value is declared but
not used.

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Iad7f2c06d705522520254056b18ffd136fdc1906
diff --git a/bmc/main.cpp b/bmc/main.cpp
index 5f1538d..5282831 100644
--- a/bmc/main.cpp
+++ b/bmc/main.cpp
@@ -60,6 +60,26 @@
     return HandlerPack(name, std::make_unique<FileHandler>(path));
 }
 
+/**
+ * Returns the corresponding memory region size given the compiled
+ * configuration.
+ *
+ * @return the size.
+ */
+std::size_t GetMemoryRegionSize()
+{
+#ifdef NUVOTON_P2A_MBOX
+    constexpr std::size_t memoryRegionSize = 16 * 1024UL;
+#elif defined NUVOTON_P2A_VGA
+    constexpr std::size_t memoryRegionSize = 4 * 1024 * 1024UL;
+#else
+    /* The maximum external buffer size we expect is 64KB. */
+    constexpr std::size_t memoryRegionSize = 64 * 1024UL;
+#endif
+
+    return memoryRegionSize;
+}
+
 } // namespace
 } // namespace ipmi_flash
 
@@ -72,15 +92,6 @@
 {
     using namespace ipmi_flash;
 
-#ifdef NUVOTON_P2A_MBOX
-    constexpr std::size_t memoryRegionSize = 16 * 1024UL;
-#elif defined NUVOTON_P2A_VGA
-    constexpr std::size_t memoryRegionSize = 4 * 1024 * 1024UL;
-#else
-    /* The maximum external buffer size we expect is 64KB. */
-    constexpr std::size_t memoryRegionSize = 64 * 1024UL;
-#endif
-
     std::vector<DataHandlerPack> supportedTransports;
 
     supportedTransports.emplace_back(FirmwareFlags::UpdateFlags::ipmi, nullptr);
@@ -88,7 +99,8 @@
 #ifdef ENABLE_PCI_BRIDGE
     supportedTransports.emplace_back(
         FirmwareFlags::UpdateFlags::p2a,
-        std::make_unique<PciDataHandler>(MAPPED_ADDRESS, memoryRegionSize));
+        std::make_unique<PciDataHandler>(MAPPED_ADDRESS,
+                                         GetMemoryRegionSize()));
 #endif
 
 #ifdef ENABLE_LPC_BRIDGE
@@ -96,12 +108,12 @@
     supportedTransports.emplace_back(
         FirmwareFlags::UpdateFlags::lpc,
         std::make_unique<LpcDataHandler>(LpcMapperAspeed::createAspeedMapper(
-            MAPPED_ADDRESS, memoryRegionSize)));
+            MAPPED_ADDRESS, GetMemoryRegionSize())));
 #elif defined(NUVOTON_LPC)
     supportedTransports.emplace_back(
         FirmwareFlags::UpdateFlags::lpc,
         std::make_unique<LpcDataHandler>(LpcMapperNuvoton::createNuvotonMapper(
-            MAPPED_ADDRESS, memoryRegionSize)));
+            MAPPED_ADDRESS, GetMemoryRegionSize())));
 #else
 #error "You must specify a hardware implementation."
 #endif