Fix some gcc warnings and style suggestions
Building against gcc-10 produced warnings and style suggestions.
Fixed all the warnings, but only select style suggestions due to
readability and others appeared to be compiler confusion.
Tested: Compiled
No functional impacts appear to have been made with these changes
Change-Id: I1adcce355b831ae8b178bfba9b89cc18fe4f3cf7
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/control/functor.hpp b/control/functor.hpp
index f631311..658c76a 100644
--- a/control/functor.hpp
+++ b/control/functor.hpp
@@ -87,7 +87,8 @@
Properties& operator=(const Properties&) = default;
Properties(Properties&&) = default;
Properties& operator=(Properties&&) = default;
- explicit Properties(U&& handler) : _handler(std::forward<U>(handler))
+ explicit Properties(U&& handler) :
+ _path(""), _intf(""), _prop(""), _handler(std::forward<U>(handler))
{}
Properties(const char* path, const char* intf, const char* prop,
U&& handler) :
@@ -404,10 +405,11 @@
void operator()(sdbusplus::bus::bus& bus, sdbusplus::message::message& msg,
Zone& zone) const
{
- std::string name;
- bool hasOwner = false;
if (msg)
{
+ std::string name;
+ bool hasOwner = false;
+
// Handle NameOwnerChanged signals
msg.read(name);
diff --git a/control/zone.cpp b/control/zone.cpp
index 3c87654..9efb0c7 100644
--- a/control/zone.cpp
+++ b/control/zone.cpp
@@ -63,9 +63,9 @@
{
auto& fanDefs = std::get<fanListPos>(def);
- for (auto& def : fanDefs)
+ for (auto& fanDef : fanDefs)
{
- _fans.emplace_back(std::make_unique<Fan>(bus, def));
+ _fans.emplace_back(std::make_unique<Fan>(bus, fanDef));
}
// Do not enable set speed events when in init mode
@@ -89,9 +89,9 @@
_targetSpeed = _fans.front()->getTargetSpeed();
}
// Setup signal trigger for set speed events
- for (auto& event : std::get<setSpeedEventsPos>(def))
+ for (auto& ssEvent : std::get<setSpeedEventsPos>(def))
{
- initEvent(event);
+ initEvent(ssEvent);
}
// Start timer for fan speed decreases
_decTimer.restart(_decInterval);
@@ -523,7 +523,7 @@
if (it != _persisted.end())
{
return std::any_of(it->second.begin(), it->second.end(),
- [&prop](auto& p) { return prop == p; });
+ [&prop](const auto& p) { return prop == p; });
}
return persisted;
diff --git a/cooling-type/cooling_type.cpp b/cooling-type/cooling_type.cpp
index d996230..86b1385 100644
--- a/cooling-type/cooling_type.cpp
+++ b/cooling-type/cooling_type.cpp
@@ -102,9 +102,9 @@
ObjectMap invObj = getObjectMap(objpath);
// Update inventory
- auto invMgrResponseMsg = util::SDBusPlus::lookupAndCallMethod(
+ static_cast<void>(util::SDBusPlus::lookupAndCallMethod(
bus, util::INVENTORY_PATH, util::INVENTORY_INTF, "Notify",
- std::move(invObj));
+ std::move(invObj)));
}
} // namespace type
diff --git a/cooling-type/cooling_type.hpp b/cooling-type/cooling_type.hpp
index 2622f6c..752c32c 100644
--- a/cooling-type/cooling_type.hpp
+++ b/cooling-type/cooling_type.hpp
@@ -44,7 +44,7 @@
*
* @param[in] bus - Dbus bus object
*/
- CoolingType(sdbusplus::bus::bus& bus) : bus(bus)
+ explicit CoolingType(sdbusplus::bus::bus& bus) : bus(bus), gpioFd(-1)
{
// TODO: Issue openbmc/openbmc#1531 - means to default properties.
}
@@ -75,7 +75,7 @@
/** @brief Connection for sdbusplus bus */
sdbusplus::bus::bus& bus;
// File descriptor for the GPIO file we are going to read.
- phosphor::fan::util::FileDescriptor gpioFd = -1;
+ phosphor::fan::util::FileDescriptor gpioFd;
bool airCooled = false;
bool waterCooled = false;
diff --git a/presence/tach.cpp b/presence/tach.cpp
index ee35878..3372d8e 100644
--- a/presence/tach.cpp
+++ b/presence/tach.cpp
@@ -119,12 +119,11 @@
void Tach::propertiesChanged(size_t sensor,
const util::Properties<int64_t>& props)
{
- auto& s = state[sensor];
-
// Find the Value property containing the speed.
auto it = props.find(tachProperty);
if (it != props.end())
{
+ auto& s = state[sensor];
std::get<int64_t>(s) = std::get<int64_t>(it->second);
auto newState =
diff --git a/sdbusplus.hpp b/sdbusplus.hpp
index 9c3d08d..703895e 100644
--- a/sdbusplus.hpp
+++ b/sdbusplus.hpp
@@ -32,7 +32,7 @@
class DBusError : public std::runtime_error
{
public:
- DBusError(const char* msg) : std::runtime_error(msg)
+ explicit DBusError(const char* msg) : std::runtime_error(msg)
{}
};
diff --git a/utility.hpp b/utility.hpp
index 7db9047..4e8c226 100644
--- a/utility.hpp
+++ b/utility.hpp
@@ -40,7 +40,7 @@
FileDescriptor& operator=(const FileDescriptor&) = delete;
FileDescriptor& operator=(FileDescriptor&&) = default;
- FileDescriptor(int fd) : fd(fd)
+ explicit FileDescriptor(int fd) : fd(fd)
{}
~FileDescriptor()