summaryrefslogtreecommitdiff
path: root/redfish-core/lib/sensors.hpp
diff options
context:
space:
mode:
authorEd Tanous <ed@tanous.net>2020-07-25 07:45:05 +0300
committerEd Tanous <ed@tanous.net>2020-08-17 23:54:37 +0300
commit23a21a1cbed23ace4174664950e595df961e9e69 (patch)
tree12e7cc9d9301642fc1e48332a0e0834c54e8c8af /redfish-core/lib/sensors.hpp
parent52cc112d962920b035c870127784bcbd98948fad (diff)
downloadbmcweb-23a21a1cbed23ace4174664950e595df961e9e69.tar.xz
Enable clang warnings
This commit enables clang warnings, and fixes all warnings that were found. Most of these fall into a couple categories: Variable shadow issues were fixed by renaming variables unused parameter warnings were resolved by either checking error codes that had been ignored, or removing the name of the variable from the scope. Other various warnings were fixed in the best way I was able to come up with. Note, the redfish Node class is especially insidious, as it causes all imlementers to have variables for parameters, regardless of whether or not they are used. Deprecating the Node class is on my list of things to do, as it adds extra overhead, and in general isn't a useful abstraction. For now, I have simply fixed all the handlers. Tested: Added the current meta-clang meta layer into bblayers.conf, and added TOOLCHAIN_pn-bmcweb = "clang" to my local.conf Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: Ia75b94010359170159c703e535d1c1af182fe700
Diffstat (limited to 'redfish-core/lib/sensors.hpp')
-rw-r--r--redfish-core/lib/sensors.hpp53
1 files changed, 27 insertions, 26 deletions
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index 99a03c9bf6..d1895c45fb 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -320,7 +320,7 @@ void getConnections(
* allSensors list. Eliminate Thermal sensors when a Power request is
* made, and eliminate Power sensors when a Thermal request is made.
*/
-void reduceSensorList(
+inline void reduceSensorList(
std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp,
const std::vector<std::string>* allSensors,
std::shared_ptr<boost::container::flat_set<std::string>> activeSensors)
@@ -623,7 +623,7 @@ void getObjectManagerPaths(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp,
* @param inventoryItem D-Bus inventory item associated with a sensor.
* @return State value for inventory item.
*/
-static std::string getState(const InventoryItem* inventoryItem)
+inline std::string getState(const InventoryItem* inventoryItem)
{
if ((inventoryItem != nullptr) && !(inventoryItem->isPresent))
{
@@ -641,7 +641,7 @@ static std::string getState(const InventoryItem* inventoryItem)
* be nullptr if no associated inventory item was found.
* @return Health value for sensor.
*/
-static std::string getHealth(
+inline std::string getHealth(
nlohmann::json& sensorJson,
const boost::container::flat_map<
std::string, boost::container::flat_map<std::string, SensorVariant>>&
@@ -759,7 +759,7 @@ static std::string getHealth(
return "OK";
}
-static void setLedState(nlohmann::json& sensorJson,
+inline void setLedState(nlohmann::json& sensorJson,
const InventoryItem* inventoryItem)
{
if (inventoryItem != nullptr && !inventoryItem->ledObjectPath.empty())
@@ -775,7 +775,7 @@ static void setLedState(nlohmann::json& sensorJson,
case LedState::BLINK:
sensorJson["IndicatorLED"] = "Blinking";
break;
- default:
+ case LedState::UNKNOWN:
break;
}
}
@@ -793,7 +793,7 @@ static void setLedState(nlohmann::json& sensorJson,
* @param inventoryItem D-Bus inventory item associated with the sensor. Will
* be nullptr if no associated inventory item was found.
*/
-void objectInterfacesToJson(
+inline void objectInterfacesToJson(
const std::string& sensorName, const std::string& sensorType,
std::shared_ptr<SensorsAsyncResp> sensorsAsyncResp,
const boost::container::flat_map<
@@ -1043,7 +1043,7 @@ void objectInterfacesToJson(
BMCWEB_LOG_DEBUG << "Added sensor " << sensorName;
}
-static void
+inline void
populateFanRedundancy(std::shared_ptr<SensorsAsyncResp> sensorsAsyncResp)
{
crow::connections::systemBus->async_method_call(
@@ -1250,7 +1250,7 @@ static void
"xyz.openbmc_project.Control.FanRedundancy"});
}
-void sortJSONResponse(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp)
+inline void sortJSONResponse(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp)
{
nlohmann::json& response = SensorsAsyncResp->res.jsonValue;
std::array<std::string, 2> sensorHeaders{"Temperatures", "Fans"};
@@ -1295,7 +1295,7 @@ void sortJSONResponse(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp)
* @param invItemObjPath D-Bus object path of inventory item.
* @return Inventory item within vector, or nullptr if no match found.
*/
-static InventoryItem* findInventoryItem(
+inline InventoryItem* findInventoryItem(
std::shared_ptr<std::vector<InventoryItem>> inventoryItems,
const std::string& invItemObjPath)
{
@@ -1315,7 +1315,7 @@ static InventoryItem* findInventoryItem(
* @param sensorObjPath D-Bus object path of sensor.
* @return Inventory item within vector, or nullptr if no match found.
*/
-static InventoryItem* findInventoryItemForSensor(
+inline InventoryItem* findInventoryItemForSensor(
std::shared_ptr<std::vector<InventoryItem>> inventoryItems,
const std::string& sensorObjPath)
{
@@ -1363,7 +1363,7 @@ inline InventoryItem*
* @param invItemObjPath D-Bus object path of inventory item.
* @param sensorObjPath D-Bus object path of sensor
*/
-static void
+inline void
addInventoryItem(std::shared_ptr<std::vector<InventoryItem>> inventoryItems,
const std::string& invItemObjPath,
const std::string& sensorObjPath)
@@ -1396,7 +1396,7 @@ static void
* @param interfacesDict Map containing D-Bus interfaces and their properties
* for the specified inventory item.
*/
-static void storeInventoryItemData(
+inline void storeInventoryItemData(
InventoryItem& inventoryItem,
const boost::container::flat_map<
std::string, boost::container::flat_map<std::string, SensorVariant>>&
@@ -2348,7 +2348,7 @@ static void getInventoryItems(
* @param chassisId Chassis that contains the power supply.
* @return JSON PowerSupply object for the specified inventory item.
*/
-static nlohmann::json& getPowerSupply(nlohmann::json& powerSupplyArray,
+inline nlohmann::json& getPowerSupply(nlohmann::json& powerSupplyArray,
const InventoryItem& inventoryItem,
const std::string& chassisId)
{
@@ -2416,7 +2416,7 @@ static nlohmann::json& getPowerSupply(nlohmann::json& powerSupplyArray,
* implements ObjectManager.
* @param inventoryItems Inventory items associated with the sensors.
*/
-void getSensorData(
+inline void getSensorData(
std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp,
const std::shared_ptr<boost::container::flat_set<std::string>> sensorNames,
const boost::container::flat_set<std::string>& connections,
@@ -2596,11 +2596,11 @@ void getSensorData(
crow::connections::systemBus->async_method_call(
getManagedObjectsCb, connection, objectMgrPath,
"org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
- };
+ }
BMCWEB_LOG_DEBUG << "getSensorData exit";
}
-void processSensorList(
+inline void processSensorList(
std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp,
std::shared_ptr<boost::container::flat_set<std::string>> sensorNames)
{
@@ -2651,7 +2651,7 @@ void processSensorList(
* chassis.
* @param SensorsAsyncResp Pointer to object holding response data
*/
-void getChassisData(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp)
+inline void getChassisData(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp)
{
BMCWEB_LOG_DEBUG << "getChassisData enter";
auto getChassisCb =
@@ -2678,7 +2678,7 @@ void getChassisData(std::shared_ptr<SensorsAsyncResp> SensorsAsyncResp)
* @param sensorsModified The list of sensors that were found as a result of
* repeated calls to this function
*/
-bool findSensorNameUsingSensorPath(
+inline bool findSensorNameUsingSensorPath(
std::string_view sensorName,
boost::container::flat_set<std::string>& sensorsList,
boost::container::flat_set<std::string>& sensorsModified)
@@ -2707,7 +2707,7 @@ bool findSensorNameUsingSensorPath(
* @param allCollections Collections extract from sensors' request patch info
* @param chassisSubNode Chassis Node for which the query has to happen
*/
-void setSensorsOverride(
+inline void setSensorsOverride(
std::shared_ptr<SensorsAsyncResp> sensorAsyncResp,
std::unordered_map<std::string, std::vector<nlohmann::json>>&
allCollections)
@@ -2832,7 +2832,7 @@ void setSensorsOverride(
getChassis(sensorAsyncResp, std::move(getChassisSensorListCb));
}
-bool isOverridingAllowed(const std::string& manufacturingModeStatus)
+inline bool isOverridingAllowed(const std::string& manufacturingModeStatus)
{
if (manufacturingModeStatus ==
"xyz.openbmc_project.Control.Security.SpecialMode.Modes.Manufacturing")
@@ -2860,7 +2860,7 @@ bool isOverridingAllowed(const std::string& manufacturingModeStatus)
* @param allCollections Collections extract from sensors' request patch info
* @param chassisSubNode Chassis Node for which the query has to happen
*/
-void checkAndDoSensorsOverride(
+inline void checkAndDoSensorsOverride(
std::shared_ptr<SensorsAsyncResp> sensorAsyncResp,
std::unordered_map<std::string, std::vector<nlohmann::json>>&
allCollections)
@@ -2872,13 +2872,13 @@ void checkAndDoSensorsOverride(
"xyz.openbmc_project.Security.SpecialMode"};
crow::connections::systemBus->async_method_call(
- [sensorAsyncResp, allCollections](const boost::system::error_code ec,
+ [sensorAsyncResp, allCollections](const boost::system::error_code ec2,
const GetSubTreeType& resp) mutable {
- if (ec)
+ if (ec2)
{
BMCWEB_LOG_DEBUG
<< "Error in querying GetSubTree with Object Mapper. "
- << ec;
+ << ec2;
messages::internalError(sensorAsyncResp->res);
return;
}
@@ -2972,8 +2972,9 @@ void checkAndDoSensorsOverride(
* @param node Node (group) of sensors. See sensors::node for supported values
* @param mapComplete Callback to be called with retrieval result
*/
-void retrieveUriToDbusMap(const std::string& chassis, const std::string& node,
- SensorsAsyncResp::DataCompleteCb&& mapComplete)
+inline void retrieveUriToDbusMap(const std::string& chassis,
+ const std::string& node,
+ SensorsAsyncResp::DataCompleteCb&& mapComplete)
{
auto typesIt = sensors::dbus::types.find(node);
if (typesIt == sensors::dbus::types.end())