drop struct keyword for non-packed objects
As a style decision, struct is often used with packed structures to
indicate they are used like C-structs. Cleanup this codebase to not use
the extra struct keyword throughout.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I2f83bb1989e4d1f2f843ba3e45fb82e04f0fa61c
diff --git a/conf.hpp b/conf.hpp
index f2157e1..e471f22 100644
--- a/conf.hpp
+++ b/conf.hpp
@@ -58,7 +58,7 @@
double failsafePercent;
};
-using PIDConf = std::map<std::string, struct ControllerInfo>;
+using PIDConf = std::map<std::string, ControllerInfo>;
constexpr bool DEBUG = false; // enable to print found configuration
diff --git a/dbus/dbusactiveread.cpp b/dbus/dbusactiveread.cpp
index 689a85d..3d0ed79 100644
--- a/dbus/dbusactiveread.cpp
+++ b/dbus/dbusactiveread.cpp
@@ -28,7 +28,7 @@
ReadReturn DbusActiveRead::read(void)
{
- struct SensorProperties settings;
+ SensorProperties settings;
double value;
_helper->getProperties(_service, _path, &settings);
@@ -39,7 +39,7 @@
* Technically it might not be a value from now, but there's no timestamp
* on Sensor.Value yet.
*/
- struct ReadReturn r = {value, std::chrono::high_resolution_clock::now()};
+ ReadReturn r = {value, std::chrono::high_resolution_clock::now()};
return r;
}
diff --git a/dbus/dbusconfiguration.cpp b/dbus/dbusconfiguration.cpp
index 161f14a..55151d3 100644
--- a/dbus/dbusconfiguration.cpp
+++ b/dbus/dbusconfiguration.cpp
@@ -260,7 +260,7 @@
void populatePidInfo(
sdbusplus::bus::bus& bus,
const std::unordered_map<std::string, DbusVariantType>& base,
- struct conf::ControllerInfo& info, const std::string* thresholdProperty,
+ conf::ControllerInfo& info, const std::string* thresholdProperty,
const std::map<std::string, conf::SensorConfig>& sensorConfig)
{
info.type = std::get<std::string>(getPIDAttribute(base, "Class"));
@@ -752,7 +752,7 @@
if (offsetType.empty())
{
- struct conf::ControllerInfo& info =
+ conf::ControllerInfo& info =
conf[std::get<std::string>(base.at("Name"))];
info.inputs = std::move(inputSensorNames);
populatePidInfo(bus, base, info, nullptr, sensorConfig);
@@ -763,7 +763,7 @@
// values will differ, making setpoints differ
for (const std::string& input : inputSensorNames)
{
- struct conf::ControllerInfo& info = conf[input];
+ conf::ControllerInfo& info = conf[input];
info.inputs.emplace_back(input);
populatePidInfo(bus, base, info, &offsetType,
sensorConfig);
@@ -822,7 +822,7 @@
{
continue;
}
- struct conf::ControllerInfo& info =
+ conf::ControllerInfo& info =
conf[std::get<std::string>(base.at("Name"))];
info.inputs = std::move(inputs);
diff --git a/dbus/dbushelper.cpp b/dbus/dbushelper.cpp
index f7dbe41..8601733 100644
--- a/dbus/dbushelper.cpp
+++ b/dbus/dbushelper.cpp
@@ -74,8 +74,7 @@
}
void DbusHelper::getProperties(const std::string& service,
- const std::string& path,
- struct SensorProperties* prop)
+ const std::string& path, SensorProperties* prop)
{
auto pimMsg = _bus.new_method_call(service.c_str(), path.c_str(),
propertiesintf, "GetAll");
diff --git a/dbus/dbushelper.hpp b/dbus/dbushelper.hpp
index b4d3aa0..81a7238 100644
--- a/dbus/dbushelper.hpp
+++ b/dbus/dbushelper.hpp
@@ -33,7 +33,7 @@
const std::string& path) override;
void getProperties(const std::string& service, const std::string& path,
- struct SensorProperties* prop) override;
+ SensorProperties* prop) override;
bool thresholdsAsserted(const std::string& service,
const std::string& path) override;
diff --git a/dbus/dbushelper_interface.hpp b/dbus/dbushelper_interface.hpp
index 4dbf00c..3f7d744 100644
--- a/dbus/dbushelper_interface.hpp
+++ b/dbus/dbushelper_interface.hpp
@@ -32,13 +32,13 @@
* @param[in] bus - A bus to use for the call.
* @param[in] service - The service providing the interface.
* @param[in] path - The dbus path.
- * @param[out] prop - A pointer to a properties struct to fill out.
+ * @param[out] prop - A pointer to a properties to fill out.
*
* @warning Throws exception on dbus failure.
*/
virtual void getProperties(const std::string& service,
const std::string& path,
- struct SensorProperties* prop) = 0;
+ SensorProperties* prop) = 0;
/** @brief Get Critical Threshold current assert status
*
diff --git a/dbus/dbuspassive.cpp b/dbus/dbuspassive.cpp
index 6667bc4..0c73db2 100644
--- a/dbus/dbuspassive.cpp
+++ b/dbus/dbuspassive.cpp
@@ -50,7 +50,7 @@
/* service == busname */
std::string path = getSensorPath(type, id);
- struct SensorProperties settings;
+ SensorProperties settings;
bool failed;
try
@@ -79,8 +79,7 @@
DbusPassive::DbusPassive(
sdbusplus::bus::bus& bus, const std::string& type, const std::string& id,
std::unique_ptr<DbusHelperInterface> helper,
- const struct SensorProperties& settings, bool failed,
- const std::string& path,
+ const SensorProperties& settings, bool failed, const std::string& path,
const std::shared_ptr<DbusPassiveRedundancy>& redundancy) :
ReadInterface(),
_signal(bus, getMatch(type, id).c_str(), dbusHandleSignal, this), _id(id),
@@ -103,7 +102,7 @@
{
std::lock_guard<std::mutex> guard(_lock);
- struct ReadReturn r = {_value, _updated};
+ ReadReturn r = {_value, _updated};
return r;
}
diff --git a/dbus/dbuspassive.hpp b/dbus/dbuspassive.hpp
index 3b091dd..9065a29 100644
--- a/dbus/dbuspassive.hpp
+++ b/dbus/dbuspassive.hpp
@@ -49,7 +49,7 @@
DbusPassive(sdbusplus::bus::bus& bus, const std::string& type,
const std::string& id,
std::unique_ptr<DbusHelperInterface> helper,
- const struct SensorProperties& settings, bool failed,
+ const SensorProperties& settings, bool failed,
const std::string& path,
const std::shared_ptr<DbusPassiveRedundancy>& redundancy);
diff --git a/main.cpp b/main.cpp
index f5d34e0..9a47a00 100644
--- a/main.cpp
+++ b/main.cpp
@@ -51,11 +51,11 @@
{
/* The configuration converted sensor list. */
-std::map<std::string, struct conf::SensorConfig> sensorConfig = {};
+std::map<std::string, conf::SensorConfig> sensorConfig = {};
/* The configuration converted PID list. */
std::map<int64_t, conf::PIDConf> zoneConfig = {};
/* The configuration converted Zone configuration. */
-std::map<int64_t, struct conf::ZoneConfig> zoneDetailsConfig = {};
+std::map<int64_t, conf::ZoneConfig> zoneDetailsConfig = {};
} // namespace pid_control
diff --git a/pid/builder.cpp b/pid/builder.cpp
index 706585a..505ca98 100644
--- a/pid/builder.cpp
+++ b/pid/builder.cpp
@@ -46,7 +46,7 @@
std::unordered_map<int64_t, std::shared_ptr<ZoneInterface>>
buildZones(const std::map<int64_t, conf::PIDConf>& zonePids,
- std::map<int64_t, struct conf::ZoneConfig>& zoneConfigs,
+ std::map<int64_t, conf::ZoneConfig>& zoneConfigs,
SensorManager& mgr, sdbusplus::bus::bus& modeControlBus)
{
std::unordered_map<int64_t, std::shared_ptr<ZoneInterface>> zones;
diff --git a/pid/builder.hpp b/pid/builder.hpp
index c07de74..5f03400 100644
--- a/pid/builder.hpp
+++ b/pid/builder.hpp
@@ -14,7 +14,7 @@
std::unordered_map<int64_t, std::shared_ptr<ZoneInterface>>
buildZones(const std::map<int64_t, conf::PIDConf>& zonePids,
- std::map<int64_t, struct conf::ZoneConfig>& zoneConfigs,
+ std::map<int64_t, conf::ZoneConfig>& zoneConfigs,
SensorManager& mgr, sdbusplus::bus::bus& modeControlBus);
}
diff --git a/pid/buildjson.cpp b/pid/buildjson.cpp
index c178293..e078fdb 100644
--- a/pid/buildjson.cpp
+++ b/pid/buildjson.cpp
@@ -118,14 +118,13 @@
}
} // namespace conf
-std::pair<std::map<int64_t, conf::PIDConf>,
- std::map<int64_t, struct conf::ZoneConfig>>
+std::pair<std::map<int64_t, conf::PIDConf>, std::map<int64_t, conf::ZoneConfig>>
buildPIDsFromJson(const json& data)
{
// zone -> pids
std::map<int64_t, conf::PIDConf> pidConfig;
// zone -> configs
- std::map<int64_t, struct conf::ZoneConfig> zoneConfig;
+ std::map<int64_t, conf::ZoneConfig> zoneConfig;
/* TODO: if zones is empty, that's invalid. */
auto zones = data["zones"];
@@ -133,7 +132,7 @@
{
int64_t id;
conf::PIDConf thisZone;
- struct conf::ZoneConfig thisZoneConfig;
+ conf::ZoneConfig thisZoneConfig;
/* TODO: using at() throws a specific exception we can catch */
id = zone["id"];
diff --git a/pid/buildjson.hpp b/pid/buildjson.hpp
index 5489c5a..56267fa 100644
--- a/pid/buildjson.hpp
+++ b/pid/buildjson.hpp
@@ -18,8 +18,7 @@
* @param[in] data - the json data
* @return the pidConfig, and the zoneConfig
*/
-std::pair<std::map<int64_t, conf::PIDConf>,
- std::map<int64_t, struct conf::ZoneConfig>>
+std::pair<std::map<int64_t, conf::PIDConf>, std::map<int64_t, conf::ZoneConfig>>
buildPIDsFromJson(const json& data);
} // namespace pid_control
diff --git a/sensors/builder.cpp b/sensors/builder.cpp
index de7e020..f4257ad 100644
--- a/sensors/builder.cpp
+++ b/sensors/builder.cpp
@@ -43,7 +43,7 @@
static constexpr bool deferSignals = true;
SensorManager
- buildSensors(const std::map<std::string, struct conf::SensorConfig>& config,
+ buildSensors(const std::map<std::string, conf::SensorConfig>& config,
sdbusplus::bus::bus& passive, sdbusplus::bus::bus& host)
{
SensorManager mgmr(passive, host);
@@ -56,7 +56,7 @@
std::unique_ptr<WriteInterface> wi;
std::string name = it.first;
- const struct conf::SensorConfig* info = &it.second;
+ const conf::SensorConfig* info = &it.second;
std::cerr << "Sensor: " << name << " " << info->type << " ";
std::cerr << info->readPath << " " << info->writePath << "\n";
diff --git a/sensors/builder.hpp b/sensors/builder.hpp
index bea3bd0..955307a 100644
--- a/sensors/builder.hpp
+++ b/sensors/builder.hpp
@@ -16,7 +16,7 @@
* Build the sensors and associate them with a SensorManager.
*/
SensorManager
- buildSensors(const std::map<std::string, struct conf::SensorConfig>& config,
+ buildSensors(const std::map<std::string, conf::SensorConfig>& config,
sdbusplus::bus::bus& passive, sdbusplus::bus::bus& host);
} // namespace pid_control
diff --git a/sensors/buildjson.cpp b/sensors/buildjson.cpp
index 2bfc143..c320fe1 100644
--- a/sensors/buildjson.cpp
+++ b/sensors/buildjson.cpp
@@ -99,10 +99,9 @@
}
} // namespace conf
-std::map<std::string, struct conf::SensorConfig>
- buildSensorsFromJson(const json& data)
+std::map<std::string, conf::SensorConfig> buildSensorsFromJson(const json& data)
{
- std::map<std::string, struct conf::SensorConfig> config;
+ std::map<std::string, conf::SensorConfig> config;
auto sensors = data["sensors"];
/* TODO: If no sensors, this is invalid, and we should except here or during
@@ -110,7 +109,7 @@
*/
for (const auto& sensor : sensors)
{
- config[sensor["name"]] = sensor.get<struct conf::SensorConfig>();
+ config[sensor["name"]] = sensor.get<conf::SensorConfig>();
}
return config;
diff --git a/sensors/buildjson.hpp b/sensors/buildjson.hpp
index ee82381..2075d30 100644
--- a/sensors/buildjson.hpp
+++ b/sensors/buildjson.hpp
@@ -20,7 +20,7 @@
* @param[in] data - the json data
* @return a map of sensors.
*/
-std::map<std::string, struct conf::SensorConfig>
+std::map<std::string, conf::SensorConfig>
buildSensorsFromJson(const json& data);
} // namespace pid_control
diff --git a/sensors/host.cpp b/sensors/host.cpp
index e05ac37..53f114e 100644
--- a/sensors/host.cpp
+++ b/sensors/host.cpp
@@ -86,7 +86,7 @@
std::lock_guard<std::mutex> guard(_lock);
/* This doesn't sanity check anything, that's the caller's job. */
- struct ReadReturn r = {_value, _updated};
+ ReadReturn r = {_value, _updated};
return r;
}
diff --git a/sysfs/sysfsread.cpp b/sysfs/sysfsread.cpp
index eee1c8a..deb533a 100644
--- a/sysfs/sysfsread.cpp
+++ b/sysfs/sysfsread.cpp
@@ -32,8 +32,8 @@
ifs >> value;
ifs.close();
- struct ReadReturn r = {static_cast<double>(value),
- std::chrono::high_resolution_clock::now()};
+ ReadReturn r = {static_cast<double>(value),
+ std::chrono::high_resolution_clock::now()};
return r;
}
diff --git a/test/dbus_active_unittest.cpp b/test/dbus_active_unittest.cpp
index 6c640f8..3f06c96 100644
--- a/test/dbus_active_unittest.cpp
+++ b/test/dbus_active_unittest.cpp
@@ -42,13 +42,12 @@
std::string service = "asdfasdf.asdfasdf";
EXPECT_CALL(*helper, getProperties(service, path, NotNull()))
- .WillOnce(
- Invoke([&](const std::string& service, const std::string& path,
- struct SensorProperties* prop) {
- prop->scale = -3;
- prop->value = 10000;
- prop->unit = "x";
- }));
+ .WillOnce(Invoke([&](const std::string& service,
+ const std::string& path, SensorProperties* prop) {
+ prop->scale = -3;
+ prop->value = 10000;
+ prop->unit = "x";
+ }));
DbusActiveRead ar(bus_mock, path, service, std::move(helper));
diff --git a/test/dbus_passive_unittest.cpp b/test/dbus_passive_unittest.cpp
index a04b4ec..e6f07a0 100644
--- a/test/dbus_passive_unittest.cpp
+++ b/test/dbus_passive_unittest.cpp
@@ -56,7 +56,7 @@
std::string path = "/xyz/openbmc_project/sensors/unknown/id";
auto helper = std::make_unique<DbusHelperMock>();
- struct SensorProperties properties;
+ SensorProperties properties;
DbusPassive(bus_mock, type, id, std::move(helper), properties, false, path,
nullptr);
@@ -78,7 +78,7 @@
getProperties(StrEq("asdf"), StrEq(path), NotNull()))
.WillOnce(
Invoke([&](const std::string& service, const std::string& path,
- struct SensorProperties* prop) {
+ SensorProperties* prop) {
prop->scale = _scale;
prop->value = _value;
prop->unit = "x";
diff --git a/test/dbushelper_mock.hpp b/test/dbushelper_mock.hpp
index 44b3bea..0d4221d 100644
--- a/test/dbushelper_mock.hpp
+++ b/test/dbushelper_mock.hpp
@@ -17,7 +17,7 @@
MOCK_METHOD2(getService,
std::string(const std::string&, const std::string&));
MOCK_METHOD3(getProperties, void(const std::string&, const std::string&,
- struct SensorProperties*));
+ SensorProperties*));
MOCK_METHOD2(thresholdsAsserted,
bool(const std::string& service, const std::string& path));
diff --git a/test/pid_json_unittest.cpp b/test/pid_json_unittest.cpp
index 0e767f9..827d207 100644
--- a/test/pid_json_unittest.cpp
+++ b/test/pid_json_unittest.cpp
@@ -14,7 +14,7 @@
// This is technically invalid.
std::map<int64_t, conf::PIDConf> pidConfig;
- std::map<int64_t, struct conf::ZoneConfig> zoneConfig;
+ std::map<int64_t, conf::ZoneConfig> zoneConfig;
auto j2 = R"(
{
@@ -33,7 +33,7 @@
// Parse a valid configuration with one zone and one PID.
std::map<int64_t, conf::PIDConf> pidConfig;
- std::map<int64_t, struct conf::ZoneConfig> zoneConfig;
+ std::map<int64_t, conf::ZoneConfig> zoneConfig;
auto j2 = R"(
{
@@ -78,7 +78,7 @@
// Hysteresis parameters.
std::map<int64_t, conf::PIDConf> pidConfig;
- std::map<int64_t, struct conf::ZoneConfig> zoneConfig;
+ std::map<int64_t, conf::ZoneConfig> zoneConfig;
auto j2 = R"(
{
@@ -127,7 +127,7 @@
// Hysteresis parameters.
std::map<int64_t, conf::PIDConf> pidConfig;
- std::map<int64_t, struct conf::ZoneConfig> zoneConfig;
+ std::map<int64_t, conf::ZoneConfig> zoneConfig;
auto j2 = R"(
{