diff options
| author | Tom Englund <tomenglund26@gmail.com> | 2026-04-05 15:45:27 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-05 14:45:27 +0100 |
| commit | 3af9b108909ee1e138cb8b3b6659563ab763e038 (patch) | |
| tree | e76045229a67423fbba4902c46232278cff2e8f6 /start | |
| parent | 3a7bd8fea2ca9711da5523dc185c05ea30ec0f35 (diff) | |
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.
Diffstat (limited to 'start')
| -rw-r--r-- | start/src/core/Instance.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
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<char, 1024> 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]}; |
