From 85d5837b577e95aef9fe6988f400a8ed981654d6 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 12 Nov 2024 08:49:29 +0100 Subject: [PATCH] io/FileDescriptor: remove Read()/Write() with void pointers Obsolete and unsafe. --- src/io/FileDescriptor.cxx | 4 ++-- src/io/FileDescriptor.hxx | 10 ---------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/io/FileDescriptor.cxx b/src/io/FileDescriptor.cxx index 08c38ca6..5d326b1a 100644 --- a/src/io/FileDescriptor.cxx +++ b/src/io/FileDescriptor.cxx @@ -267,7 +267,7 @@ void FileDescriptor::FullRead(std::span 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"); @@ -282,7 +282,7 @@ void FileDescriptor::FullWrite(std::span 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"); diff --git a/src/io/FileDescriptor.hxx b/src/io/FileDescriptor.hxx index c132a4e9..458cd816 100644 --- a/src/io/FileDescriptor.hxx +++ b/src/io/FileDescriptor.hxx @@ -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. @@ -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.