libhealthloop: Use designated initializers
Make the code somewhat easier to read by using designated initializers.
No functionality has been changed.
Bug: 362986353
Change-Id: I707ea158c9c45eeb2662d7b5c1efc9b63f0375cb
Signed-off-by: Bart Van Assche <bvanassche@google.com>
diff --git a/health/utils/libhealthloop/HealthLoop.cpp b/health/utils/libhealthloop/HealthLoop.cpp
index 12c8b34..691d896 100644
--- a/health/utils/libhealthloop/HealthLoop.cpp
+++ b/health/utils/libhealthloop/HealthLoop.cpp
@@ -63,14 +63,13 @@
EventHandler{this, fd, std::move(func)}))
.get();
- struct epoll_event ev;
-
- ev.events = EPOLLIN;
+ struct epoll_event ev = {
+ .events = EPOLLIN,
+ .data.ptr = reinterpret_cast<void*>(event_handler),
+ };
if (wakeup == EVENT_WAKEUP_FD) ev.events |= EPOLLWAKEUP;
- ev.data.ptr = reinterpret_cast<void*>(event_handler);
-
if (epoll_ctl(epollfd_, EPOLL_CTL_ADD, fd, &ev) == -1) {
KLOG_ERROR(LOG_TAG, "epoll_ctl failed; errno=%d\n", errno);
return -1;