move sensors into ipmi::sensor namespace

The object was left in the global namespace, but the type was in the
ipmi::sensor namespace.  Move the object into the namespace.

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I88e46da4abda220d3b6fcc2ea64b8ef0decb0dc3
diff --git a/scripts/writesensor.mako.cpp b/scripts/writesensor.mako.cpp
index 192b858..c740f6f 100644
--- a/scripts/writesensor.mako.cpp
+++ b/scripts/writesensor.mako.cpp
@@ -27,7 +27,9 @@
 #include "sensordatahandler.hpp"
 
 #include <ipmid/types.hpp>
-using namespace ipmi::sensor;
+
+namespace ipmi {
+namespace sensor {
 
 extern const IdInfoMap sensors = {
 % for key in sensorDict.iterkeys():
@@ -145,3 +147,5 @@
 % endfor
 };
 
+} // namespace sensor
+} // namespace ipmi
diff --git a/sensorhandler.cpp b/sensorhandler.cpp
index 1901464..28b04c1 100644
--- a/sensorhandler.cpp
+++ b/sensorhandler.cpp
@@ -26,7 +26,15 @@
 
 extern int updateSensorRecordFromSSRAESC(const void*);
 extern sd_bus* bus;
-extern const ipmi::sensor::IdInfoMap sensors;
+
+namespace ipmi
+{
+namespace sensor
+{
+extern const IdInfoMap sensors;
+} // namespace sensor
+} // namespace ipmi
+
 extern const FruMap frus;
 
 using namespace phosphor::logging;
@@ -103,8 +111,8 @@
 {
     int rc;
 
-    const auto& sensor_it = sensors.find(num);
-    if (sensor_it == sensors.end())
+    const auto& sensor_it = ipmi::sensor::sensors.find(num);
+    if (sensor_it == ipmi::sensor::sensors.end())
     {
         // The sensor map does not contain the sensor requested
         return -EINVAL;
@@ -380,8 +388,8 @@
     cmdData.eventData3 = eventData3;
 
     // Check if the Sensor Number is present
-    const auto iter = sensors.find(sensorNumber);
-    if (iter == sensors.end())
+    const auto iter = ipmi::sensor::sensors.find(sensorNumber);
+    if (iter == ipmi::sensor::sensors.end())
     {
         updateSensorRecordFromSSRAESC(&sensorNumber);
         return ipmi::responseSuccess();
@@ -424,8 +432,8 @@
     ipmi::sensor::GetSensorResponse getResponse{};
     static constexpr auto scanningEnabledBit = 6;
 
-    const auto iter = sensors.find(reqptr->sennum);
-    if (iter == sensors.end())
+    const auto iter = ipmi::sensor::sensors.find(reqptr->sennum);
+    if (iter == ipmi::sensor::sensors.end())
     {
         return IPMI_CC_SENSOR_INVALID;
     }
@@ -467,7 +475,7 @@
 
     sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()};
 
-    const auto iter = sensors.find(sensorNum);
+    const auto iter = ipmi::sensor::sensors.find(sensorNum);
     const auto info = iter->second;
 
     auto service = ipmi::getService(bus, info.sensorInterface, info.sensorPath);
@@ -541,8 +549,8 @@
     auto sensorNum = *(reinterpret_cast<const uint8_t*>(request));
     *data_len = 0;
 
-    const auto iter = sensors.find(sensorNum);
-    if (iter == sensors.end())
+    const auto iter = ipmi::sensor::sensors.find(sensorNum);
+    if (iter == ipmi::sensor::sensors.end())
     {
         return IPMI_CC_SENSOR_INVALID;
     }
@@ -608,12 +616,13 @@
     {
         // Get SDR count. This returns the total number of SDRs in the device.
         const auto& entityRecords = ipmi::sensor::getIpmiEntityRecords();
-        sdrCount = sensors.size() + frus.size() + entityRecords.size();
+        sdrCount =
+            ipmi::sensor::sensors.size() + frus.size() + entityRecords.size();
     }
     else if (count.value_or(0) == getSensorCount)
     {
         // Get Sensor count. This returns the number of sensors
-        sdrCount = sensors.size();
+        sdrCount = ipmi::sensor::sensors.size();
     }
     else
     {
@@ -888,7 +897,7 @@
 
     // Note: we use an iterator so we can provide the next ID at the end of
     // the call.
-    auto sensor = sensors.begin();
+    auto sensor = ipmi::sensor::sensors.begin();
     auto recordID = get_sdr::request::get_record_id(req);
 
     // At the beginning of a scan, the host side will send us id=0.
@@ -910,8 +919,8 @@
         }
         else
         {
-            sensor = sensors.find(recordID);
-            if (sensor == sensors.end())
+            sensor = ipmi::sensor::sensors.find(recordID);
+            if (sensor == ipmi::sensor::sensors.end())
             {
                 return IPMI_CC_SENSOR_INVALID;
             }
@@ -945,7 +954,7 @@
     ret =
         populate_record_from_dbus(&(record.body), &(sensor->second), data_len);
 
-    if (++sensor == sensors.end())
+    if (++sensor == ipmi::sensor::sensors.end())
     {
         // we have reached till end of sensor, so assign the next record id
         // to 256(Max Sensor ID = 255) + FRU ID(may start with 0).
diff --git a/storagehandler.cpp b/storagehandler.cpp
index 0932f72..96d3d54 100644
--- a/storagehandler.cpp
+++ b/storagehandler.cpp
@@ -27,7 +27,14 @@
 void register_netfn_storage_functions() __attribute__((constructor));
 
 unsigned int g_sel_time = 0xFFFFFFFF;
-extern const ipmi::sensor::IdInfoMap sensors;
+namespace ipmi
+{
+namespace sensor
+{
+extern const IdInfoMap sensors;
+} // namespace sensor
+} // namespace ipmi
+
 extern const FruMap frus;
 constexpr uint8_t eventDataSize = 3;
 namespace
@@ -725,7 +732,7 @@
     constexpr uint32_t deletionTimestamp = 0x0;
     constexpr uint8_t operationSupport = 0;
 
-    uint16_t records = frus.size() + sensors.size();
+    uint16_t records = frus.size() + ipmi::sensor::sensors.size();
 
     return ipmi::responseSuccess(sdrVersion, records, freeSpace,
                                  additionTimestamp, deletionTimestamp,