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 263b991 commit fc4a579
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 13 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
2 changes: 1 addition & 1 deletion src/io/FileOutputStream.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ FileOutputStream::Write(std::span<const std::byte> src)
{
assert(IsDefined());

ssize_t nbytes = fd.Write(src.data(), src.size());
ssize_t nbytes = fd.Write(src);
if (nbytes < 0)
throw FmtErrno("Failed to write to {}", GetPath());
else if ((size_t)nbytes < src.size())
Expand Down

0 comments on commit fc4a579

Please sign in to comment.