Clean up
Turn on werror and wall. Also return emtpy on
MATCH_ONE to discourage template usage.
Change-Id: I1b987d901d251c61b846ee88a3b95df36d59d439
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/src/EntityManager.cpp b/src/EntityManager.cpp
index 35fadb9..fb75856 100644
--- a/src/EntityManager.cpp
+++ b/src/EntityManager.cpp
@@ -38,9 +38,7 @@
constexpr const char* schemaDirectory = PACKAGE_DIR "configurations/schemas";
constexpr const char* globalSchema = "global.json";
constexpr const char* TEMPLATE_CHAR = "$";
-constexpr const size_t PROPERTIES_CHANGED_UNTIL_FLUSH_COUNT = 20;
constexpr const int32_t MAX_MAPPER_DEPTH = 0;
-constexpr const size_t SLEEP_AFTER_PROPERTIES_CHANGE_SECONDS = 5;
struct cmp_str
{
@@ -160,8 +158,7 @@
{
for (auto& connPair : object.second)
{
- auto insertPair =
- interfaceConnections.insert(connPair.first);
+ interfaceConnections.insert(connPair.first);
}
}
}
@@ -286,6 +283,11 @@
}
break;
}
+ default:
+ {
+ std::cerr << "unexpected dbus probe type "
+ << match.second.type_name() << "\n";
+ }
}
}
else
@@ -342,12 +344,10 @@
case probe_type_codes::FALSE_T:
{
return false;
- break;
}
case probe_type_codes::TRUE_T:
{
return true;
- break;
}
case probe_type_codes::MATCH_ONE:
{
@@ -367,7 +367,7 @@
{
if (!std::regex_search(probe, match, command))
{
- std::cerr << "found probe sytax error " << probe
+ std::cerr << "found probe syntax error " << probe
<< "\n";
return false;
}
@@ -377,6 +377,10 @@
commandStr) != PASSED_PROBES.end());
break;
}
+ default:
+ {
+ break;
+ }
}
}
// look on dbus for object
@@ -384,7 +388,7 @@
{
if (!std::regex_search(probe, match, command))
{
- std::cerr << "dbus probe sytax error " << probe << "\n";
+ std::cerr << "dbus probe syntax error " << probe << "\n";
return false;
}
std::string commandStr = *(match.begin() + 1);
@@ -394,7 +398,7 @@
auto json = nlohmann::json::parse(commandStr, nullptr, false);
if (json.is_discarded())
{
- std::cerr << "dbus command sytax error " << commandStr << "\n";
+ std::cerr << "dbus command syntax error " << commandStr << "\n";
return false;
}
// we can match any (string, variant) property. (string, string)
@@ -436,9 +440,14 @@
foundDevs.emplace_back(
boost::container::flat_map<std::string, BasicVariantType>());
}
- if (matchOne && foundDevs.size() > 1)
+ if (matchOne && ret)
{
- foundDevs.erase(foundDevs.begin() + 1, foundDevs.end());
+ // match one could match multiple dbus values, which means we don't care
+ // what one we found so we shouldn't be using template replace. return
+ // an empty one
+ foundDevs.clear();
+ foundDevs.emplace_back(
+ boost::container::flat_map<std::string, BasicVariantType>());
}
return ret;
}
@@ -456,9 +465,11 @@
}
~PerformProbe()
{
- if (probe(_probeCommand, _foundDevs))
+ std::vector<boost::container::flat_map<std::string, BasicVariantType>>
+ foundDevs;
+ if (probe(_probeCommand, foundDevs))
{
- _callback(_foundDevs);
+ _callback(foundDevs);
}
}
void run()
@@ -467,7 +478,6 @@
boost::container::flat_map<const char*, probe_type_codes,
cmp_str>::const_iterator probeType;
- std::vector<std::string> dbusProbes;
for (std::string& probe : _probeCommand)
{
bool found = false;
@@ -497,8 +507,6 @@
std::function<void(std::vector<boost::container::flat_map<
std::string, BasicVariantType>>&)>
_callback;
- std::vector<boost::container::flat_map<std::string, BasicVariantType>>
- _foundDevs;
};
// writes output files to persist data
@@ -793,6 +801,11 @@
}
break;
}
+ default:
+ {
+ std::cerr << "Unexpected json type in system configuration \n";
+ break;
+ }
}
}
if (permission == sdbusplus::asio::PropertyPermission::readWrite)
@@ -925,7 +938,6 @@
for (auto& boardPair : newConfiguration.items())
{
std::string boardKey = boardPair.key();
- std::vector<std::string> path;
std::string jsonPointerPath = "/" + boardKey;
// loop through newConfiguration, but use values from system
// configuration to be able to modify via dbus later
@@ -1129,8 +1141,6 @@
boost::replace_all(*strPtr, "$index", std::to_string(foundDeviceIdx));
- std::size_t templateIndex = 0;
-
for (auto& foundDevicePair : foundDevice)
{
std::string templateName = "$" + foundDevicePair.first;
@@ -1311,7 +1321,7 @@
PASSED_PROBES.push_back(name);
size_t foundDeviceIdx = 0;
- // insert into configuration temporarly to be able to
+ // insert into configuration temporarily to be able to
// reference ourselves
_systemConfiguration[name] = *record;