mirror of
https://github.com/hyprwm/Hyprland
synced 2026-05-07 07:18:02 +02:00
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.
This commit is contained in:
parent
3a7bd8fea2
commit
3af9b10890
6 changed files with 36 additions and 14 deletions
|
|
@ -117,8 +117,8 @@ static void handleUnrecoverableSignal(int sig) {
|
|||
|
||||
// Kill the program if the crash-reporter is caught in a deadlock.
|
||||
signal(SIGALRM, [](int _) {
|
||||
char const* msg = "\nCrashReporter exceeded timeout, forcefully exiting\n";
|
||||
write(2, msg, strlen(msg));
|
||||
char const* msg = "\nCrashReporter exceeded timeout, forcefully exiting\n";
|
||||
[[maybe_unused]] auto w = write(2, msg, strlen(msg));
|
||||
abort();
|
||||
});
|
||||
alarm(15);
|
||||
|
|
@ -550,8 +550,8 @@ void CCompositor::cleanup() {
|
|||
if (!m_wlDisplay)
|
||||
return;
|
||||
|
||||
if (m_watchdogWriteFd.isValid())
|
||||
write(m_watchdogWriteFd.get(), "end", 3);
|
||||
if (m_watchdogWriteFd.isValid()) [[maybe_unused]]
|
||||
auto w = write(m_watchdogWriteFd.get(), "end", 3);
|
||||
|
||||
signal(SIGABRT, SIG_DFL);
|
||||
signal(SIGSEGV, SIG_DFL);
|
||||
|
|
@ -803,8 +803,10 @@ void CCompositor::startCompositor() {
|
|||
|
||||
Event::bus()->m_events.ready.emit();
|
||||
|
||||
if (m_watchdogWriteFd.isValid())
|
||||
write(m_watchdogWriteFd.get(), "vax", 3);
|
||||
if (m_watchdogWriteFd.isValid()) {
|
||||
if (write(m_watchdogWriteFd.get(), "vax", 3) < 0)
|
||||
Log::logger->log(Log::ERR, "startCompositor: failed to write to watchdogWriteFd {}: {}", m_watchdogWriteFd.get(), strerror(errno));
|
||||
}
|
||||
|
||||
// This blocks until we are done.
|
||||
Log::logger->log(Log::DEBUG, "Hyprland is ready, running the event loop!");
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ static char const* getRandomMessage() {
|
|||
}
|
||||
|
||||
[[noreturn]] static inline void exitWithError(char const* err) {
|
||||
write(STDERR_FILENO, err, strlen(err));
|
||||
[[maybe_unused]] auto w = write(STDERR_FILENO, err, strlen(err));
|
||||
// perror() is not signal-safe, but we use it here
|
||||
// because if the crash-handler already crashed, it can't get any worse.
|
||||
perror("");
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "MainLoopExecutor.hpp"
|
||||
#include "../managers/eventLoop/EventLoopManager.hpp"
|
||||
#include "../macros.hpp"
|
||||
#include <cstring>
|
||||
#include <unistd.h>
|
||||
|
||||
static int onDataRead(int fd, uint32_t mask, void* data) {
|
||||
|
|
@ -26,7 +27,8 @@ CMainLoopExecutor::~CMainLoopExecutor() {
|
|||
|
||||
void CMainLoopExecutor::signal() {
|
||||
const char* amogus = "h";
|
||||
write(m_writeFd.get(), amogus, 1);
|
||||
if (write(m_writeFd.get(), amogus, 1) < 0)
|
||||
Log::logger->log(Log::ERR, "signal: failed to write to fd {}: {}", m_writeFd.get(), strerror(errno));
|
||||
}
|
||||
|
||||
void CMainLoopExecutor::onFired() {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "../../config/shared/inotify/ConfigWatcher.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <ranges>
|
||||
|
||||
|
|
@ -41,7 +42,8 @@ static int timerWrite(int fd, uint32_t mask, void* data) {
|
|||
Log::logger->log(Log::ERR, "timerWrite: triggered a non readable event on fd : {}", fd);
|
||||
else {
|
||||
uint64_t expirations;
|
||||
read(fd, &expirations, sizeof(expirations));
|
||||
if (read(fd, &expirations, sizeof(expirations)) < 0)
|
||||
Log::logger->log(Log::ERR, "timerWrite: read failed on fd {}: {}", fd, strerror(errno));
|
||||
}
|
||||
|
||||
g_pEventLoopManager->onTimerFire();
|
||||
|
|
|
|||
|
|
@ -222,7 +222,10 @@ bool CXWaylandServer::tryOpenSockets() {
|
|||
continue;
|
||||
|
||||
char pidstr[12] = {0};
|
||||
read(fd.get(), pidstr, sizeof(pidstr) - 1);
|
||||
if (read(fd.get(), pidstr, sizeof(pidstr) - 1) < 0) {
|
||||
Log::logger->log(Log::ERR, "Failed to read on fd {}: {}", fd.get(), strerror(errno));
|
||||
continue;
|
||||
}
|
||||
|
||||
int32_t pid = 0;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -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]};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue