Skip to content

Commit b1a9bbc

Browse files
committed
reaper/TreeWatch: use FileDescriptor::ReadAt() instead of pread()
1 parent e240d59 commit b1a9bbc

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

src/reaper/UnifiedWatch.cxx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,21 @@
1010
#include "util/BindMethod.hxx"
1111
#include "util/PrintException.hxx"
1212
#include "util/ScopeExit.hxx"
13+
#include "util/SpanCast.hxx"
1314

1415
#include <algorithm> // for std::binary_search()
1516

16-
#include <fcntl.h> // for AT_FDCWD
17-
#include <stdint.h>
18-
#include <stdio.h>
19-
#include <string.h>
20-
2117
using std::string_view_literals::operator""sv;
2218

2319
static bool
2420
IsPopulated(FileDescriptor fd) noexcept
2521
{
26-
char buffer[4096];
27-
ssize_t nbytes = pread(fd.Get(), buffer, sizeof(buffer), 0);
22+
std::byte buffer[4096];
23+
ssize_t nbytes = fd.ReadAt(0, buffer);
2824
if (nbytes <= 0)
2925
return false;
3026

31-
const std::string_view contents{buffer, static_cast<std::size_t>(nbytes)};
27+
const std::string_view contents = ToStringView(std::span{buffer}.first(nbytes));
3228
return !contents.contains("populated 0"sv);
3329
}
3430

0 commit comments

Comments
 (0)