From fdc0f89a4a56e22828de5d87e60d953ee61326ce Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 2 Dec 2022 18:45:33 -0800 Subject: [PATCH] init: Convert a single-element array into a scalar Simplify PollIn() by converting a single-element array into a scalar. No functionality is changed. Change-Id: I3ef36b9c0daafeed3a92f90c7a7c4fe0654dd586 Signed-off-by: Bart Van Assche --- init/property_service.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/init/property_service.cpp b/init/property_service.cpp index f3550a126..22b66a92d 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -320,13 +320,13 @@ class SocketConnection { private: bool PollIn(uint32_t* timeout_ms) { - struct pollfd ufds[1]; - ufds[0].fd = socket_; - ufds[0].events = POLLIN; - ufds[0].revents = 0; + struct pollfd ufd = { + .fd = socket_, + .events = POLLIN, + }; while (*timeout_ms > 0) { auto start_time = std::chrono::steady_clock::now(); - int nr = poll(ufds, 1, *timeout_ms); + int nr = poll(&ufd, 1, *timeout_ms); auto now = std::chrono::steady_clock::now(); auto time_elapsed = std::chrono::duration_cast(now - start_time);