io/FileDescriptor: remove Read()/Write() with void pointers

Obsolete and unsafe.
This commit is contained in:
Max Kellermann 2024-11-12 08:49:29 +01:00 committed by Max Kellermann
parent 263b9916c2
commit fc4a579d83
3 changed files with 3 additions and 13 deletions

View File

@ -267,7 +267,7 @@ void
FileDescriptor::FullRead(std::span<std::byte> dest) const FileDescriptor::FullRead(std::span<std::byte> dest) const
{ {
while (!dest.empty()) { while (!dest.empty()) {
ssize_t nbytes = Read(dest.data(), dest.size()); ssize_t nbytes = Read(dest);
if (nbytes <= 0) { if (nbytes <= 0) {
if (nbytes < 0) if (nbytes < 0)
throw MakeErrno("Failed to read"); throw MakeErrno("Failed to read");
@ -282,7 +282,7 @@ void
FileDescriptor::FullWrite(std::span<const std::byte> src) const FileDescriptor::FullWrite(std::span<const std::byte> src) const
{ {
while (!src.empty()) { while (!src.empty()) {
ssize_t nbytes = Write(src.data(), src.size()); ssize_t nbytes = Write(src);
if (nbytes <= 0) { if (nbytes <= 0) {
if (nbytes < 0) if (nbytes < 0)
throw MakeErrno("Failed to write"); throw MakeErrno("Failed to write");

View File

@ -246,11 +246,6 @@ public:
return ::read(fd, dest.data(), dest.size()); 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 * Read until all of the given buffer has been filled. Throws
* on error. * on error.
@ -269,11 +264,6 @@ public:
return ::write(fd, src.data(), src.size()); 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. * Write until all of the given buffer has been written.
* Throws on error. * Throws on error.

View File

@ -250,7 +250,7 @@ FileOutputStream::Write(std::span<const std::byte> src)
{ {
assert(IsDefined()); assert(IsDefined());
ssize_t nbytes = fd.Write(src.data(), src.size()); ssize_t nbytes = fd.Write(src);
if (nbytes < 0) if (nbytes < 0)
throw FmtErrno("Failed to write to {}", GetPath()); throw FmtErrno("Failed to write to {}", GetPath());
else if ((size_t)nbytes < src.size()) else if ((size_t)nbytes < src.size())