system/{Event,Signal}FD: pass std::span to FileDescriptor::Read()

This commit is contained in:
Max Kellermann 2024-11-13 10:43:03 +01:00
parent 77226bc0d8
commit 16604997d6
2 changed files with 4 additions and 2 deletions

View File

@ -3,6 +3,7 @@
#include "EventFD.hxx" #include "EventFD.hxx"
#include "system/Error.hxx" #include "system/Error.hxx"
#include "util/SpanCast.hxx"
#include <cassert> #include <cassert>
@ -31,5 +32,5 @@ EventFD::Write() noexcept
static constexpr eventfd_t value = 1; static constexpr eventfd_t value = 1;
[[maybe_unused]] ssize_t nbytes = [[maybe_unused]] ssize_t nbytes =
fd.Write(&value, sizeof(value)); fd.Write(ReferenceAsBytes(value));
} }

View File

@ -3,6 +3,7 @@
#include "SignalFD.hxx" #include "SignalFD.hxx"
#include "Error.hxx" #include "Error.hxx"
#include "util/SpanCast.hxx"
#include <cassert> #include <cassert>
@ -28,7 +29,7 @@ SignalFD::Read() noexcept
assert(fd.IsDefined()); assert(fd.IsDefined());
signalfd_siginfo info; signalfd_siginfo info;
return fd.Read(&info, sizeof(info)) > 0 return fd.Read(ReferenceAsWritableBytes(info)) > 0
? info.ssi_signo ? info.ssi_signo
: -1; : -1;
} }