Clean up codes
This commit cleans up codes to follow coding style and conventions
of OpenBMC.
Change-Id: Ib2a9b2589b839db6eb0f31b392b3fa54aef3a8c6
Signed-off-by: Jae Hyun Yoo <jae.hyun.yoo@linux.intel.com>
diff --git a/src/ADCSensorMain.cpp b/src/ADCSensorMain.cpp
index 47edd5c..4fff81a 100644
--- a/src/ADCSensorMain.cpp
+++ b/src/ADCSensorMain.cpp
@@ -30,9 +30,9 @@
namespace fs = std::experimental::filesystem;
namespace variant_ns = sdbusplus::message::variant_ns;
-static constexpr std::array<const char*, 1> SENSOR_TYPES = {
+static constexpr std::array<const char*, 1> sensorTypes = {
"xyz.openbmc_project.Configuration.ADC"};
-static std::regex INPUT_REGEX(R"(in(\d+)_input)");
+static std::regex inputRegex(R"(in(\d+)_input)");
void createSensors(
boost::asio::io_service& io, sdbusplus::asio::object_server& objectServer,
@@ -46,7 +46,7 @@
// use new data the first time, then refresh
ManagedObjectType sensorConfigurations;
bool useCache = false;
- for (const char* type : SENSOR_TYPES)
+ for (const char* type : sensorTypes)
{
if (!getSensorConfiguration(type, dbusConnection, sensorConfigurations,
useCache))
@@ -57,7 +57,7 @@
useCache = true;
}
std::vector<fs::path> paths;
- if (!find_files(fs::path("/sys/class/hwmon"), R"(in\d+_input)", paths))
+ if (!findFiles(fs::path("/sys/class/hwmon"), R"(in\d+_input)", paths))
{
std::cerr << "No temperature sensors in system\n";
return;
@@ -70,21 +70,23 @@
std::smatch match;
std::string pathStr = path.string();
- std::regex_search(pathStr, match, INPUT_REGEX);
+ std::regex_search(pathStr, match, inputRegex);
std::string indexStr = *(match.begin() + 1);
auto directory = path.parent_path();
// convert to 0 based
size_t index = std::stoul(indexStr) - 1;
- auto oem_name_path =
+ auto oemNamePath =
directory.string() + R"(/of_node/oemname)" + std::to_string(index);
if (DEBUG)
- std::cout << "Checking path " << oem_name_path << "\n";
- std::ifstream nameFile(oem_name_path);
+ {
+ std::cout << "Checking path " << oemNamePath << "\n";
+ }
+ std::ifstream nameFile(oemNamePath);
if (!nameFile.good())
{
- std::cerr << "Failure reading " << oem_name_path << "\n";
+ std::cerr << "Failure reading " << oemNamePath << "\n";
continue;
}
std::string oemName;
@@ -118,7 +120,7 @@
const std::pair<std::string, boost::container::flat_map<
std::string, BasicVariantType>>*
baseConfiguration = nullptr;
- for (const char* type : SENSOR_TYPES)
+ for (const char* type : sensorTypes)
{
auto sensorBase = sensorData->find(type);
if (sensorBase != sensorData->end())
@@ -168,7 +170,7 @@
}
}
std::vector<thresholds::Threshold> sensorThresholds;
- if (!ParseThresholdsFromConfig(*sensorData, sensorThresholds))
+ if (!parseThresholdsFromConfig(*sensorData, sensorThresholds))
{
std::cerr << "error populating thresholds for " << sensorName
<< "\n";
@@ -230,12 +232,12 @@
});
};
- for (const char* type : SENSOR_TYPES)
+ for (const char* type : sensorTypes)
{
auto match = std::make_unique<sdbusplus::bus::match::match>(
static_cast<sdbusplus::bus::bus&>(*systemBus),
"type='signal',member='PropertiesChanged',path_namespace='" +
- std::string(INVENTORY_PATH) + "',arg0namespace='" + type + "'",
+ std::string(inventoryPath) + "',arg0namespace='" + type + "'",
eventHandler);
matches.emplace_back(std::move(match));
}