Skip to content

Commit

Permalink
io/FileDescriptor: remove Read()/Write() with void pointers
Browse files Browse the repository at this point in the history
Obsolete and unsafe.
  • Loading branch information
MaxKellermann committed Nov 13, 2024
1 parent fc1d71e commit 85d5837
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/io/FileDescriptor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void
FileDescriptor::FullRead(std::span<std::byte> dest) const
{
while (!dest.empty()) {
ssize_t nbytes = Read(dest.data(), dest.size());
ssize_t nbytes = Read(dest);
if (nbytes <= 0) {
if (nbytes < 0)
throw MakeErrno("Failed to read");
Expand All @@ -282,7 +282,7 @@ void
FileDescriptor::FullWrite(std::span<const std::byte> src) const
{
while (!src.empty()) {
ssize_t nbytes = Write(src.data(), src.size());
ssize_t nbytes = Write(src);
if (nbytes <= 0) {
if (nbytes < 0)
throw MakeErrno("Failed to write");
Expand Down
10 changes: 0 additions & 10 deletions src/io/FileDescriptor.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,6 @@ public:
return ::read(fd, dest.data(), dest.size());
}

[[nodiscard]]
ssize_t Read(void *buffer, std::size_t length) const noexcept {
return ::read(fd, buffer, length);
}

/**
* Read until all of the given buffer has been filled. Throws
* on error.
Expand All @@ -269,11 +264,6 @@ public:
return ::write(fd, src.data(), src.size());
}

[[nodiscard]]
ssize_t Write(const void *buffer, std::size_t length) const noexcept {
return ::write(fd, buffer, length);
}

/**
* Write until all of the given buffer has been written.
* Throws on error.
Expand Down

0 comments on commit 85d5837

Please sign in to comment.