init: add [[nodiscard]] to Result
It's better to either check these results or explicitly ignore them.
Only a few callers weren't already doing this, so it's relatively
trivial to enforce.
Test: build
Change-Id: I44cdc342e46128f66cac914aaa0b9b4559cacd8c
diff --git a/init/keychords.cpp b/init/keychords.cpp
index b8c1cfd..f5ac44f 100644
--- a/init/keychords.cpp
+++ b/init/keychords.cpp
@@ -41,7 +41,7 @@
Keychords::~Keychords() noexcept {
if (inotify_fd_ >= 0) {
- epoll_->UnregisterHandler(inotify_fd_);
+ epoll_->UnregisterHandler(inotify_fd_).IgnoreError();
::close(inotify_fd_);
}
while (!registration_.empty()) GeteventCloseDevice(registration_.begin()->first);
@@ -186,7 +186,11 @@
current_ |= mask & available & set;
LambdaCheck();
}
- epoll_->RegisterHandler(fd, [this, fd]() { this->LambdaHandler(fd); });
+ if (auto result = epoll_->RegisterHandler(fd, [this, fd]() { this->LambdaHandler(fd); });
+ !result) {
+ LOG(WARNING) << "Could not register keychord epoll handler: " << result.error();
+ return false;
+ }
return true;
}
@@ -208,7 +212,7 @@
auto it = registration_.find(device);
if (it == registration_.end()) return;
auto fd = (*it).second;
- epoll_->UnregisterHandler(fd);
+ epoll_->UnregisterHandler(fd).IgnoreError();
registration_.erase(it);
::close(fd);
}
@@ -266,7 +270,11 @@
}
if (inotify_fd_ >= 0) {
- epoll_->RegisterHandler(inotify_fd_, [this]() { this->InotifyHandler(); });
+ if (auto result =
+ epoll_->RegisterHandler(inotify_fd_, [this]() { this->InotifyHandler(); });
+ !result) {
+ LOG(WARNING) << "Could not register keychord epoll handler: " << result.error();
+ }
}
}