From 2285fe0fc6a6bba7c587bec0a1f733b333dc2650 Mon Sep 17 00:00:00 2001 From: Adriana Kobylak Date: Tue, 27 Feb 2018 15:36:59 -0600 Subject: Enable clang code format Change-Id: Ia899858c11cff6e4fa26b820b35b1e5dca1b57df Signed-off-by: Adriana Kobylak --- watch.cpp | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'watch.cpp') diff --git a/watch.cpp b/watch.cpp index c7c3653..a84c5ef 100644 --- a/watch.cpp +++ b/watch.cpp @@ -21,9 +21,8 @@ using namespace phosphor::logging; using namespace std::string_literals; namespace fs = std::experimental::filesystem; -Watch::Watch(sd_event* loop, - std::function imageCallback) : imageCallback( - imageCallback) +Watch::Watch(sd_event* loop, std::function imageCallback) : + imageCallback(imageCallback) { // Check if IMAGE DIR exists. fs::path imgDirPath(IMG_UPLOAD_DIR); @@ -38,8 +37,8 @@ Watch::Watch(sd_event* loop, // Store a copy of errno, because the string creation below will // invalidate errno due to one more system calls. auto error = errno; - throw std::runtime_error( - "inotify_init1 failed, errno="s + std::strerror(error)); + throw std::runtime_error("inotify_init1 failed, errno="s + + std::strerror(error)); } wd = inotify_add_watch(fd, IMG_UPLOAD_DIR, IN_CLOSE_WRITE); @@ -47,20 +46,15 @@ Watch::Watch(sd_event* loop, { auto error = errno; close(fd); - throw std::runtime_error( - "inotify_add_watch failed, errno="s + std::strerror(error)); + throw std::runtime_error("inotify_add_watch failed, errno="s + + std::strerror(error)); } - auto rc = sd_event_add_io(loop, - nullptr, - fd, - EPOLLIN, - callback, - this); + auto rc = sd_event_add_io(loop, nullptr, fd, EPOLLIN, callback, this); if (0 > rc) { - throw std::runtime_error( - "failed to add to event loop, rc="s + std::strerror(-rc)); + throw std::runtime_error("failed to add to event loop, rc="s + + std::strerror(-rc)); } } @@ -73,9 +67,7 @@ Watch::~Watch() } } -int Watch::callback(sd_event_source* s, - int fd, - uint32_t revents, +int Watch::callback(sd_event_source* s, int fd, uint32_t revents, void* userdata) { if (!(revents & EPOLLIN)) @@ -89,8 +81,8 @@ int Watch::callback(sd_event_source* s, if (0 > bytes) { auto error = errno; - throw std::runtime_error( - "failed to read inotify event, errno="s + std::strerror(error)); + throw std::runtime_error("failed to read inotify event, errno="s + + std::strerror(error)); } auto offset = 0; @@ -106,7 +98,6 @@ int Watch::callback(sd_event_source* s, log("Error processing image", entry("IMAGE=%s", tarballPath.c_str())); } - } offset += offsetof(inotify_event, name) + event->len; -- cgit v1.2.1