Add clang-format to repo
Add clang-format to repo.
Change-Id: I5cc1e4ed3fcbf41a28e16cf929a86cf54a3c5efb
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/inc/common.hpp b/inc/common.hpp
index 387b626..82746ee 100644
--- a/inc/common.hpp
+++ b/inc/common.hpp
@@ -15,6 +15,11 @@
*/
#pragma once
+
+#include <systemd/sd-event.h>
+
+#include <memory>
+
struct EventDeleter
{
void operator()(sd_event* event) const
@@ -22,4 +27,4 @@
event = sd_event_unref(event);
}
};
-using EventPtr = std::unique_ptr<sd_event, EventDeleter>;
\ No newline at end of file
+using EventPtr = std::unique_ptr<sd_event, EventDeleter>;
diff --git a/inc/gpio.hpp b/inc/gpio.hpp
index 6387c93..98df21b 100644
--- a/inc/gpio.hpp
+++ b/inc/gpio.hpp
@@ -14,5 +14,8 @@
// limitations under the License.
*/
#pragma once
+
+#include <sdbusplus/bus.hpp>
+
int configGpio(const char* gpioName, int* fd, sdbusplus::bus::bus& bus);
-void closeGpio(int fd);
\ No newline at end of file
+void closeGpio(int fd);
diff --git a/inc/id_button.hpp b/inc/id_button.hpp
index cc664b2..a5c4180 100644
--- a/inc/id_button.hpp
+++ b/inc/id_button.hpp
@@ -15,22 +15,23 @@
*/
#pragma once
-#include <phosphor-logging/elog-errors.hpp>
-#include <unistd.h>
-#include "xyz/openbmc_project/Chassis/Common/error.hpp"
-#include "xyz/openbmc_project/Chassis/Buttons/ID/server.hpp"
#include "common.hpp"
#include "gpio.hpp"
+#include "xyz/openbmc_project/Chassis/Buttons/ID/server.hpp"
+#include "xyz/openbmc_project/Chassis/Common/error.hpp"
-const static constexpr char *ID_BUTTON = "ID_BTN";
+#include <unistd.h>
+
+#include <phosphor-logging/elog-errors.hpp>
+
+const static constexpr char* ID_BUTTON = "ID_BTN";
struct IDButton
: sdbusplus::server::object::object<
- sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::ID>
+ sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::ID>
{
- IDButton(sdbusplus::bus::bus& bus, const char* path,
- EventPtr& event,
+ IDButton(sdbusplus::bus::bus& bus, const char* path, EventPtr& event,
sd_event_io_handler_t handler = IDButton::EventHandler) :
sdbusplus::server::object::object<
sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::ID>(
@@ -46,8 +47,8 @@
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"ID_BUTTON: failed to config GPIO");
- throw sdbusplus::xyz::openbmc_project::Chassis::Common::
- Error::IOError();
+ throw sdbusplus::xyz::openbmc_project::Chassis::Common::Error::
+ IOError();
}
ret = sd_event_add_io(event.get(), nullptr, fd, EPOLLPRI,
@@ -57,8 +58,8 @@
phosphor::logging::log<phosphor::logging::level::ERR>(
"ID_BUTTON: failed to add to event loop");
::closeGpio(fd);
- throw sdbusplus::xyz::openbmc_project::Chassis::Common::
- Error::IOError();
+ throw sdbusplus::xyz::openbmc_project::Chassis::Common::Error::
+ IOError();
}
}
@@ -69,8 +70,8 @@
void simPress() override;
- static int EventHandler(sd_event_source* es, int fd,
- uint32_t revents, void* userdata)
+ static int EventHandler(sd_event_source* es, int fd, uint32_t revents,
+ void* userdata)
{
int n = -1;
@@ -80,8 +81,8 @@
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"ID_BUTTON: userdata null!");
- throw sdbusplus::xyz::openbmc_project::Chassis::Common::
- Error::IOError();
+ throw sdbusplus::xyz::openbmc_project::Chassis::Common::Error::
+ IOError();
}
IDButton* idButton = static_cast<IDButton*>(userdata);
@@ -90,8 +91,8 @@
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"ID_BUTTON: null pointer!");
- throw sdbusplus::xyz::openbmc_project::Chassis::Common::
- Error::IOError();
+ throw sdbusplus::xyz::openbmc_project::Chassis::Common::Error::
+ IOError();
}
n = ::lseek(fd, 0, SEEK_SET);
@@ -100,8 +101,8 @@
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"ID_BUTTON: lseek error!");
- throw sdbusplus::xyz::openbmc_project::Chassis::Common::
- Error::IOError();
+ throw sdbusplus::xyz::openbmc_project::Chassis::Common::Error::
+ IOError();
}
n = ::read(fd, &buf, sizeof(buf));
@@ -109,8 +110,8 @@
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"ID_BUTTON: read error!");
- throw sdbusplus::xyz::openbmc_project::Chassis::Common::
- Error::IOError();
+ throw sdbusplus::xyz::openbmc_project::Chassis::Common::Error::
+ IOError();
}
if (buf == '0')
diff --git a/inc/power_button.hpp b/inc/power_button.hpp
index 94d15c6..d00f1c6 100644
--- a/inc/power_button.hpp
+++ b/inc/power_button.hpp
@@ -15,12 +15,14 @@
*/
#pragma once
-#include <phosphor-logging/elog-errors.hpp>
-#include <unistd.h>
-#include "xyz/openbmc_project/Chassis/Common/error.hpp"
-#include "xyz/openbmc_project/Chassis/Buttons/Power/server.hpp"
#include "common.hpp"
#include "gpio.hpp"
+#include "xyz/openbmc_project/Chassis/Buttons/Power/server.hpp"
+#include "xyz/openbmc_project/Chassis/Common/error.hpp"
+
+#include <unistd.h>
+
+#include <phosphor-logging/elog-errors.hpp>
const static constexpr char* POWER_BUTTON = "POWER_BUTTON";
@@ -29,8 +31,7 @@
sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Power>
{
- PowerButton(sdbusplus::bus::bus& bus, const char* path,
- EventPtr& event,
+ PowerButton(sdbusplus::bus::bus& bus, const char* path, EventPtr& event,
sd_event_io_handler_t handler = PowerButton::EventHandler) :
sdbusplus::server::object::object<
sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Power>(
@@ -46,8 +47,8 @@
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"POWER_BUTTON: failed to config GPIO");
- throw sdbusplus::xyz::openbmc_project::Chassis::Common::
- Error::IOError();
+ throw sdbusplus::xyz::openbmc_project::Chassis::Common::Error::
+ IOError();
}
ret = sd_event_add_io(event.get(), nullptr, fd, EPOLLPRI,
@@ -57,8 +58,8 @@
phosphor::logging::log<phosphor::logging::level::ERR>(
"POWER_BUTTON: failed to add to event loop");
::closeGpio(fd);
- throw sdbusplus::xyz::openbmc_project::Chassis::Common::
- Error::IOError();
+ throw sdbusplus::xyz::openbmc_project::Chassis::Common::Error::
+ IOError();
}
}
@@ -70,8 +71,8 @@
void simPress() override;
void simLongPress() override;
- static int EventHandler(sd_event_source* es, int fd,
- uint32_t revents, void* userdata)
+ static int EventHandler(sd_event_source* es, int fd, uint32_t revents,
+ void* userdata)
{
int n = -1;
@@ -81,8 +82,8 @@
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"POWER_BUTTON: userdata null!");
- throw sdbusplus::xyz::openbmc_project::Chassis::Common::
- Error::IOError();
+ throw sdbusplus::xyz::openbmc_project::Chassis::Common::Error::
+ IOError();
}
PowerButton* powerButton = static_cast<PowerButton*>(userdata);
@@ -91,8 +92,8 @@
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"POWER_BUTTON: null pointer!");
- throw sdbusplus::xyz::openbmc_project::Chassis::Common::
- Error::IOError();
+ throw sdbusplus::xyz::openbmc_project::Chassis::Common::Error::
+ IOError();
}
n = ::lseek(fd, 0, SEEK_SET);
@@ -101,8 +102,8 @@
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"POWER_BUTTON: lseek error!");
- throw sdbusplus::xyz::openbmc_project::Chassis::Common::
- Error::IOError();
+ throw sdbusplus::xyz::openbmc_project::Chassis::Common::Error::
+ IOError();
}
n = ::read(fd, &buf, sizeof(buf));
@@ -110,8 +111,8 @@
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"POWER_BUTTON: read error!");
- throw sdbusplus::xyz::openbmc_project::Chassis::Common::
- Error::IOError();
+ throw sdbusplus::xyz::openbmc_project::Chassis::Common::Error::
+ IOError();
}
if (buf == '0')
diff --git a/inc/reset_button.hpp b/inc/reset_button.hpp
index 8cf0545..b10f241 100644
--- a/inc/reset_button.hpp
+++ b/inc/reset_button.hpp
@@ -15,12 +15,14 @@
*/
#pragma once
-#include <phosphor-logging/elog-errors.hpp>
-#include <unistd.h>
-#include "xyz/openbmc_project/Chassis/Common/error.hpp"
-#include "xyz/openbmc_project/Chassis/Buttons/Reset/server.hpp"
#include "common.hpp"
#include "gpio.hpp"
+#include "xyz/openbmc_project/Chassis/Buttons/Reset/server.hpp"
+#include "xyz/openbmc_project/Chassis/Common/error.hpp"
+
+#include <unistd.h>
+
+#include <phosphor-logging/elog-errors.hpp>
const static constexpr char* RESET_BUTTON = "RESET_BUTTON";
@@ -29,8 +31,7 @@
sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Reset>
{
- ResetButton(sdbusplus::bus::bus& bus, const char* path,
- EventPtr& event,
+ ResetButton(sdbusplus::bus::bus& bus, const char* path, EventPtr& event,
sd_event_io_handler_t handler = ResetButton::EventHandler) :
sdbusplus::server::object::object<
sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::Reset>(
@@ -46,8 +47,8 @@
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"RESET_BUTTON: failed to config GPIO");
- throw sdbusplus::xyz::openbmc_project::Chassis::Common::
- Error::IOError();
+ throw sdbusplus::xyz::openbmc_project::Chassis::Common::Error::
+ IOError();
}
ret = sd_event_add_io(event.get(), nullptr, fd, EPOLLPRI,
@@ -57,8 +58,8 @@
phosphor::logging::log<phosphor::logging::level::ERR>(
"RESET_BUTTON: failed to add to event loop");
::closeGpio(fd);
- throw sdbusplus::xyz::openbmc_project::Chassis::Common::
- Error::IOError();
+ throw sdbusplus::xyz::openbmc_project::Chassis::Common::Error::
+ IOError();
}
}
@@ -69,8 +70,8 @@
void simPress() override;
- static int EventHandler(sd_event_source* es, int fd,
- uint32_t revents, void* userdata)
+ static int EventHandler(sd_event_source* es, int fd, uint32_t revents,
+ void* userdata)
{
int n = -1;
@@ -80,8 +81,8 @@
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"RESET_BUTTON: userdata null!");
- throw sdbusplus::xyz::openbmc_project::Chassis::Common::
- Error::IOError();
+ throw sdbusplus::xyz::openbmc_project::Chassis::Common::Error::
+ IOError();
}
ResetButton* resetButton = static_cast<ResetButton*>(userdata);
@@ -90,8 +91,8 @@
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"RESET_BUTTON: null pointer!");
- throw sdbusplus::xyz::openbmc_project::Chassis::Common::
- Error::IOError();
+ throw sdbusplus::xyz::openbmc_project::Chassis::Common::Error::
+ IOError();
}
n = ::lseek(fd, 0, SEEK_SET);
@@ -100,8 +101,8 @@
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"RESET_BUTTON: lseek error!");
- throw sdbusplus::xyz::openbmc_project::Chassis::Common::
- Error::IOError();
+ throw sdbusplus::xyz::openbmc_project::Chassis::Common::Error::
+ IOError();
}
n = ::read(fd, &buf, sizeof(buf));
@@ -109,8 +110,8 @@
{
phosphor::logging::log<phosphor::logging::level::ERR>(
"RESET_BUTTON: read error!");
- throw sdbusplus::xyz::openbmc_project::Chassis::Common::
- Error::IOError();
+ throw sdbusplus::xyz::openbmc_project::Chassis::Common::Error::
+ IOError();
}
if (buf == '0')