From a1c8a622b25ea742a340453d1a9ed527081b5bca Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 14 Oct 2022 09:41:17 -0700 Subject: [PATCH] init/epoll: Switch to aggregate initialization Make it easier to verify for humans that all data structure members are initialized. No functionality is changed. Bug: 213617178 Change-Id: I1ce2af566dba51f2032f2e7518576a67e666d12e Signed-off-by: Bart Van Assche --- init/epoll.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/init/epoll.cpp b/init/epoll.cpp index dc2104313..3a830ce25 100644 --- a/init/epoll.cpp +++ b/init/epoll.cpp @@ -45,16 +45,18 @@ Result Epoll::RegisterHandler(int fd, Handler handler, uint32_t events) { return Error() << "Must specify events"; } - Info info; - info.events = events; - info.handler = std::make_shared(std::move(handler)); - auto [it, inserted] = epoll_handlers_.emplace(fd, std::move(info)); + auto [it, inserted] = epoll_handlers_.emplace( + fd, Info{ + .events = events, + .handler = std::make_shared(std::move(handler)), + }); if (!inserted) { return Error() << "Cannot specify two epoll handlers for a given FD"; } - epoll_event ev; - ev.events = events; - ev.data.fd = fd; + epoll_event ev = { + .events = events, + .data.fd = fd, + }; if (epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, fd, &ev) == -1) { Result result = ErrnoError() << "epoll_ctl failed to add fd"; epoll_handlers_.erase(fd);