From 3af9b108909ee1e138cb8b3b6659563ab763e038 Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Sun, 5 Apr 2026 15:45:27 +0200 Subject: internal: silence compiler warnings about unused return values (#13997) * misc: silence warnings about ignoring return value on reads silence warnings on ignored return values on read() and print an error if it occurs. * misc: silence warnings about ignoring return value on writes silence warnings on ignored return values on write() and print an error where we can, or pass them the maybe_unused attribute. * misc: silence warnings about ignoring return value on pipe silence warnings on ignored return value on pipe(), print an error and exit on failure. --- start/src/core/Instance.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'start/src/core/Instance.cpp') diff --git a/start/src/core/Instance.cpp b/start/src/core/Instance.cpp index 2f5007bd..ef758422 100644 --- a/start/src/core/Instance.cpp +++ b/start/src/core/Instance.cpp @@ -81,7 +81,8 @@ void CHyprlandInstance::runHyprlandThread(bool safeMode) { break; } - write(m_wakeupWrite.get(), "vax", 3); + if (write(m_wakeupWrite.get(), "vax", 3) < 0) + g_logger->log(Hyprutils::CLI::LOG_ERR, "Failed to write to wakeup fd {}: {}", m_wakeupWrite.get(), strerror(errno)); std::fflush(stdout); std::fflush(stderr); @@ -96,8 +97,14 @@ void CHyprlandInstance::forceQuit() { } void CHyprlandInstance::clearFd(const Hyprutils::OS::CFileDescriptor& fd) { + if (!fd.isReadable()) { + g_logger->log(Hyprutils::CLI::LOG_ERR, "Can't clear a unreadable fd"); + return; + } + static std::array buf; - read(fd.get(), buf.data(), 1023); + if (read(fd.get(), buf.data(), 1023) < 0) + g_logger->log(Hyprutils::CLI::LOG_ERR, "Failed clearing fd {}: {}", fd.get(), strerror(errno)); } void CHyprlandInstance::dispatchHyprlandEvent() { @@ -132,12 +139,18 @@ void CHyprlandInstance::dispatchHyprlandEvent() { bool CHyprlandInstance::run(bool safeMode) { int pipefds[2]; - pipe(pipefds); + if (pipe(pipefds) != 0) { + g_logger->log(Hyprutils::CLI::LOG_ERR, "pipe() failed, exiting"); + exit(1); + } m_fromHlPid = CFileDescriptor{pipefds[0]}; m_toHlPid = CFileDescriptor{pipefds[1]}; - pipe(pipefds); + if (pipe(pipefds) != 0) { + g_logger->log(Hyprutils::CLI::LOG_ERR, "pipe() failed, exiting"); + exit(1); + } m_wakeupRead = CFileDescriptor{pipefds[0]}; m_wakeupWrite = CFileDescriptor{pipefds[1]}; -- cgit v1.2.3