cooling-type: Clang format updates
Used `format-code.sh` build script to make changes to conform to clang
format.
Tested: Compiled
Change-Id: I2294141845790cbb79e599741802bfede574a0b9
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/cooling-type/argument.cpp b/cooling-type/argument.cpp
index 2c54f75..7d03453 100644
--- a/cooling-type/argument.cpp
+++ b/cooling-type/argument.cpp
@@ -13,11 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <iostream>
-#include <iterator>
+#include "argument.hpp"
+
#include <algorithm>
#include <cassert>
-#include "argument.hpp"
+#include <iostream>
+#include <iterator>
namespace phosphor
{
@@ -71,30 +72,30 @@
std::cerr << "Options:\n";
std::cerr << " --help print this menu\n";
std::cerr << " --air Force 'AirCooled' property to be set"
- " to true.\n";
+ " to true.\n";
std::cerr << " --water Force 'WaterCooled' property to be "
- "set to true.\n";
+ "set to true.\n";
std::cerr << " --dev=<pin> Device to read for GPIO pin state to"
- " determine 'WaterCooled' (true) and 'AirCooled' (false)\n";
+ " determine 'WaterCooled' (true) and 'AirCooled' (false)\n";
std::cerr << " --event=<keycode> Keycode for pin to read\n";
- std::cerr <<
- " --path=<objpath> *Required* object path under inventory "
- "to have CoolingType updated\n";
- std::cerr << "\nThe --air / --water options may be given in addition to "
- "--gpio, in which case both their setting and the GPIO will take "
- "effect.\n";
+ std::cerr
+ << " --path=<objpath> *Required* object path under inventory "
+ "to have CoolingType updated\n";
+ std::cerr
+ << "\nThe --air / --water options may be given in addition to "
+ "--gpio, in which case both their setting and the GPIO will take "
+ "effect.\n";
std::cerr << std::flush;
}
-const option ArgumentParser::options[] =
-{
- { "path", required_argument, NULL, 'p' },
- { "dev", required_argument, NULL, 'd' },
- { "event", required_argument, NULL, 'e' },
- { "air", no_argument, NULL, 'a' },
- { "water", no_argument, NULL, 'w' },
- { "help", no_argument, NULL, 'h' },
- { 0, 0, 0, 0},
+const option ArgumentParser::options[] = {
+ {"path", required_argument, NULL, 'p'},
+ {"dev", required_argument, NULL, 'd'},
+ {"event", required_argument, NULL, 'e'},
+ {"air", no_argument, NULL, 'a'},
+ {"water", no_argument, NULL, 'w'},
+ {"help", no_argument, NULL, 'h'},
+ {0, 0, 0, 0},
};
const char* ArgumentParser::optionstr = "p:d:e:aw?h";
@@ -102,7 +103,7 @@
const std::string ArgumentParser::true_string = "true";
const std::string ArgumentParser::empty_string = "";
-}
-}
-}
+} // namespace util
+} // namespace fan
+} // namespace phosphor
// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
diff --git a/cooling-type/cooling_type.cpp b/cooling-type/cooling_type.cpp
index ae81ee6..d996230 100644
--- a/cooling-type/cooling_type.cpp
+++ b/cooling-type/cooling_type.cpp
@@ -1,14 +1,17 @@
-#include <fcntl.h>
-#include <unistd.h>
-#include <sdbusplus/bus.hpp>
-#include <phosphor-logging/log.hpp>
-#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/elog-errors.hpp>
-#include <xyz/openbmc_project/Common/error.hpp>
-#include <libevdev/libevdev.h>
-#include "utility.hpp"
#include "cooling_type.hpp"
+
#include "sdbusplus.hpp"
+#include "utility.hpp"
+
+#include <fcntl.h>
+#include <libevdev/libevdev.h>
+#include <unistd.h>
+
+#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/log.hpp>
+#include <sdbusplus/bus.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
namespace phosphor
{
@@ -19,10 +22,10 @@
// For throwing exception
using namespace phosphor::logging;
-using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
- Error::InternalFailure;
+using InternalFailure =
+ sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
-std::unique_ptr<libevdev, FreeEvDev> evdevOpen(int fd)
+std::unique_ptr<libevdev, FreeEvDev> evdevOpen(int fd)
{
libevdev* gpioDev = nullptr;
@@ -33,7 +36,7 @@
}
log<level::ERR>("Failed to get libevdev from file descriptor",
- entry("RC=%d", rc));
+ entry("RC=%d", rc));
elog<InternalFailure>();
return decltype(evdevOpen(0))(nullptr);
}
@@ -57,13 +60,13 @@
auto gpioDev = evdevOpen(gpioFd());
int value = 0;
- auto fetch_rc = libevdev_fetch_event_value(gpioDev.get(), EV_KEY,
- keycode, &value);
+ auto fetch_rc =
+ libevdev_fetch_event_value(gpioDev.get(), EV_KEY, keycode, &value);
if (0 == fetch_rc)
{
- log<level::ERR>("Device does not support event type",
- entry("KEYCODE=%d", keycode));
- elog<InternalFailure>();
+ log<level::ERR>("Device does not support event type",
+ entry("KEYCODE=%d", keycode));
+ elog<InternalFailure>();
}
// TODO openbmc/phosphor-fan-presence#6
@@ -75,7 +78,6 @@
{
setWaterCooled();
}
-
}
CoolingType::ObjectMap CoolingType::getObjectMap(const std::string& objpath)
@@ -101,14 +103,11 @@
// Update inventory
auto invMgrResponseMsg = util::SDBusPlus::lookupAndCallMethod(
- bus,
- util::INVENTORY_PATH,
- util::INVENTORY_INTF,
- "Notify",
- std::move(invObj));
+ bus, util::INVENTORY_PATH, util::INVENTORY_INTF, "Notify",
+ std::move(invObj));
}
-}
-}
-}
+} // namespace type
+} // namespace cooling
+} // namespace phosphor
// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
diff --git a/cooling-type/cooling_type.hpp b/cooling-type/cooling_type.hpp
index 5108eeb..2622f6c 100644
--- a/cooling-type/cooling_type.hpp
+++ b/cooling-type/cooling_type.hpp
@@ -1,5 +1,6 @@
#pragma once
#include "utility.hpp"
+
#include <libevdev/libevdev.h>
namespace phosphor
@@ -19,78 +20,77 @@
class CoolingType
{
- using Property = std::string;
- using Value = std::variant<bool>;
- // Association between property and its value
- using PropertyMap = std::map<Property, Value>;
- using Interface = std::string;
- // Association between interface and the dbus property
- using InterfaceMap = std::map<Interface, PropertyMap>;
- using Object = sdbusplus::message::object_path;
- // Association between object and the interface
- using ObjectMap = std::map<Object, InterfaceMap>;
+ using Property = std::string;
+ using Value = std::variant<bool>;
+ // Association between property and its value
+ using PropertyMap = std::map<Property, Value>;
+ using Interface = std::string;
+ // Association between interface and the dbus property
+ using InterfaceMap = std::map<Interface, PropertyMap>;
+ using Object = sdbusplus::message::object_path;
+ // Association between object and the interface
+ using ObjectMap = std::map<Object, InterfaceMap>;
- public:
- CoolingType() = delete;
- ~CoolingType() = default;
- CoolingType(const CoolingType&) = delete;
- CoolingType(CoolingType&&) = default;
- CoolingType& operator=(const CoolingType&) = delete;
- CoolingType& operator=(CoolingType&&) = default;
+ public:
+ CoolingType() = delete;
+ ~CoolingType() = default;
+ CoolingType(const CoolingType&) = delete;
+ CoolingType(CoolingType&&) = default;
+ CoolingType& operator=(const CoolingType&) = delete;
+ CoolingType& operator=(CoolingType&&) = default;
- /**
- * @brief Constructs Cooling Type Object
- *
- * @param[in] bus - Dbus bus object
- */
- CoolingType(sdbusplus::bus::bus& bus) : bus(bus)
- {
- //TODO: Issue openbmc/openbmc#1531 - means to default properties.
- }
+ /**
+ * @brief Constructs Cooling Type Object
+ *
+ * @param[in] bus - Dbus bus object
+ */
+ CoolingType(sdbusplus::bus::bus& bus) : bus(bus)
+ {
+ // TODO: Issue openbmc/openbmc#1531 - means to default properties.
+ }
- /**
- * @brief Sets airCooled to true.
- */
- void setAirCooled();
- /**
- * @brief Sets waterCooled to true.
- */
- void setWaterCooled();
- /**
- * @brief Updates the inventory properties for CoolingType.
- *
- * @param[in] path - Path to object to update
- */
- void updateInventory(const std::string& path);
- /**
- * @brief Setup and read the GPIO device for reading cooling type.
- *
- * @param[in] path - Path to the GPIO device file to read
- * @param[in] pin - Event/key code to read (pin)
- */
- void readGpio(const std::string& path, unsigned int pin);
+ /**
+ * @brief Sets airCooled to true.
+ */
+ void setAirCooled();
+ /**
+ * @brief Sets waterCooled to true.
+ */
+ void setWaterCooled();
+ /**
+ * @brief Updates the inventory properties for CoolingType.
+ *
+ * @param[in] path - Path to object to update
+ */
+ void updateInventory(const std::string& path);
+ /**
+ * @brief Setup and read the GPIO device for reading cooling type.
+ *
+ * @param[in] path - Path to the GPIO device file to read
+ * @param[in] pin - Event/key code to read (pin)
+ */
+ void readGpio(const std::string& path, unsigned int pin);
- private:
- /** @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;
- bool airCooled = false;
- bool waterCooled = false;
+ private:
+ /** @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;
+ bool airCooled = false;
+ bool waterCooled = false;
- /**
- * @brief Construct the inventory object map for CoolingType.
- *
- * @param[in] objpath - Path to object to update
- *
- * @return The inventory object map to update inventory
- */
- ObjectMap getObjectMap(const std::string& objpath);
-
+ /**
+ * @brief Construct the inventory object map for CoolingType.
+ *
+ * @param[in] objpath - Path to object to update
+ *
+ * @return The inventory object map to update inventory
+ */
+ ObjectMap getObjectMap(const std::string& objpath);
};
-}
-}
-}
+} // namespace type
+} // namespace cooling
+} // namespace phosphor
// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
diff --git a/cooling-type/main.cpp b/cooling-type/main.cpp
index 3aa7d28..6c3b199 100644
--- a/cooling-type/main.cpp
+++ b/cooling-type/main.cpp
@@ -1,11 +1,13 @@
-#include <iostream>
-#include <memory>
-#include <sdbusplus/bus.hpp>
-#include <phosphor-logging/log.hpp>
#include "argument.hpp"
#include "cooling_type.hpp"
#include "sdbusplus.hpp"
+#include <phosphor-logging/log.hpp>
+#include <sdbusplus/bus.hpp>
+
+#include <iostream>
+#include <memory>
+
using namespace phosphor::cooling::type;
using namespace phosphor::fan::util;
using namespace phosphor::logging;
@@ -67,16 +69,15 @@
catch (DBusMethodError& dme)
{
log<level::ERR>("Uncaught DBus method failure exception",
- entry("BUSNAME=%s", dme.busName.c_str()),
- entry("PATH=%s", dme.path.c_str()),
- entry("INTERFACE=%s", dme.interface.c_str()),
- entry("METHOD=%s", dme.method.c_str()));
+ entry("BUSNAME=%s", dme.busName.c_str()),
+ entry("PATH=%s", dme.path.c_str()),
+ entry("INTERFACE=%s", dme.interface.c_str()),
+ entry("METHOD=%s", dme.method.c_str()));
}
catch (std::exception& err)
{
log<phosphor::logging::level::ERR>(err.what());
}
-
}
return rc;