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/sensors/src/FanMain.cpp b/sensors/src/FanMain.cpp
index b562e05..4fa9ff2 100644
--- a/sensors/src/FanMain.cpp
+++ b/sensors/src/FanMain.cpp
@@ -32,9 +32,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.AspeedFan"};
-static std::regex INPUT_REGEX(R"(fan(\d+)_input)");
+static std::regex inputRegex(R"(fan(\d+)_input)");
void createSensors(
boost::asio::io_service& io, sdbusplus::asio::object_server& objectServer,
@@ -50,7 +50,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))
@@ -61,7 +61,7 @@
useCache = true;
}
std::vector<fs::path> paths;
- if (!find_files(fs::path("/sys/class/hwmon"), R"(fan\d+_input)", paths))
+ if (!findFiles(fs::path("/sys/class/hwmon"), R"(fan\d+_input)", paths))
{
std::cerr << "No temperature sensors in system\n";
return;
@@ -74,7 +74,7 @@
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();
@@ -91,7 +91,7 @@
sensor : sensorConfigurations)
{
// find the base of the configuration to see if indexes match
- for (const char* type : SENSOR_TYPES)
+ for (const char* type : sensorTypes)
{
auto sensorBaseFind = sensor.second.find(type);
if (sensorBaseFind != sensor.second.end())
@@ -124,7 +124,9 @@
std::to_string(pwmIndex);
if (DEBUG)
+ {
std::cout << "Checking path " << oemNamePath << "\n";
+ }
std::ifstream nameFile(oemNamePath);
if (!nameFile.good())
{
@@ -205,7 +207,7 @@
}
}
std::vector<thresholds::Threshold> sensorThresholds;
- if (!ParseThresholdsFromConfig(*sensorData, sensorThresholds))
+ if (!parseThresholdsFromConfig(*sensorData, sensorThresholds))
{
std::cerr << "error populating thresholds for " << sensorName
<< "\n";
@@ -216,7 +218,7 @@
std::move(sensorThresholds), *interfacePath);
}
std::vector<fs::path> pwms;
- if (!find_files(fs::path("/sys/class/hwmon"), R"(pwm\d+)", pwms))
+ if (!findFiles(fs::path("/sys/class/hwmon"), R"(pwm\d+)", pwms))
{
std::cerr << "No pwm in system\n";
return;
@@ -277,12 +279,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));
}