evdevpp: Clang format updates
Used `format-code.sh` build script to make changes to conform to clang
format.
Tested: Compiled
Change-Id: Idb117c40fa0eeec89863db7040bd08174c07bb33
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/evdevpp/evdev.hpp b/evdevpp/evdev.hpp
index b0ba06e..ae9a370 100644
--- a/evdevpp/evdev.hpp
+++ b/evdevpp/evdev.hpp
@@ -2,13 +2,15 @@
#include <fcntl.h>
#include <libevdev/libevdev.h>
-#include <memory>
-#include <phosphor-logging/elog.hpp>
+#include <unistd.h>
+
#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/elog.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
+
+#include <memory>
#include <string>
#include <tuple>
-#include <unistd.h>
-#include <xyz/openbmc_project/Common/error.hpp>
namespace evdevpp
{
@@ -42,82 +44,81 @@
*/
class EvDev
{
- private:
- using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
- Error::InternalFailure;
+ private:
+ using InternalFailure =
+ sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
- public:
- /* Define all of the basic class operations:
- * Not allowed:
- * - Default constructor to avoid nullptrs.
- * - Copy operations due to internal unique_ptr.
- * Allowed:
- * - Move operations.
- * - Destructor.
- */
- EvDev() = delete;
- EvDev(const EvDev&) = delete;
- EvDev& operator=(const EvDev&) = delete;
- EvDev(EvDev&&) = default;
- EvDev& operator=(EvDev&&) = default;
- ~EvDev() = default;
+ public:
+ /* Define all of the basic class operations:
+ * Not allowed:
+ * - Default constructor to avoid nullptrs.
+ * - Copy operations due to internal unique_ptr.
+ * Allowed:
+ * - Move operations.
+ * - Destructor.
+ */
+ EvDev() = delete;
+ EvDev(const EvDev&) = delete;
+ EvDev& operator=(const EvDev&) = delete;
+ EvDev(EvDev&&) = default;
+ EvDev& operator=(EvDev&&) = default;
+ ~EvDev() = default;
- /** @brief Conversion constructor from evdev. */
- explicit EvDev(EvDevPtr ptr) : evdev(ptr) {}
+ /** @brief Conversion constructor from evdev. */
+ explicit EvDev(EvDevPtr ptr) : evdev(ptr)
+ {}
- /** @brief Get the current event state. */
- auto fetch(unsigned int type, unsigned int code)
+ /** @brief Get the current event state. */
+ auto fetch(unsigned int type, unsigned int code)
+ {
+ int val;
+ auto rc = libevdev_fetch_event_value(evdev.get(), type, code, &val);
+ if (!rc)
{
- int val;
- auto rc = libevdev_fetch_event_value(
- evdev.get(), type, code, &val);
- if (!rc)
+ log<level::ERR>("Error in call to libevdev_fetch_event_value",
+ entry("TYPE=%d", type), entry("CODE=%d", code));
+ elog<InternalFailure>();
+ }
+
+ return val;
+ }
+
+ /** @brief Get the next event. */
+ auto next()
+ {
+ struct input_event ev;
+ while (true)
+ {
+ auto rc = libevdev_next_event(evdev.get(),
+ LIBEVDEV_READ_FLAG_NORMAL, &ev);
+ if (rc < 0)
{
- log<level::ERR>("Error in call to libevdev_fetch_event_value",
- entry("TYPE=%d", type),
- entry("CODE=%d", code));
+ log<level::ERR>("Error in call to libevdev_next_event",
+ entry("RC=%d", rc));
elog<InternalFailure>();
}
- return val;
+ if (ev.type == EV_SYN && ev.code == SYN_REPORT)
+ continue;
+
+ break;
}
+ return std::make_tuple(ev.type, ev.code, ev.value);
+ }
- /** @brief Get the next event. */
- auto next()
- {
- struct input_event ev;
- while (true)
- {
- auto rc = libevdev_next_event(
- evdev.get(), LIBEVDEV_READ_FLAG_NORMAL, &ev);
- if (rc < 0)
- {
- log<level::ERR>("Error in call to libevdev_next_event",
- entry("RC=%d", rc));
- elog<InternalFailure>();
- }
+ private:
+ EvDevPtr get()
+ {
+ return evdev.get();
+ }
- if (ev.type == EV_SYN && ev.code == SYN_REPORT)
- continue;
-
- break;
- }
- return std::make_tuple(ev.type, ev.code, ev.value);
- }
-
- private:
- EvDevPtr get()
- {
- return evdev.get();
- }
-
- details::EvDev evdev;
+ details::EvDev evdev;
};
inline auto newFromFD(int fd)
{
- using InternalFailure = sdbusplus::xyz::openbmc_project::Common::
- Error::InternalFailure;
+ using InternalFailure =
+ sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
EvDevPtr dev = nullptr;
auto rc = libevdev_new_from_fd(fd, &dev);
@@ -125,8 +126,7 @@
if (rc)
{
log<level::ERR>("Error in call to libevdev_new_from_fd",
- entry("RC=%d", rc),
- entry("FD=%d", fd));
+ entry("RC=%d", rc), entry("FD=%d", fd));
elog<InternalFailure>();
}
diff --git a/evdevpp/test/evmon.cpp b/evdevpp/test/evmon.cpp
index 526f759..dca2c00 100644
--- a/evdevpp/test/evmon.cpp
+++ b/evdevpp/test/evmon.cpp
@@ -14,17 +14,18 @@
* limitations under the License.
*/
-#include <algorithm>
-#include <cassert>
-#include <iostream>
-#include <iterator>
-#include <memory>
#include "argument.hpp"
#include "evdevpp/evdev.hpp"
#include "sdevent/event.hpp"
#include "sdevent/io.hpp"
#include "utility.hpp"
+#include <algorithm>
+#include <cassert>
+#include <iostream>
+#include <iterator>
+#include <memory>
+
namespace phosphor
{
namespace fan
@@ -79,12 +80,11 @@
std::cerr << std::flush;
}
-const option ArgumentParser::options[] =
-{
- { "path", required_argument, NULL, 'p' },
- { "type", required_argument, NULL, 't' },
- { "code", required_argument, NULL, 'c' },
- { 0, 0, 0, 0},
+const option ArgumentParser::options[] = {
+ {"path", required_argument, NULL, 'p'},
+ {"type", required_argument, NULL, 't'},
+ {"code", required_argument, NULL, 'c'},
+ {0, 0, 0, 0},
};
const char* ArgumentParser::optionstr = "p:t:c:";
@@ -131,26 +131,20 @@
auto loop = sdevent::event::newDefault();
phosphor::fan::util::FileDescriptor fd(
- open(path.c_str(), O_RDONLY | O_NONBLOCK));
+ open(path.c_str(), O_RDONLY | O_NONBLOCK));
auto evdev = evdevpp::evdev::newFromFD(fd());
- sdevent::event::io::IO callback(
- loop,
- fd(),
- [&evdev](auto& s)
- {
- unsigned int type, code, value;
- std::tie(type, code, value) = evdev.next();
- std::cout <<
- "type: " << libevdev_event_type_get_name(type) <<
- " code: " << libevdev_event_code_get_name(type, code) <<
- " value: " << value << "\n";
- });
+ sdevent::event::io::IO callback(loop, fd(), [&evdev](auto& s) {
+ unsigned int type, code, value;
+ std::tie(type, code, value) = evdev.next();
+ std::cout << "type: " << libevdev_event_type_get_name(type)
+ << " code: " << libevdev_event_code_get_name(type, code)
+ << " value: " << value << "\n";
+ });
auto value = evdev.fetch(type, stoul(scode));
- std::cout <<
- "type: " << libevdev_event_type_get_name(type) <<
- " code: " << libevdev_event_code_get_name(type, stoul(scode)) <<
- " value: " << value << "\n";
+ std::cout << "type: " << libevdev_event_type_get_name(type)
+ << " code: " << libevdev_event_code_get_name(type, stoul(scode))
+ << " value: " << value << "\n";
loop.loop();