From d5871f5717579fab3c093537c44e3cd467560cdd Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Fri, 24 Feb 2023 22:38:01 +0100 Subject: [PATCH] AK: Rename Stream::{read,write} to Stream::{read_some,write_some} Similar to POSIX read, the basic read and write functions of AK::Stream do not have a lower limit of how much data they read or write (apart from "none at all"). Rename the functions to "read some [data]" and "write some [data]" (with "data" being omitted, since everything here is reading and writing data) to make them sufficiently distinct from the functions that ensure to use the entire buffer (which should be the go-to function for most usages). No functional changes, just a lot of new FIXMEs. --- AK/BitStream.h | 44 +++++++------ AK/BufferedStream.h | 6 +- AK/MemoryStream.cpp | 10 +-- AK/MemoryStream.h | 8 +-- AK/Stream.cpp | 8 +-- AK/Stream.h | 4 +- .../CodeGenerators/LibEDID/GeneratePnpIDs.cpp | 6 +- .../LibGL/GenerateGLAPIWrapper.cpp | 6 +- .../LibLocale/GenerateDateTimeFormatData.cpp | 6 +- .../LibLocale/GenerateLocaleData.cpp | 6 +- .../LibLocale/GenerateNumberFormatData.cpp | 6 +- .../LibLocale/GeneratePluralRulesData.cpp | 6 +- .../GenerateRelativeTimeFormatData.cpp | 6 +- .../LibTimeZone/GenerateTimeZoneData.cpp | 6 +- .../LibUnicode/GenerateEmojiData.cpp | 9 ++- .../LibUnicode/GenerateUnicodeData.cpp | 6 +- .../LibWeb/BindingsGenerator/main.cpp | 6 +- .../LibWeb/GenerateCSSEnums.cpp | 6 +- .../LibWeb/GenerateCSSMediaFeatureID.cpp | 6 +- .../LibWeb/GenerateCSSPropertyID.cpp | 6 +- .../LibWeb/GenerateCSSTransformFunctions.cpp | 6 +- .../LibWeb/GenerateCSSValueID.cpp | 6 +- .../GenerateWindowOrWorkerInterfaces.cpp | 12 ++-- Meta/Lagom/Wasm/js_repl.cpp | 4 +- Tests/AK/TestMemoryStream.cpp | 2 +- Tests/AK/TestString.cpp | 9 ++- Tests/LibCompress/TestBrotli.cpp | 2 +- Tests/LibCore/TestLibCoreStream.cpp | 24 +++---- Tests/LibTLS/TestTLSHandshake.cpp | 2 +- Tests/LibWasm/test-wasm.cpp | 3 +- Tests/LibWeb/TestHTMLTokenizer.cpp | 3 +- .../Applications/Browser/BrowserWindow.cpp | 3 +- .../ContentFilterSettingsWidget.cpp | 3 +- Userland/Applications/CrashReporter/main.cpp | 3 +- .../Applications/HexEditor/HexDocument.cpp | 20 +++--- .../KeyboardMapper/KeyboardMapperWidget.cpp | 3 +- Userland/Applications/Magnifier/main.cpp | 3 +- Userland/Applications/Run/RunWindow.cpp | 3 +- Userland/Games/Chess/ChessWidget.cpp | 41 ++++++------ Userland/Libraries/LibArchive/TarStream.cpp | 11 ++-- Userland/Libraries/LibArchive/TarStream.h | 4 +- Userland/Libraries/LibAudio/FlacLoader.cpp | 11 ++-- Userland/Libraries/LibAudio/MP3Loader.cpp | 3 +- Userland/Libraries/LibCompress/Brotli.cpp | 6 +- Userland/Libraries/LibCompress/Brotli.h | 4 +- Userland/Libraries/LibCompress/Deflate.cpp | 17 ++--- Userland/Libraries/LibCompress/Deflate.h | 8 +-- Userland/Libraries/LibCompress/Gzip.cpp | 30 +++++---- Userland/Libraries/LibCompress/Gzip.h | 8 +-- Userland/Libraries/LibCompress/Zlib.cpp | 12 ++-- Userland/Libraries/LibCompress/Zlib.h | 4 +- Userland/Libraries/LibCore/ConfigFile.cpp | 7 ++- Userland/Libraries/LibCore/EventLoop.cpp | 9 +-- Userland/Libraries/LibCore/File.cpp | 4 +- Userland/Libraries/LibCore/File.h | 4 +- Userland/Libraries/LibCore/NetworkJob.h | 2 +- .../Libraries/LibCore/SOCKSProxyClient.cpp | 63 ++++++++++++------- Userland/Libraries/LibCore/SOCKSProxyClient.h | 4 +- Userland/Libraries/LibCore/Socket.h | 20 +++--- Userland/Libraries/LibGUI/TextEditor.cpp | 5 +- Userland/Libraries/LibGemini/Job.cpp | 2 +- Userland/Libraries/LibHTTP/Job.cpp | 2 +- Userland/Libraries/LibIMAP/Client.cpp | 8 ++- Userland/Libraries/LibIPC/Connection.cpp | 2 +- Userland/Libraries/LibJS/Console.cpp | 3 +- Userland/Libraries/LibJS/Print.cpp | 2 +- .../Libraries/LibLine/InternalFunctions.cpp | 2 +- .../LibLine/XtermSuggestionDisplay.cpp | 17 +++-- Userland/Libraries/LibProtocol/Request.cpp | 2 +- Userland/Libraries/LibSQL/Heap.cpp | 6 +- Userland/Libraries/LibSQL/SQLClient.cpp | 3 +- Userland/Libraries/LibTLS/Socket.cpp | 8 +-- Userland/Libraries/LibTLS/TLSv12.h | 4 +- .../Libraries/LibTest/JavaScriptTestRunner.h | 3 +- Userland/Libraries/LibWasm/Parser/Parser.cpp | 2 +- Userland/Libraries/LibWasm/Types.h | 12 ++-- .../Libraries/LibWeb/WebDriver/Client.cpp | 12 ++-- .../Impl/WebSocketImplSerenity.cpp | 2 +- Userland/Services/EchoServer/Client.cpp | 5 +- Userland/Services/FileOperation/main.cpp | 5 +- .../InspectorServer/InspectableProcess.cpp | 13 ++-- .../Services/LookupServer/LookupServer.cpp | 5 +- Userland/Services/TelnetServer/Client.cpp | 11 ++-- Userland/Services/WebServer/Client.cpp | 15 +++-- Userland/Utilities/cat.cpp | 2 +- Userland/Utilities/checksum.cpp | 6 +- Userland/Utilities/cksum.cpp | 4 +- Userland/Utilities/cmp.cpp | 4 +- Userland/Utilities/file.cpp | 2 +- Userland/Utilities/gml-format.cpp | 3 +- Userland/Utilities/gunzip.cpp | 2 +- Userland/Utilities/headless-browser.cpp | 3 +- Userland/Utilities/hexdump.cpp | 2 +- Userland/Utilities/js.cpp | 3 +- Userland/Utilities/nc.cpp | 3 +- Userland/Utilities/pro.cpp | 6 +- Userland/Utilities/reboot.cpp | 3 +- Userland/Utilities/sed.cpp | 5 +- Userland/Utilities/shot.cpp | 3 +- Userland/Utilities/shutdown.cpp | 3 +- Userland/Utilities/strace.cpp | 3 +- Userland/Utilities/strings.cpp | 2 +- Userland/Utilities/sysctl.cpp | 3 +- Userland/Utilities/tail.cpp | 3 +- Userland/Utilities/tar.cpp | 4 +- Userland/Utilities/uniq.cpp | 5 +- Userland/Utilities/uptime.cpp | 2 +- Userland/Utilities/utmpupdate.cpp | 3 +- Userland/Utilities/wasm.cpp | 23 ++++--- 109 files changed, 474 insertions(+), 329 deletions(-) diff --git a/AK/BitStream.h b/AK/BitStream.h index c5a3d89801c..25dfb265d05 100644 --- a/AK/BitStream.h +++ b/AK/BitStream.h @@ -23,16 +23,17 @@ public: } // ^Stream - virtual ErrorOr read(Bytes bytes) override + virtual ErrorOr read_some(Bytes bytes) override { if (m_current_byte.has_value() && is_aligned_to_byte_boundary()) { bytes[0] = m_current_byte.release_value(); - return m_stream->read(bytes.slice(1)); + // FIXME: This accidentally slices off the first byte of the returned span. + return m_stream->read_some(bytes.slice(1)); } align_to_byte_boundary(); - return m_stream->read(bytes); + return m_stream->read_some(bytes); } - virtual ErrorOr write(ReadonlyBytes bytes) override { return m_stream->write(bytes); } + virtual ErrorOr write_some(ReadonlyBytes bytes) override { return m_stream->write_some(bytes); } virtual ErrorOr write_entire_buffer(ReadonlyBytes bytes) override { return m_stream->write_entire_buffer(bytes); } virtual bool is_eof() const override { return m_stream->is_eof() && !m_current_byte.has_value(); } virtual bool is_open() const override { return m_stream->is_open(); } @@ -91,7 +92,9 @@ public: } } else { auto temp_buffer = TRY(ByteBuffer::create_uninitialized(1)); - TRY(m_stream->read(temp_buffer.bytes())); + // FIXME: This should read the entire span. + // FIXME: This should just write into m_current_byte directly. + TRY(m_stream->read_some(temp_buffer.bytes())); m_current_byte = temp_buffer[0]; m_bit_offset = 0; } @@ -127,16 +130,17 @@ public: } // ^Stream - virtual ErrorOr read(Bytes bytes) override + virtual ErrorOr read_some(Bytes bytes) override { if (m_current_byte.has_value() && is_aligned_to_byte_boundary()) { bytes[0] = m_current_byte.release_value(); - return m_stream->read(bytes.slice(1)); + // FIXME: This accidentally slices off the first byte of the returned span. + return m_stream->read_some(bytes.slice(1)); } align_to_byte_boundary(); - return m_stream->read(bytes); + return m_stream->read_some(bytes); } - virtual ErrorOr write(ReadonlyBytes bytes) override { return m_stream->write(bytes); } + virtual ErrorOr write_some(ReadonlyBytes bytes) override { return m_stream->write_some(bytes); } virtual ErrorOr write_entire_buffer(ReadonlyBytes bytes) override { return m_stream->write_entire_buffer(bytes); } virtual bool is_eof() const override { return m_stream->is_eof() && !m_current_byte.has_value(); } virtual bool is_open() const override { return m_stream->is_open(); } @@ -191,7 +195,9 @@ public: } } else { auto temp_buffer = TRY(ByteBuffer::create_uninitialized(1)); - auto read_bytes = TRY(m_stream->read(temp_buffer.bytes())); + // FIXME: This should read the entire span. + // FIXME: This should just write into m_current_byte directly. + auto read_bytes = TRY(m_stream->read_some(temp_buffer.bytes())); if (read_bytes.is_empty()) return Error::from_string_literal("eof"); m_current_byte = temp_buffer[0]; @@ -230,15 +236,15 @@ public: { } - virtual ErrorOr read(Bytes) override + virtual ErrorOr read_some(Bytes) override { return Error::from_errno(EBADF); } - virtual ErrorOr write(ReadonlyBytes bytes) override + virtual ErrorOr write_some(ReadonlyBytes bytes) override { VERIFY(m_bit_offset == 0); - return m_stream->write(bytes); + return m_stream->write_some(bytes); } template @@ -255,7 +261,8 @@ public: m_bit_offset++; if (m_bit_offset > 7) { - TRY(m_stream->write({ &m_current_byte, sizeof(m_current_byte) })); + // FIXME: This should write the entire span. + TRY(m_stream->write_some({ &m_current_byte, sizeof(m_current_byte) })); m_bit_offset = 0; m_current_byte = 0; } @@ -308,15 +315,15 @@ public: { } - virtual ErrorOr read(Bytes) override + virtual ErrorOr read_some(Bytes) override { return Error::from_errno(EBADF); } - virtual ErrorOr write(ReadonlyBytes bytes) override + virtual ErrorOr write_some(ReadonlyBytes bytes) override { VERIFY(m_bit_offset == 0); - return m_stream->write(bytes); + return m_stream->write_some(bytes); } template @@ -333,7 +340,8 @@ public: m_bit_offset++; if (m_bit_offset > 7) { - TRY(m_stream->write({ &m_current_byte, sizeof(m_current_byte) })); + // FIXME: This should write the entire span. + TRY(m_stream->write_some({ &m_current_byte, sizeof(m_current_byte) })); m_bit_offset = 0; m_current_byte = 0; } diff --git a/AK/BufferedStream.h b/AK/BufferedStream.h index b34868952f2..4b454d15e9f 100644 --- a/AK/BufferedStream.h +++ b/AK/BufferedStream.h @@ -236,7 +236,7 @@ private: auto const fillable_slice = temporary_buffer.span().trim(min(temporary_buffer.size(), m_buffer.empty_space())); size_t nread = 0; do { - auto result = stream().read(fillable_slice); + auto result = stream().read_some(fillable_slice); if (result.is_error()) { if (!result.error().is_errno()) return result.release_error(); @@ -274,8 +274,8 @@ public: BufferedSeekable(BufferedSeekable&& other) = default; BufferedSeekable& operator=(BufferedSeekable&& other) = default; - virtual ErrorOr read(Bytes buffer) override { return m_helper.read(move(buffer)); } - virtual ErrorOr write(ReadonlyBytes buffer) override { return m_helper.stream().write(buffer); } + virtual ErrorOr read_some(Bytes buffer) override { return m_helper.read(move(buffer)); } + virtual ErrorOr write_some(ReadonlyBytes buffer) override { return m_helper.stream().write_some(buffer); } virtual bool is_eof() const override { return m_helper.is_eof(); } virtual bool is_open() const override { return m_helper.stream().is_open(); } virtual void close() override { m_helper.stream().close(); } diff --git a/AK/MemoryStream.cpp b/AK/MemoryStream.cpp index 237fd345bfe..e1131b3cd8f 100644 --- a/AK/MemoryStream.cpp +++ b/AK/MemoryStream.cpp @@ -43,7 +43,7 @@ ErrorOr FixedMemoryStream::truncate(size_t) return Error::from_errno(EBADF); } -ErrorOr FixedMemoryStream::read(Bytes bytes) +ErrorOr FixedMemoryStream::read_some(Bytes bytes) { auto to_read = min(remaining(), bytes.size()); if (to_read == 0) @@ -79,7 +79,7 @@ ErrorOr FixedMemoryStream::seek(i64 offset, SeekMode seek_mode) return m_offset; } -ErrorOr FixedMemoryStream::write(ReadonlyBytes bytes) +ErrorOr FixedMemoryStream::write_some(ReadonlyBytes bytes) { VERIFY(m_writing_enabled); @@ -94,7 +94,7 @@ ErrorOr FixedMemoryStream::write_entire_buffer(ReadonlyBytes bytes) if (remaining() < bytes.size()) return Error::from_string_view_or_print_error_and_return_errno("Write of entire buffer ends past the memory area"sv, EINVAL); - TRY(write(bytes)); + TRY(write_some(bytes)); return {}; } @@ -118,7 +118,7 @@ size_t FixedMemoryStream::remaining() const return m_bytes.size() - m_offset; } -ErrorOr AllocatingMemoryStream::read(Bytes bytes) +ErrorOr AllocatingMemoryStream::read_some(Bytes bytes) { size_t read_bytes = 0; @@ -140,7 +140,7 @@ ErrorOr AllocatingMemoryStream::read(Bytes bytes) return bytes.trim(read_bytes); } -ErrorOr AllocatingMemoryStream::write(ReadonlyBytes bytes) +ErrorOr AllocatingMemoryStream::write_some(ReadonlyBytes bytes) { size_t written_bytes = 0; diff --git a/AK/MemoryStream.h b/AK/MemoryStream.h index fa4961b77b4..c1fe27a27c4 100644 --- a/AK/MemoryStream.h +++ b/AK/MemoryStream.h @@ -23,11 +23,11 @@ public: virtual bool is_open() const override; virtual void close() override; virtual ErrorOr truncate(size_t) override; - virtual ErrorOr read(Bytes bytes) override; + virtual ErrorOr read_some(Bytes bytes) override; virtual ErrorOr seek(i64 offset, SeekMode seek_mode = SeekMode::SetPosition) override; - virtual ErrorOr write(ReadonlyBytes bytes) override; + virtual ErrorOr write_some(ReadonlyBytes bytes) override; virtual ErrorOr write_entire_buffer(ReadonlyBytes bytes) override; Bytes bytes(); @@ -45,8 +45,8 @@ private: /// and reading back the written data afterwards. class AllocatingMemoryStream final : public Stream { public: - virtual ErrorOr read(Bytes) override; - virtual ErrorOr write(ReadonlyBytes) override; + virtual ErrorOr read_some(Bytes) override; + virtual ErrorOr write_some(ReadonlyBytes) override; virtual ErrorOr discard(size_t) override; virtual bool is_eof() const override; virtual bool is_open() const override; diff --git a/AK/Stream.cpp b/AK/Stream.cpp index c47afe3dbf6..ab0c572391e 100644 --- a/AK/Stream.cpp +++ b/AK/Stream.cpp @@ -18,7 +18,7 @@ ErrorOr Stream::read_entire_buffer(Bytes buffer) if (is_eof()) return Error::from_string_view_or_print_error_and_return_errno("Reached end-of-file before filling the entire buffer"sv, EIO); - auto result = read(buffer.slice(nread)); + auto result = read_some(buffer.slice(nread)); if (result.is_error()) { if (result.error().is_errno() && result.error().code() == EINTR) { continue; @@ -50,7 +50,7 @@ ErrorOr Stream::read_until_eof_impl(size_t block_size, size_t expect buffer = TRY(data.get_bytes_for_writing(block_size)); } - auto nread = TRY(read(buffer)).size(); + auto nread = TRY(read_some(buffer)).size(); total_read += nread; buffer = buffer.slice(nread); } @@ -71,7 +71,7 @@ ErrorOr Stream::discard(size_t discarded_bytes) if (is_eof()) return Error::from_string_view_or_print_error_and_return_errno("Reached end-of-file before reading all discarded bytes"sv, EIO); - auto slice = TRY(read(buffer.span().slice(0, min(discarded_bytes, continuous_read_size)))); + auto slice = TRY(read_some(buffer.span().slice(0, min(discarded_bytes, continuous_read_size)))); discarded_bytes -= slice.size(); } @@ -82,7 +82,7 @@ ErrorOr Stream::write_entire_buffer(ReadonlyBytes buffer) { size_t nwritten = 0; while (nwritten < buffer.size()) { - auto result = write(buffer.slice(nwritten)); + auto result = write_some(buffer.slice(nwritten)); if (result.is_error()) { if (result.error().is_errno() && result.error().code() == EINTR) { continue; diff --git a/AK/Stream.h b/AK/Stream.h index d01ae9ddb33..8211cf8687e 100644 --- a/AK/Stream.h +++ b/AK/Stream.h @@ -23,7 +23,7 @@ public: /// The amount of bytes read can be smaller than the size of the buffer. /// Returns either the bytes that were read, or an errno in the case of /// failure. - virtual ErrorOr read(Bytes) = 0; + virtual ErrorOr read_some(Bytes) = 0; /// Tries to fill the entire buffer through reading. Returns whether the /// buffer was filled without an error. virtual ErrorOr read_entire_buffer(Bytes); @@ -41,7 +41,7 @@ public: /// Tries to write the entire contents of the buffer. It is possible for /// less than the full buffer to be written. Returns either the amount of /// bytes written into the stream, or an errno in the case of failure. - virtual ErrorOr write(ReadonlyBytes) = 0; + virtual ErrorOr write_some(ReadonlyBytes) = 0; /// Same as write, but does not return until either the entire buffer /// contents are written or an error occurs. virtual ErrorOr write_entire_buffer(ReadonlyBytes); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibEDID/GeneratePnpIDs.cpp b/Meta/Lagom/Tools/CodeGenerators/LibEDID/GeneratePnpIDs.cpp index bf6228ce7aa..0e6f1be97ed 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibEDID/GeneratePnpIDs.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibEDID/GeneratePnpIDs.cpp @@ -211,7 +211,8 @@ namespace PnpIDs { } )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } @@ -265,7 +266,8 @@ IterationDecision for_each(Function callbac } )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibGL/GenerateGLAPIWrapper.cpp b/Meta/Lagom/Tools/CodeGenerators/LibGL/GenerateGLAPIWrapper.cpp index 2a2b346a0f9..6232391bcfb 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibGL/GenerateGLAPIWrapper.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibGL/GenerateGLAPIWrapper.cpp @@ -405,7 +405,8 @@ ErrorOr generate_header_file(JsonObject& api_data, Core::File& file) generator.appendln("}"); generator.appendln("#endif"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } @@ -529,7 +530,8 @@ ErrorOr generate_implementation_file(JsonObject& api_data, Core::File& fil } }); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp index 0c9314837e9..11036568e77 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp @@ -1724,7 +1724,8 @@ namespace Locale { } )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } @@ -2397,7 +2398,8 @@ Optional get_time_zone_name(StringView locale, StringView time_zone, } )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp index f3acc8bada4..9aaa0e2aa8c 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp @@ -1047,7 +1047,8 @@ namespace Locale { } )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } @@ -1747,7 +1748,8 @@ ErrorOr> resolve_most_likely_territory(LanguageID const& langua } )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp index a364adfaed1..c256207909f 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp @@ -763,7 +763,8 @@ namespace Locale { } )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } @@ -1107,7 +1108,8 @@ ErrorOr> get_unit_formats(StringView locale, StringView uni } )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp index 35dba37051b..06cf4e52334 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp @@ -442,7 +442,8 @@ namespace Locale { } )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } @@ -654,7 +655,8 @@ PluralCategory determine_plural_range(StringView locale, PluralCategory start, P } )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateRelativeTimeFormatData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateRelativeTimeFormatData.cpp index 5954490130e..2de3325cfcf 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateRelativeTimeFormatData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateRelativeTimeFormatData.cpp @@ -180,7 +180,8 @@ namespace Locale { } )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } @@ -276,7 +277,8 @@ ErrorOr> get_relative_time_format_patterns(StringView } )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp index b3743a8795e..bfce2109e4a 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp @@ -469,7 +469,8 @@ namespace TimeZone { } )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } @@ -801,7 +802,8 @@ Vector time_zones_in_region(StringView region) } )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp index 0474357668e..f767e359b4a 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp @@ -213,7 +213,8 @@ static ErrorOr generate_emoji_data_header(Core::BufferedFile& file, EmojiD StringBuilder builder; SourceGenerator generator { builder }; - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } @@ -334,7 +335,8 @@ Optional find_emoji_for_code_points(ReadonlySpan code_points) } )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } @@ -379,7 +381,8 @@ static ErrorOr generate_emoji_installation(Core::BufferedFile& file, Emoji generator.append(" @name@ (@status@)\n"sv); } - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp index f0bb5b2265a..bc9ae3545cf 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp @@ -866,7 +866,8 @@ ReadonlySpan case_folding_mapping(u32 code_point); } )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } @@ -1354,7 +1355,8 @@ bool code_point_has_@enum_snake@(u32 code_point, @enum_title@ @enum_snake@) } )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/main.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/main.cpp index 7100004c238..7380ff753f2 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/main.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/main.cpp @@ -160,7 +160,8 @@ ErrorOr serenity_main(Main::Arguments arguments) if (global_mixin_implementation_mode) IDL::generate_global_mixin_implementation(interface, output_builder); - TRY(output_file->write(output_builder.string_view().bytes())); + // FIXME: This should write the entire span. + TRY(output_file->write_some(output_builder.string_view().bytes())); if (!depfile_path.is_null()) { auto depfile = TRY(Core::File::open_file_or_standard_stream(depfile_path, Core::File::OpenMode::Write)); @@ -173,7 +174,8 @@ ErrorOr serenity_main(Main::Arguments arguments) depfile_builder.append(path); } depfile_builder.append('\n'); - TRY(depfile->write(depfile_builder.string_view().bytes())); + // FIXME: This should write the entire span. + TRY(depfile->write_some(depfile_builder.string_view().bytes())); } return 0; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSEnums.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSEnums.cpp index 51e21dbbf44..3b69be6a233 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSEnums.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSEnums.cpp @@ -95,7 +95,8 @@ enum class ValueID; generator.appendln("}"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } @@ -199,6 +200,7 @@ StringView to_string(@name:titlecase@ value) generator.appendln("}"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMediaFeatureID.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMediaFeatureID.cpp index 8da1c6578fc..dac67bc14e5 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMediaFeatureID.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMediaFeatureID.cpp @@ -80,7 +80,8 @@ bool media_feature_accepts_identifier(MediaFeatureID, ValueID); } )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } @@ -290,6 +291,7 @@ bool media_feature_accepts_identifier(MediaFeatureID media_feature_id, ValueID i } )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp index 168a6f49041..5dee887262f 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp @@ -140,7 +140,8 @@ struct Traits : public GenericTraits } // namespace AK )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } @@ -605,6 +606,7 @@ size_t property_maximum_value_count(PropertyID property_id) )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp index e64a546733e..7e4cea8284b 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp @@ -96,7 +96,8 @@ TransformFunctionMetadata transform_function_metadata(TransformFunction); generator.appendln("\n}"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } @@ -205,6 +206,7 @@ TransformFunctionMetadata transform_function_metadata(TransformFunction transfor generator.appendln("\n}"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSValueID.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSValueID.cpp index ba0dba9088c..2b0c51b4855 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSValueID.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSValueID.cpp @@ -74,7 +74,8 @@ StringView string_from_value_id(ValueID); )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } @@ -134,6 +135,7 @@ StringView string_from_value_id(ValueID value_id) { } // namespace Web::CSS )~~~"); - TRY(file.write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(generator.as_string_view().bytes())); return {}; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp index 72ec204d97d..ab6ddc03146 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp @@ -105,7 +105,8 @@ class @legacy_constructor_class@;)~~~"); auto generated_forward_path = LexicalPath(output_path).append("Forward.h"sv).string(); auto generated_forward_file = TRY(Core::File::open(generated_forward_path, Core::File::OpenMode::Write)); - TRY(generated_forward_file->write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(generated_forward_file->write_some(generator.as_string_view().bytes())); return {}; } @@ -208,7 +209,8 @@ void Intrinsics::create_web_prototype_and_constructor<@prototype_class@>(JS::Rea auto generated_intrinsics_path = LexicalPath(output_path).append("IntrinsicDefinitions.cpp"sv).string(); auto generated_intrinsics_file = TRY(Core::File::open(generated_intrinsics_path, Core::File::OpenMode::Write)); - TRY(generated_intrinsics_file->write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(generated_intrinsics_file->write_some(generator.as_string_view().bytes())); return {}; } @@ -234,7 +236,8 @@ void add_@global_object_snake_name@_exposed_interfaces(JS::Object&); auto generated_header_path = LexicalPath(output_path).append(DeprecatedString::formatted("{}ExposedInterfaces.h", class_name)).string(); auto generated_header_file = TRY(Core::File::open(generated_header_path, Core::File::OpenMode::Write)); - TRY(generated_header_file->write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(generated_header_file->write_some(generator.as_string_view().bytes())); return {}; } @@ -303,7 +306,8 @@ void add_@global_object_snake_name@_exposed_interfaces(JS::Object& global) auto generated_implementation_path = LexicalPath(output_path).append(DeprecatedString::formatted("{}ExposedInterfaces.cpp", class_name)).string(); auto generated_implementation_file = TRY(Core::File::open(generated_implementation_path, Core::File::OpenMode::Write)); - TRY(generated_implementation_file->write(generator.as_string_view().bytes())); + // FIXME: This should write the entire span. + TRY(generated_implementation_file->write_some(generator.as_string_view().bytes())); return {}; } diff --git a/Meta/Lagom/Wasm/js_repl.cpp b/Meta/Lagom/Wasm/js_repl.cpp index 5e1fa7ad9aa..356ef65b4a1 100644 --- a/Meta/Lagom/Wasm/js_repl.cpp +++ b/Meta/Lagom/Wasm/js_repl.cpp @@ -63,8 +63,8 @@ void displayln(CheckedFormatString format_string, Args const&... args) void displayln() { user_display("\n", 1); } class UserDisplayStream final : public Stream { - virtual ErrorOr read(Bytes) override { return Error::from_string_view("Not readable"sv); }; - virtual ErrorOr write(ReadonlyBytes bytes) override + virtual ErrorOr read_some(Bytes) override { return Error::from_string_view("Not readable"sv); }; + virtual ErrorOr write_some(ReadonlyBytes bytes) override { user_display(bit_cast(bytes.data()), bytes.size()); return bytes.size(); diff --git a/Tests/AK/TestMemoryStream.cpp b/Tests/AK/TestMemoryStream.cpp index b335609b865..cbe2cfea2e0 100644 --- a/Tests/AK/TestMemoryStream.cpp +++ b/Tests/AK/TestMemoryStream.cpp @@ -16,7 +16,7 @@ TEST_CASE(allocating_memory_stream_empty) { Array array; - auto read_bytes = MUST(stream.read(array)); + auto read_bytes = MUST(stream.read_some(array)); EXPECT_EQ(read_bytes.size(), 0ul); } diff --git a/Tests/AK/TestString.cpp b/Tests/AK/TestString.cpp index 61cfbcdc9ff..4d93637b23b 100644 --- a/Tests/AK/TestString.cpp +++ b/Tests/AK/TestString.cpp @@ -98,7 +98,8 @@ TEST_CASE(long_streams) u8 bytes[64] = {}; constexpr auto test_view = "Well, hello friends"sv; FixedMemoryStream stream(Bytes { bytes, sizeof(bytes) }); - MUST(stream.write(test_view.bytes())); + // FIXME: This should write the entire span. + MUST(stream.write_some(test_view.bytes())); MUST(stream.seek(0)); auto string = MUST(String::from_stream(stream, test_view.length())); @@ -110,7 +111,8 @@ TEST_CASE(long_streams) { AllocatingMemoryStream stream; - MUST(stream.write(("abc"sv).bytes())); + // FIXME: This should write the entire span. + MUST(stream.write_some(("abc"sv).bytes())); auto string = MUST(String::from_stream(stream, 3u)); @@ -121,7 +123,8 @@ TEST_CASE(long_streams) { AllocatingMemoryStream stream; - MUST(stream.write(("0123456789"sv).bytes())); + // FIXME: This should write the entire span. + MUST(stream.write_some(("0123456789"sv).bytes())); auto string = MUST(String::from_stream(stream, 9u)); diff --git a/Tests/LibCompress/TestBrotli.cpp b/Tests/LibCompress/TestBrotli.cpp index d5b99bd4f13..eed05c59eac 100644 --- a/Tests/LibCompress/TestBrotli.cpp +++ b/Tests/LibCompress/TestBrotli.cpp @@ -104,7 +104,7 @@ TEST_CASE(brotli_decompress_zero_one_bin) size_t bytes_read = 0; while (true) { - size_t nread = MUST(brotli_stream.read(buffer)).size(); + size_t nread = MUST(brotli_stream.read_some(buffer)).size(); if (nread == 0) break; diff --git a/Tests/LibCore/TestLibCoreStream.cpp b/Tests/LibCore/TestLibCoreStream.cpp index 8e4ac3917ef..e9bc16a02fb 100644 --- a/Tests/LibCore/TestLibCoreStream.cpp +++ b/Tests/LibCore/TestLibCoreStream.cpp @@ -46,7 +46,7 @@ TEST_CASE(file_write_bytes) constexpr auto some_words = "These are some words"sv; ReadonlyBytes buffer { some_words.characters_without_null_termination(), some_words.length() }; - auto result = file->write(buffer); + auto result = file->write_some(buffer); EXPECT(!result.is_error()); } @@ -62,7 +62,7 @@ TEST_CASE(file_read_bytes) EXPECT(!maybe_buffer.is_error()); auto buffer = maybe_buffer.release_value(); - auto result = file->read(buffer); + auto result = file->read_some(buffer); EXPECT(!result.is_error()); EXPECT_EQ(result.value().size(), 131ul); @@ -185,7 +185,7 @@ TEST_CASE(tcp_socket_read) auto maybe_server_socket = tcp_server->accept(); EXPECT(!maybe_server_socket.is_error()); auto server_socket = maybe_server_socket.release_value(); - EXPECT(!server_socket->write({ sent_data.characters_without_null_termination(), sent_data.length() }).is_error()); + EXPECT(!server_socket->write_some({ sent_data.characters_without_null_termination(), sent_data.length() }).is_error()); server_socket->close(); EXPECT(client_socket->can_read_without_blocking(100).release_value()); @@ -194,7 +194,7 @@ TEST_CASE(tcp_socket_read) auto maybe_receive_buffer = ByteBuffer::create_uninitialized(64); EXPECT(!maybe_receive_buffer.is_error()); auto receive_buffer = maybe_receive_buffer.release_value(); - auto maybe_read_bytes = client_socket->read(receive_buffer); + auto maybe_read_bytes = client_socket->read_some(receive_buffer); EXPECT(!maybe_read_bytes.is_error()); auto read_bytes = maybe_read_bytes.release_value(); @@ -227,7 +227,7 @@ TEST_CASE(tcp_socket_write) auto maybe_receive_buffer = ByteBuffer::create_uninitialized(64); EXPECT(!maybe_receive_buffer.is_error()); auto receive_buffer = maybe_receive_buffer.release_value(); - auto maybe_read_bytes = server_socket->read(receive_buffer); + auto maybe_read_bytes = server_socket->read_some(receive_buffer); EXPECT(!maybe_read_bytes.is_error()); auto read_bytes = maybe_read_bytes.release_value(); @@ -263,7 +263,7 @@ TEST_CASE(tcp_socket_eof) auto maybe_receive_buffer = ByteBuffer::create_uninitialized(1); EXPECT(!maybe_receive_buffer.is_error()); auto receive_buffer = maybe_receive_buffer.release_value(); - EXPECT(client_socket->read(receive_buffer).release_value().is_empty()); + EXPECT(client_socket->read_some(receive_buffer).release_value().is_empty()); EXPECT(client_socket->is_eof()); } @@ -307,12 +307,12 @@ TEST_CASE(udp_socket_read_write) // Testing that supplying a smaller buffer than required causes a failure. auto small_buffer = ByteBuffer::create_uninitialized(8).release_value(); - EXPECT_EQ(client_socket->read(small_buffer).error().code(), EMSGSIZE); + EXPECT_EQ(client_socket->read_some(small_buffer).error().code(), EMSGSIZE); auto maybe_client_receive_buffer = ByteBuffer::create_uninitialized(64); EXPECT(!maybe_client_receive_buffer.is_error()); auto client_receive_buffer = maybe_client_receive_buffer.release_value(); - auto maybe_read_bytes = client_socket->read(client_receive_buffer); + auto maybe_read_bytes = client_socket->read_some(client_receive_buffer); EXPECT(!maybe_read_bytes.is_error()); auto read_bytes = maybe_read_bytes.release_value(); @@ -330,7 +330,7 @@ TEST_CASE(local_socket_read) EXPECT(local_server->listen("/tmp/test-socket")); local_server->on_accept = [&](NonnullOwnPtr server_socket) { - EXPECT(!server_socket->write(sent_data.bytes()).is_error()); + EXPECT(!server_socket->write_some(sent_data.bytes()).is_error()); event_loop.quit(0); event_loop.pump(); @@ -356,7 +356,7 @@ TEST_CASE(local_socket_read) auto maybe_receive_buffer = ByteBuffer::create_uninitialized(64); EXPECT(!maybe_receive_buffer.is_error()); auto receive_buffer = maybe_receive_buffer.release_value(); - auto maybe_read_bytes = client_socket->read(receive_buffer); + auto maybe_read_bytes = client_socket->read_some(receive_buffer); EXPECT(!maybe_read_bytes.is_error()); auto read_bytes = maybe_read_bytes.release_value(); @@ -387,7 +387,7 @@ TEST_CASE(local_socket_write) auto maybe_receive_buffer = ByteBuffer::create_uninitialized(pending_bytes); EXPECT(!maybe_receive_buffer.is_error()); auto receive_buffer = maybe_receive_buffer.release_value(); - auto maybe_read_bytes = server_socket->read(receive_buffer); + auto maybe_read_bytes = server_socket->read_some(receive_buffer); EXPECT(!maybe_read_bytes.is_error()); EXPECT_EQ(maybe_read_bytes.value().size(), sent_data.length()); @@ -578,7 +578,7 @@ TEST_CASE(buffered_tcp_socket_read) auto maybe_server_socket = tcp_server->accept(); EXPECT(!maybe_server_socket.is_error()); auto server_socket = maybe_server_socket.release_value(); - EXPECT(!server_socket->write({ buffered_sent_data.characters_without_null_termination(), sent_data.length() }).is_error()); + EXPECT(!server_socket->write_some({ buffered_sent_data.characters_without_null_termination(), sent_data.length() }).is_error()); EXPECT(client_socket->can_read_without_blocking(100).release_value()); diff --git a/Tests/LibTLS/TestTLSHandshake.cpp b/Tests/LibTLS/TestTLSHandshake.cpp index 1878b6a425f..13712a0e8a7 100644 --- a/Tests/LibTLS/TestTLSHandshake.cpp +++ b/Tests/LibTLS/TestTLSHandshake.cpp @@ -88,7 +88,7 @@ TEST_CASE(test_TLS_hello_handshake) auto tls = MUST(TLS::TLSv12::connect(DEFAULT_SERVER, port, move(options))); ByteBuffer contents; tls->on_ready_to_read = [&] { - auto read_bytes = MUST(tls->read(contents.must_get_bytes_for_writing(4 * KiB))); + auto read_bytes = MUST(tls->read_some(contents.must_get_bytes_for_writing(4 * KiB))); if (read_bytes.is_empty()) { FAIL("No data received"); loop.quit(1); diff --git a/Tests/LibWasm/test-wasm.cpp b/Tests/LibWasm/test-wasm.cpp index 81bd472774d..1f8b0b4180e 100644 --- a/Tests/LibWasm/test-wasm.cpp +++ b/Tests/LibWasm/test-wasm.cpp @@ -32,7 +32,8 @@ TESTJS_GLOBAL_FUNCTION(read_binary_wasm_file, readBinaryWasmFile) auto array = TRY(JS::Uint8Array::create(realm, file_size.value())); - auto read = file.value()->read(array->data()); + // FIXME: This should read the entire span. + auto read = file.value()->read_some(array->data()); if (read.is_error()) return vm.throw_completion(error_code_to_string(read.error().code())); diff --git a/Tests/LibWeb/TestHTMLTokenizer.cpp b/Tests/LibWeb/TestHTMLTokenizer.cpp index ba2ba76a91d..a6d03186a10 100644 --- a/Tests/LibWeb/TestHTMLTokenizer.cpp +++ b/Tests/LibWeb/TestHTMLTokenizer.cpp @@ -211,7 +211,8 @@ TEST_CASE(regression) auto file = MUST(Core::File::open(path, Core::File::OpenMode::Read)); auto file_size = MUST(file->size()); auto content = MUST(ByteBuffer::create_uninitialized(file_size)); - MUST(file->read(content.bytes())); + // FIXME: This should read the entire span. + MUST(file->read_some(content.bytes())); DeprecatedString file_contents { content.bytes() }; auto tokens = run_tokenizer(file_contents); u32 hash = hash_tokens(tokens); diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp index af098d03357..ebd4544af91 100644 --- a/Userland/Applications/Browser/BrowserWindow.cpp +++ b/Userland/Applications/Browser/BrowserWindow.cpp @@ -775,7 +775,8 @@ ErrorOr BrowserWindow::take_screenshot(ScreenshotType type) auto encoded = TRY(Gfx::PNGWriter::encode(*bitmap.bitmap())); auto screenshot_file = TRY(Core::File::open(path.string(), Core::File::OpenMode::Write)); - TRY(screenshot_file->write(encoded)); + // FIXME: This should write the entire span. + TRY(screenshot_file->write_some(encoded)); return {}; } diff --git a/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp b/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp index 5127ccf6fe2..551fa6b81db 100644 --- a/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp +++ b/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp @@ -50,7 +50,8 @@ ErrorOr DomainListModel::save() TRY(builder.try_appendff("{}\n", domain)); auto file = TRY(Core::File::open(filter_list_file_path(), Core::File::OpenMode::Write)); - TRY(file->write(TRY(builder.to_byte_buffer()).bytes())); + // FIXME: This should write the entire span. + TRY(file->write_some(TRY(builder.to_byte_buffer()).bytes())); return {}; } diff --git a/Userland/Applications/CrashReporter/main.cpp b/Userland/Applications/CrashReporter/main.cpp index 4eb839c6a2b..bf3c17b0b17 100644 --- a/Userland/Applications/CrashReporter/main.cpp +++ b/Userland/Applications/CrashReporter/main.cpp @@ -284,7 +284,8 @@ ErrorOr serenity_main(Main::Arguments arguments) } auto byte_buffer = byte_buffer_or_error.release_value(); - if (auto result = file->write(byte_buffer); result.is_error()) + // FIXME: This should write the entire span. + if (auto result = file->write_some(byte_buffer); result.is_error()) GUI::MessageBox::show(window, DeprecatedString::formatted("Couldn't save file: {}.", result.release_error()), "Saving backtrace failed"sv, GUI::MessageBox::Type::Error); }; save_backtrace_button.set_enabled(false); diff --git a/Userland/Applications/HexEditor/HexDocument.cpp b/Userland/Applications/HexEditor/HexDocument.cpp index fa9edbec491..eddcc409f5c 100644 --- a/Userland/Applications/HexEditor/HexDocument.cpp +++ b/Userland/Applications/HexEditor/HexDocument.cpp @@ -62,10 +62,12 @@ void HexDocumentMemory::clear_changes() ErrorOr HexDocumentMemory::write_to_file(Core::File& file) { TRY(file.seek(0, SeekMode::SetPosition)); - TRY(file.write(m_buffer)); + // FIXME: This should write the entire span. + TRY(file.write_some(m_buffer)); for (auto& change : m_changes) { TRY(file.seek(change.key, SeekMode::SetPosition)); - TRY(file.write({ &change.value, 1 })); + // FIXME: This should write the entire span. + TRY(file.write_some({ &change.value, 1 })); } return {}; } @@ -87,7 +89,8 @@ ErrorOr HexDocumentFile::write_to_file() { for (auto& change : m_changes) { TRY(m_file->seek(change.key, SeekMode::SetPosition)); - TRY(m_file->write({ &change.value, 1 })); + // FIXME: This should write the entire span. + TRY(m_file->write_some({ &change.value, 1 })); } clear_changes(); // make sure the next get operation triggers a read @@ -104,15 +107,17 @@ ErrorOr HexDocumentFile::write_to_file(Core::File& file) while (true) { Array buffer; - auto copy_buffer = TRY(m_file->read(buffer)); + auto copy_buffer = TRY(m_file->read_some(buffer)); if (copy_buffer.size() == 0) break; - TRY(file.write(copy_buffer)); + // FIXME: This should write the entire span. + TRY(file.write_some(copy_buffer)); } for (auto& change : m_changes) { TRY(file.seek(change.key, SeekMode::SetPosition)); - TRY(file.write({ &change.value, 1 })); + // FIXME: This should write the entire span. + TRY(file.write_some({ &change.value, 1 })); } return {}; @@ -181,7 +186,8 @@ void HexDocumentFile::ensure_position_in_buffer(size_t position) { if (position < m_buffer_file_pos || position >= m_buffer_file_pos + m_buffer.size()) { m_file->seek(position, SeekMode::SetPosition).release_value_but_fixme_should_propagate_errors(); - m_file->read(m_buffer).release_value_but_fixme_should_propagate_errors(); + // FIXME: This seems wrong. We don't track how much of the buffer is actually filled. + m_file->read_some(m_buffer).release_value_but_fixme_should_propagate_errors(); m_buffer_file_pos = position; } } diff --git a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp index 438212deb60..3695aadfc88 100644 --- a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp +++ b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp @@ -191,7 +191,8 @@ ErrorOr KeyboardMapperWidget::save_to_file(StringView filename) // Write to file. DeprecatedString file_content = map_json.to_deprecated_string(); auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Write)); - TRY(file->write(file_content.bytes())); + // FIXME: This should write the entire span. + TRY(file->write_some(file_content.bytes())); file->close(); window()->set_modified(false); diff --git a/Userland/Applications/Magnifier/main.cpp b/Userland/Applications/Magnifier/main.cpp index 9595c89eac4..bd4664d13d1 100644 --- a/Userland/Applications/Magnifier/main.cpp +++ b/Userland/Applications/Magnifier/main.cpp @@ -73,7 +73,8 @@ ErrorOr serenity_main(Main::Arguments arguments) filename = path.basename(); auto encoded = TRY(dump_bitmap(magnifier->current_bitmap(), path.extension())); - TRY(file->write(encoded)); + // FIXME: This should write the entire span. + TRY(file->write_some(encoded)); return {}; }; diff --git a/Userland/Applications/Run/RunWindow.cpp b/Userland/Applications/Run/RunWindow.cpp index 0e864971c3b..252c2a6a1a9 100644 --- a/Userland/Applications/Run/RunWindow.cpp +++ b/Userland/Applications/Run/RunWindow.cpp @@ -187,7 +187,8 @@ ErrorOr RunWindow::save_history() // Write the first 25 items of history for (int i = 0; i < min(static_cast(m_path_history.size()), 25); i++) - TRY(file->write(DeprecatedString::formatted("{}\n", m_path_history[i]).bytes())); + // FIXME: This should write the entire span. + TRY(file->write_some(DeprecatedString::formatted("{}\n", m_path_history[i]).bytes())); return {}; } diff --git a/Userland/Games/Chess/ChessWidget.cpp b/Userland/Games/Chess/ChessWidget.cpp index 2f43ab111ba..2c5ecc54092 100644 --- a/Userland/Games/Chess/ChessWidget.cpp +++ b/Userland/Games/Chess/ChessWidget.cpp @@ -632,24 +632,25 @@ ErrorOr ChessWidget::import_pgn(Core::File& file) ErrorOr ChessWidget::export_pgn(Core::File& file) const { // Tag Pair Section - TRY(file.write("[Event \"Casual Game\"]\n"sv.bytes())); - TRY(file.write("[Site \"SerenityOS Chess\"]\n"sv.bytes())); - TRY(file.write(DeprecatedString::formatted("[Date \"{}\"]\n", Core::DateTime::now().to_deprecated_string("%Y.%m.%d"sv)).bytes())); - TRY(file.write("[Round \"1\"]\n"sv.bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some("[Event \"Casual Game\"]\n"sv.bytes())); + TRY(file.write_some("[Site \"SerenityOS Chess\"]\n"sv.bytes())); + TRY(file.write_some(DeprecatedString::formatted("[Date \"{}\"]\n", Core::DateTime::now().to_deprecated_string("%Y.%m.%d"sv)).bytes())); + TRY(file.write_some("[Round \"1\"]\n"sv.bytes())); DeprecatedString username(getlogin()); auto const player1 = (!username.is_empty() ? username.view() : "?"sv.bytes()); auto const player2 = (!m_engine.is_null() ? "SerenityOS ChessEngine"sv.bytes() : "?"sv.bytes()); - TRY(file.write(DeprecatedString::formatted("[White \"{}\"]\n", m_side == Chess::Color::White ? player1 : player2).bytes())); - TRY(file.write(DeprecatedString::formatted("[Black \"{}\"]\n", m_side == Chess::Color::Black ? player1 : player2).bytes())); + TRY(file.write_some(DeprecatedString::formatted("[White \"{}\"]\n", m_side == Chess::Color::White ? player1 : player2).bytes())); + TRY(file.write_some(DeprecatedString::formatted("[Black \"{}\"]\n", m_side == Chess::Color::Black ? player1 : player2).bytes())); - TRY(file.write(DeprecatedString::formatted("[Result \"{}\"]\n", Chess::Board::result_to_points_string(m_board.game_result(), m_board.turn())).bytes())); - TRY(file.write("[WhiteElo \"?\"]\n"sv.bytes())); - TRY(file.write("[BlackElo \"?\"]\n"sv.bytes())); - TRY(file.write("[Variant \"Standard\"]\n"sv.bytes())); - TRY(file.write("[TimeControl \"-\"]\n"sv.bytes())); - TRY(file.write("[Annotator \"SerenityOS Chess\"]\n"sv.bytes())); - TRY(file.write("\n"sv.bytes())); + TRY(file.write_some(DeprecatedString::formatted("[Result \"{}\"]\n", Chess::Board::result_to_points_string(m_board.game_result(), m_board.turn())).bytes())); + TRY(file.write_some("[WhiteElo \"?\"]\n"sv.bytes())); + TRY(file.write_some("[BlackElo \"?\"]\n"sv.bytes())); + TRY(file.write_some("[Variant \"Standard\"]\n"sv.bytes())); + TRY(file.write_some("[TimeControl \"-\"]\n"sv.bytes())); + TRY(file.write_some("[Annotator \"SerenityOS Chess\"]\n"sv.bytes())); + TRY(file.write_some("\n"sv.bytes())); // Movetext Section for (size_t i = 0, move_no = 1; i < m_board.moves().size(); i += 2, move_no++) { @@ -657,17 +658,17 @@ ErrorOr ChessWidget::export_pgn(Core::File& file) const if (i + 1 < m_board.moves().size()) { const DeprecatedString black = m_board.moves().at(i + 1).to_algebraic(); - TRY(file.write(DeprecatedString::formatted("{}. {} {} ", move_no, white, black).bytes())); + TRY(file.write_some(DeprecatedString::formatted("{}. {} {} ", move_no, white, black).bytes())); } else { - TRY(file.write(DeprecatedString::formatted("{}. {} ", move_no, white).bytes())); + TRY(file.write_some(DeprecatedString::formatted("{}. {} ", move_no, white).bytes())); } } - TRY(file.write("{ "sv.bytes())); - TRY(file.write(Chess::Board::result_to_string(m_board.game_result(), m_board.turn()).bytes())); - TRY(file.write(" } "sv.bytes())); - TRY(file.write(Chess::Board::result_to_points_string(m_board.game_result(), m_board.turn()).bytes())); - TRY(file.write("\n"sv.bytes())); + TRY(file.write_some("{ "sv.bytes())); + TRY(file.write_some(Chess::Board::result_to_string(m_board.game_result(), m_board.turn()).bytes())); + TRY(file.write_some(" } "sv.bytes())); + TRY(file.write_some(Chess::Board::result_to_points_string(m_board.game_result(), m_board.turn()).bytes())); + TRY(file.write_some("\n"sv.bytes())); return {}; } diff --git a/Userland/Libraries/LibArchive/TarStream.cpp b/Userland/Libraries/LibArchive/TarStream.cpp index f2c7725cefc..1515185f2f9 100644 --- a/Userland/Libraries/LibArchive/TarStream.cpp +++ b/Userland/Libraries/LibArchive/TarStream.cpp @@ -18,7 +18,7 @@ TarFileStream::TarFileStream(TarInputStream& tar_stream) { } -ErrorOr TarFileStream::read(Bytes bytes) +ErrorOr TarFileStream::read_some(Bytes bytes) { // Verify that the stream has not advanced. VERIFY(m_tar_stream.m_generation == m_generation); @@ -27,7 +27,7 @@ ErrorOr TarFileStream::read(Bytes bytes) auto to_read = min(bytes.size(), header_size - m_tar_stream.m_file_offset); - auto slice = TRY(m_tar_stream.m_stream->read(bytes.trim(to_read))); + auto slice = TRY(m_tar_stream.m_stream->read_some(bytes.trim(to_read))); m_tar_stream.m_file_offset += slice.size(); return slice; @@ -47,7 +47,7 @@ bool TarFileStream::is_eof() const || m_tar_stream.m_file_offset >= header_size; } -ErrorOr TarFileStream::write(ReadonlyBytes) +ErrorOr TarFileStream::write_some(ReadonlyBytes) { return Error::from_errno(EBADF); } @@ -92,7 +92,8 @@ ErrorOr TarInputStream::load_next_header() { size_t number_of_consecutive_zero_blocks = 0; while (true) { - auto header_span = TRY(m_stream->read(Bytes(&m_header, sizeof(m_header)))); + // FIXME: This should read the entire span. + auto header_span = TRY(m_stream->read_some(Bytes(&m_header, sizeof(m_header)))); if (header_span.size() != sizeof(m_header)) return Error::from_string_literal("Failed to read the entire header"); @@ -175,7 +176,7 @@ ErrorOr TarOutputStream::add_file(StringView path, mode_t mode, ReadonlyBy TRY(m_stream->write_entire_buffer(ReadonlyBytes { &padding, block_size - sizeof(header) })); size_t n_written = 0; while (n_written < bytes.size()) { - n_written += MUST(m_stream->write(bytes.slice(n_written, min(bytes.size() - n_written, block_size)))); + n_written += MUST(m_stream->write_some(bytes.slice(n_written, min(bytes.size() - n_written, block_size)))); } TRY(m_stream->write_entire_buffer(ReadonlyBytes { &padding, block_size - (n_written % block_size) })); return {}; diff --git a/Userland/Libraries/LibArchive/TarStream.h b/Userland/Libraries/LibArchive/TarStream.h index 61e104b35b6..45cc1eb1119 100644 --- a/Userland/Libraries/LibArchive/TarStream.h +++ b/Userland/Libraries/LibArchive/TarStream.h @@ -18,8 +18,8 @@ class TarInputStream; class TarFileStream : public Stream { public: - virtual ErrorOr read(Bytes) override; - virtual ErrorOr write(ReadonlyBytes) override; + virtual ErrorOr read_some(Bytes) override; + virtual ErrorOr write_some(ReadonlyBytes) override; virtual bool is_eof() const override; virtual bool is_open() const override { return true; }; virtual void close() override {}; diff --git a/Userland/Libraries/LibAudio/FlacLoader.cpp b/Userland/Libraries/LibAudio/FlacLoader.cpp index 10329815301..b530db5df29 100644 --- a/Userland/Libraries/LibAudio/FlacLoader.cpp +++ b/Userland/Libraries/LibAudio/FlacLoader.cpp @@ -111,7 +111,8 @@ MaybeLoaderError FlacLoaderPlugin::parse_header() // Parse checksum into a buffer first [[maybe_unused]] u128 md5_checksum; VERIFY(streaminfo_data.is_aligned_to_byte_boundary()); - auto md5_bytes_read = LOADER_TRY(streaminfo_data.read(md5_checksum.bytes())); + // FIXME: This should read the entire span. + auto md5_bytes_read = LOADER_TRY(streaminfo_data.read_some(md5_checksum.bytes())); FLAC_VERIFY(md5_bytes_read.size() == sizeof(md5_checksum), LoaderError::Category::IO, "MD5 Checksum size"); md5_checksum.bytes().copy_to({ m_md5_checksum, sizeof(m_md5_checksum) }); @@ -228,7 +229,7 @@ ErrorOr FlacLoaderPlugin::next_meta_block(Big // Blocks might exceed our buffer size. auto bytes_left_to_read = block_data.bytes(); while (bytes_left_to_read.size()) { - auto read_bytes = LOADER_TRY(bit_input.read(bytes_left_to_read)); + auto read_bytes = LOADER_TRY(bit_input.read_some(bytes_left_to_read)); bytes_left_to_read = bytes_left_to_read.slice(read_bytes.size()); } @@ -870,7 +871,8 @@ ErrorOr read_utf8_char(BigEndianInputBitStream& input) u64 character; u8 buffer = 0; Bytes buffer_bytes { &buffer, 1 }; - TRY(input.read(buffer_bytes)); + // FIXME: This should read the entire span. + TRY(input.read_some(buffer_bytes)); u8 start_byte = buffer_bytes[0]; // Signal byte is zero: ASCII character if ((start_byte & 0b10000000) == 0) { @@ -886,7 +888,8 @@ ErrorOr read_utf8_char(BigEndianInputBitStream& input) u8 start_byte_bitmask = AK::exp2(bits_from_start_byte) - 1; character = start_byte_bitmask & start_byte; for (u8 i = length - 1; i > 0; --i) { - TRY(input.read(buffer_bytes)); + // FIXME: This should read the entire span. + TRY(input.read_some(buffer_bytes)); u8 current_byte = buffer_bytes[0]; character = (character << 6) | (current_byte & 0b00111111); } diff --git a/Userland/Libraries/LibAudio/MP3Loader.cpp b/Userland/Libraries/LibAudio/MP3Loader.cpp index 33af341fdcf..674f398ae27 100644 --- a/Userland/Libraries/LibAudio/MP3Loader.cpp +++ b/Userland/Libraries/LibAudio/MP3Loader.cpp @@ -233,7 +233,8 @@ ErrorOr MP3LoaderPlugin::read_frame_data(MP3::Header size_t old_reservoir_size = m_bit_reservoir.used_buffer_size(); LOADER_TRY(m_bitstream->read_entire_buffer(buffer)); - if (LOADER_TRY(m_bit_reservoir.write(buffer)) != header.slot_count) + // FIXME: This should write the entire span. + if (LOADER_TRY(m_bit_reservoir.write_some(buffer)) != header.slot_count) return LoaderError { LoaderError::Category::IO, m_loaded_samples, "Could not write frame into bit reservoir." }; // If we don't have enough data in the reservoir to process this frame, skip it (but keep the data). diff --git a/Userland/Libraries/LibCompress/Brotli.cpp b/Userland/Libraries/LibCompress/Brotli.cpp index ee16bff271a..6221bc15f75 100644 --- a/Userland/Libraries/LibCompress/Brotli.cpp +++ b/Userland/Libraries/LibCompress/Brotli.cpp @@ -573,7 +573,7 @@ size_t BrotliDecompressionStream::literal_code_index_from_context() return literal_code_index; } -ErrorOr BrotliDecompressionStream::read(Bytes output_buffer) +ErrorOr BrotliDecompressionStream::read_some(Bytes output_buffer) { size_t bytes_read = 0; while (bytes_read < output_buffer.size()) { @@ -653,7 +653,7 @@ ErrorOr BrotliDecompressionStream::read(Bytes output_buffer) Bytes temp_bytes { temp_buffer, 4096 }; while (skip_length > 0) { Bytes temp_bytes_slice = temp_bytes.slice(0, min(4096, skip_length)); - auto metadata_bytes = TRY(m_input_stream.read(temp_bytes_slice)); + auto metadata_bytes = TRY(m_input_stream.read_some(temp_bytes_slice)); if (metadata_bytes.is_empty()) return Error::from_string_literal("eof"); if (metadata_bytes.last() == 0) @@ -741,7 +741,7 @@ ErrorOr BrotliDecompressionStream::read(Bytes output_buffer) size_t number_of_fitting_bytes = min(output_buffer.size() - bytes_read, m_bytes_left); VERIFY(number_of_fitting_bytes > 0); - auto uncompressed_bytes = TRY(m_input_stream.read(output_buffer.slice(bytes_read, number_of_fitting_bytes))); + auto uncompressed_bytes = TRY(m_input_stream.read_some(output_buffer.slice(bytes_read, number_of_fitting_bytes))); if (uncompressed_bytes.is_empty()) return Error::from_string_literal("eof"); diff --git a/Userland/Libraries/LibCompress/Brotli.h b/Userland/Libraries/LibCompress/Brotli.h index 735abf9aa29..e1bbe003502 100644 --- a/Userland/Libraries/LibCompress/Brotli.h +++ b/Userland/Libraries/LibCompress/Brotli.h @@ -104,8 +104,8 @@ public: public: BrotliDecompressionStream(Stream&); - ErrorOr read(Bytes output_buffer) override; - ErrorOr write(ReadonlyBytes bytes) override { return m_input_stream.write(bytes); } + ErrorOr read_some(Bytes output_buffer) override; + ErrorOr write_some(ReadonlyBytes bytes) override { return m_input_stream.write_some(bytes); } bool is_eof() const override; bool is_open() const override { return m_input_stream.is_open(); } void close() override { m_input_stream.close(); } diff --git a/Userland/Libraries/LibCompress/Deflate.cpp b/Userland/Libraries/LibCompress/Deflate.cpp index 189a0d2fa87..b790d317f42 100644 --- a/Userland/Libraries/LibCompress/Deflate.cpp +++ b/Userland/Libraries/LibCompress/Deflate.cpp @@ -181,7 +181,7 @@ ErrorOr DeflateDecompressor::UncompressedBlock::try_read_more() Array temporary_buffer; auto readable_bytes = temporary_buffer.span().trim(min(m_bytes_remaining, m_decompressor.m_output_buffer.empty_space())); - auto read_bytes = TRY(m_decompressor.m_input_stream->read(readable_bytes)); + auto read_bytes = TRY(m_decompressor.m_input_stream->read_some(readable_bytes)); auto written_bytes = m_decompressor.m_output_buffer.write(read_bytes); VERIFY(read_bytes.size() == written_bytes); @@ -209,7 +209,7 @@ DeflateDecompressor::~DeflateDecompressor() m_uncompressed_block.~UncompressedBlock(); } -ErrorOr DeflateDecompressor::read(Bytes bytes) +ErrorOr DeflateDecompressor::read_some(Bytes bytes) { size_t total_read = 0; while (total_read < bytes.size()) { @@ -225,9 +225,10 @@ ErrorOr DeflateDecompressor::read(Bytes bytes) if (block_type == 0b00) { m_input_stream->align_to_byte_boundary(); + // FIXME: This should read the entire span. LittleEndian length, negated_length; - TRY(m_input_stream->read(length.bytes())); - TRY(m_input_stream->read(negated_length.bytes())); + TRY(m_input_stream->read_some(length.bytes())); + TRY(m_input_stream->read_some(negated_length.bytes())); if ((length ^ 0xffff) != negated_length) return Error::from_string_literal("Calculated negated length does not equal stored negated length"); @@ -301,7 +302,7 @@ ErrorOr DeflateDecompressor::read(Bytes bytes) bool DeflateDecompressor::is_eof() const { return m_state == State::Idle && m_read_final_bock; } -ErrorOr DeflateDecompressor::write(ReadonlyBytes) +ErrorOr DeflateDecompressor::write_some(ReadonlyBytes) { return Error::from_errno(EBADF); } @@ -323,7 +324,7 @@ ErrorOr DeflateDecompressor::decompress_all(ReadonlyBytes bytes) auto buffer = TRY(ByteBuffer::create_uninitialized(4096)); while (!deflate_stream->is_eof()) { - auto const slice = TRY(deflate_stream->read(buffer)); + auto const slice = TRY(deflate_stream->read_some(buffer)); TRY(output_stream.write_entire_buffer(slice)); } @@ -468,12 +469,12 @@ DeflateCompressor::~DeflateCompressor() VERIFY(m_finished); } -ErrorOr DeflateCompressor::read(Bytes) +ErrorOr DeflateCompressor::read_some(Bytes) { return Error::from_errno(EBADF); } -ErrorOr DeflateCompressor::write(ReadonlyBytes bytes) +ErrorOr DeflateCompressor::write_some(ReadonlyBytes bytes) { VERIFY(!m_finished); diff --git a/Userland/Libraries/LibCompress/Deflate.h b/Userland/Libraries/LibCompress/Deflate.h index 1e165f9a7a0..c62f1bd34e4 100644 --- a/Userland/Libraries/LibCompress/Deflate.h +++ b/Userland/Libraries/LibCompress/Deflate.h @@ -79,8 +79,8 @@ public: static ErrorOr> construct(MaybeOwned stream); ~DeflateDecompressor(); - virtual ErrorOr read(Bytes) override; - virtual ErrorOr write(ReadonlyBytes) override; + virtual ErrorOr read_some(Bytes) override; + virtual ErrorOr write_some(ReadonlyBytes) override; virtual bool is_eof() const override; virtual bool is_open() const override; virtual void close() override; @@ -144,8 +144,8 @@ public: static ErrorOr> construct(MaybeOwned, CompressionLevel = CompressionLevel::GOOD); ~DeflateCompressor(); - virtual ErrorOr read(Bytes) override; - virtual ErrorOr write(ReadonlyBytes) override; + virtual ErrorOr read_some(Bytes) override; + virtual ErrorOr write_some(ReadonlyBytes) override; virtual bool is_eof() const override; virtual bool is_open() const override; virtual void close() override; diff --git a/Userland/Libraries/LibCompress/Gzip.cpp b/Userland/Libraries/LibCompress/Gzip.cpp index 0fb1980f4bd..56f6daa535b 100644 --- a/Userland/Libraries/LibCompress/Gzip.cpp +++ b/Userland/Libraries/LibCompress/Gzip.cpp @@ -60,7 +60,7 @@ GzipDecompressor::~GzipDecompressor() m_current_member.clear(); } -ErrorOr GzipDecompressor::read(Bytes bytes) +ErrorOr GzipDecompressor::read_some(Bytes bytes) { size_t total_read = 0; while (total_read < bytes.size()) { @@ -70,14 +70,15 @@ ErrorOr GzipDecompressor::read(Bytes bytes) auto slice = bytes.slice(total_read); if (m_current_member) { - auto current_slice = TRY(current_member().m_stream->read(slice)); + auto current_slice = TRY(current_member().m_stream->read_some(slice)); current_member().m_checksum.update(current_slice); current_member().m_nread += current_slice.size(); if (current_slice.size() < slice.size()) { + // FIXME: This should read the entire span. LittleEndian crc32, input_size; - TRY(m_input_stream->read(crc32.bytes())); - TRY(m_input_stream->read(input_size.bytes())); + TRY(m_input_stream->read_some(crc32.bytes())); + TRY(m_input_stream->read_some(input_size.bytes())); if (crc32 != current_member().m_checksum.digest()) return Error::from_string_literal("Stored CRC32 does not match the calculated CRC32 of the current member"); @@ -95,7 +96,7 @@ ErrorOr GzipDecompressor::read(Bytes bytes) continue; } else { auto current_partial_header_slice = Bytes { m_partial_header, sizeof(BlockHeader) }.slice(m_partial_header_offset); - auto current_partial_header_data = TRY(m_input_stream->read(current_partial_header_slice)); + auto current_partial_header_data = TRY(m_input_stream->read_some(current_partial_header_slice)); m_partial_header_offset += current_partial_header_data.size(); if (is_eof()) @@ -115,16 +116,18 @@ ErrorOr GzipDecompressor::read(Bytes bytes) return Error::from_string_literal("Header is not supported by implementation"); if (header.flags & Flags::FEXTRA) { + // FIXME: This should read the entire span. LittleEndian subfield_id, length; - TRY(m_input_stream->read(subfield_id.bytes())); - TRY(m_input_stream->read(length.bytes())); + TRY(m_input_stream->read_some(subfield_id.bytes())); + TRY(m_input_stream->read_some(length.bytes())); TRY(m_input_stream->discard(length)); } auto discard_string = [&]() -> ErrorOr { char next_char; do { - TRY(m_input_stream->read({ &next_char, sizeof(next_char) })); + // FIXME: This should read the entire span. + TRY(m_input_stream->read_some({ &next_char, sizeof(next_char) })); } while (next_char); return {}; @@ -137,8 +140,9 @@ ErrorOr GzipDecompressor::read(Bytes bytes) TRY(discard_string()); if (header.flags & Flags::FHCRC) { + // FIXME: This should read the entire span. LittleEndian crc16; - TRY(m_input_stream->read(crc16.bytes())); + TRY(m_input_stream->read_some(crc16.bytes())); // FIXME: we should probably verify this instead of just assuming it matches } @@ -170,7 +174,7 @@ ErrorOr GzipDecompressor::decompress_all(ReadonlyBytes bytes) auto buffer = TRY(ByteBuffer::create_uninitialized(4096)); while (!gzip_stream->is_eof()) { - auto const data = TRY(gzip_stream->read(buffer)); + auto const data = TRY(gzip_stream->read_some(buffer)); TRY(output_stream.write_entire_buffer(data)); } @@ -181,7 +185,7 @@ ErrorOr GzipDecompressor::decompress_all(ReadonlyBytes bytes) bool GzipDecompressor::is_eof() const { return m_input_stream->is_eof(); } -ErrorOr GzipDecompressor::write(ReadonlyBytes) +ErrorOr GzipDecompressor::write_some(ReadonlyBytes) { return Error::from_errno(EBADF); } @@ -191,12 +195,12 @@ GzipCompressor::GzipCompressor(MaybeOwned stream) { } -ErrorOr GzipCompressor::read(Bytes) +ErrorOr GzipCompressor::read_some(Bytes) { return Error::from_errno(EBADF); } -ErrorOr GzipCompressor::write(ReadonlyBytes bytes) +ErrorOr GzipCompressor::write_some(ReadonlyBytes bytes) { BlockHeader header; header.identification_1 = 0x1f; diff --git a/Userland/Libraries/LibCompress/Gzip.h b/Userland/Libraries/LibCompress/Gzip.h index 2a297103efb..85a33eae901 100644 --- a/Userland/Libraries/LibCompress/Gzip.h +++ b/Userland/Libraries/LibCompress/Gzip.h @@ -45,8 +45,8 @@ public: GzipDecompressor(NonnullOwnPtr); ~GzipDecompressor(); - virtual ErrorOr read(Bytes) override; - virtual ErrorOr write(ReadonlyBytes) override; + virtual ErrorOr read_some(Bytes) override; + virtual ErrorOr write_some(ReadonlyBytes) override; virtual bool is_eof() const override; virtual bool is_open() const override { return true; } virtual void close() override {}; @@ -84,8 +84,8 @@ class GzipCompressor final : public Stream { public: GzipCompressor(MaybeOwned); - virtual ErrorOr read(Bytes) override; - virtual ErrorOr write(ReadonlyBytes) override; + virtual ErrorOr read_some(Bytes) override; + virtual ErrorOr write_some(ReadonlyBytes) override; virtual bool is_eof() const override; virtual bool is_open() const override; virtual void close() override; diff --git a/Userland/Libraries/LibCompress/Zlib.cpp b/Userland/Libraries/LibCompress/Zlib.cpp index 04fa6be768b..39df8779b68 100644 --- a/Userland/Libraries/LibCompress/Zlib.cpp +++ b/Userland/Libraries/LibCompress/Zlib.cpp @@ -113,21 +113,22 @@ ErrorOr ZlibCompressor::write_header(ZlibCompressionMethod compression_met // FIXME: Support pre-defined dictionaries. - TRY(m_output_stream->write(header.as_u16.bytes())); + // FIXME: This should write the entire span. + TRY(m_output_stream->write_some(header.as_u16.bytes())); return {}; } -ErrorOr ZlibCompressor::read(Bytes) +ErrorOr ZlibCompressor::read_some(Bytes) { return Error::from_errno(EBADF); } -ErrorOr ZlibCompressor::write(ReadonlyBytes bytes) +ErrorOr ZlibCompressor::write_some(ReadonlyBytes bytes) { VERIFY(!m_finished); - size_t n_written = TRY(m_compressor->write(bytes)); + size_t n_written = TRY(m_compressor->write_some(bytes)); m_adler32_checksum.update(bytes.trim(n_written)); return n_written; } @@ -154,7 +155,8 @@ ErrorOr ZlibCompressor::finish() TRY(static_cast(m_compressor.ptr())->final_flush()); NetworkOrdered adler_sum = m_adler32_checksum.digest(); - TRY(m_output_stream->write(adler_sum.bytes())); + // FIXME: This should write the entire span. + TRY(m_output_stream->write_some(adler_sum.bytes())); m_finished = true; diff --git a/Userland/Libraries/LibCompress/Zlib.h b/Userland/Libraries/LibCompress/Zlib.h index 44eb4e1bf48..2039973f2bc 100644 --- a/Userland/Libraries/LibCompress/Zlib.h +++ b/Userland/Libraries/LibCompress/Zlib.h @@ -67,8 +67,8 @@ public: static ErrorOr> construct(MaybeOwned, ZlibCompressionLevel = ZlibCompressionLevel::Default); ~ZlibCompressor(); - virtual ErrorOr read(Bytes) override; - virtual ErrorOr write(ReadonlyBytes) override; + virtual ErrorOr read_some(Bytes) override; + virtual ErrorOr write_some(ReadonlyBytes) override; virtual bool is_eof() const override; virtual bool is_open() const override; virtual void close() override; diff --git a/Userland/Libraries/LibCore/ConfigFile.cpp b/Userland/Libraries/LibCore/ConfigFile.cpp index a6101870276..faa333a2254 100644 --- a/Userland/Libraries/LibCore/ConfigFile.cpp +++ b/Userland/Libraries/LibCore/ConfigFile.cpp @@ -179,10 +179,11 @@ ErrorOr ConfigFile::sync() TRY(m_file->seek(0, SeekMode::SetPosition)); for (auto& it : m_groups) { - TRY(m_file->write(DeprecatedString::formatted("[{}]\n", it.key).bytes())); + // FIXME: This should write the entire span. + TRY(m_file->write_some(DeprecatedString::formatted("[{}]\n", it.key).bytes())); for (auto& jt : it.value) - TRY(m_file->write(DeprecatedString::formatted("{}={}\n", jt.key, jt.value).bytes())); - TRY(m_file->write("\n"sv.bytes())); + TRY(m_file->write_some(DeprecatedString::formatted("{}={}\n", jt.key, jt.value).bytes())); + TRY(m_file->write_some("\n"sv.bytes())); } m_dirty = false; diff --git a/Userland/Libraries/LibCore/EventLoop.cpp b/Userland/Libraries/LibCore/EventLoop.cpp index dd5bb3acb1d..b5a0c985218 100644 --- a/Userland/Libraries/LibCore/EventLoop.cpp +++ b/Userland/Libraries/LibCore/EventLoop.cpp @@ -169,7 +169,7 @@ private: #ifdef AK_OS_SERENITY m_socket->on_ready_to_read = [this] { u32 length; - auto maybe_bytes_read = m_socket->read({ (u8*)&length, sizeof(length) }); + auto maybe_bytes_read = m_socket->read_some({ (u8*)&length, sizeof(length) }); if (maybe_bytes_read.is_error()) { dbgln("InspectorServerConnection: Failed to read message length from inspector server connection: {}", maybe_bytes_read.error()); shutdown(); @@ -186,7 +186,7 @@ private: VERIFY(bytes_read.size() == sizeof(length)); auto request_buffer = ByteBuffer::create_uninitialized(length).release_value(); - maybe_bytes_read = m_socket->read(request_buffer.bytes()); + maybe_bytes_read = m_socket->read_some(request_buffer.bytes()); if (maybe_bytes_read.is_error()) { dbgln("InspectorServerConnection: Failed to read message content from inspector server connection: {}", maybe_bytes_read.error()); shutdown(); @@ -221,10 +221,11 @@ public: auto bytes_to_send = serialized.bytes(); u32 length = bytes_to_send.size(); // FIXME: Propagate errors - auto sent = MUST(m_socket->write({ (u8 const*)&length, sizeof(length) })); + // FIXME: This should write the entire span. + auto sent = MUST(m_socket->write_some({ (u8 const*)&length, sizeof(length) })); VERIFY(sent == sizeof(length)); while (!bytes_to_send.is_empty()) { - size_t bytes_sent = MUST(m_socket->write(bytes_to_send)); + size_t bytes_sent = MUST(m_socket->write_some(bytes_to_send)); bytes_to_send = bytes_to_send.slice(bytes_sent); } } diff --git a/Userland/Libraries/LibCore/File.cpp b/Userland/Libraries/LibCore/File.cpp index d9eba43da0c..7ce5bb42dcd 100644 --- a/Userland/Libraries/LibCore/File.cpp +++ b/Userland/Libraries/LibCore/File.cpp @@ -99,7 +99,7 @@ ErrorOr File::open_path(StringView filename, mode_t permissions) return {}; } -ErrorOr File::read(Bytes buffer) +ErrorOr File::read_some(Bytes buffer) { if (!has_flag(m_mode, OpenMode::Read)) { // NOTE: POSIX says that if the fd is not open for reading, the call @@ -121,7 +121,7 @@ ErrorOr File::read_until_eof(size_t block_size) return read_until_eof_impl(block_size, potential_file_size); } -ErrorOr File::write(ReadonlyBytes buffer) +ErrorOr File::write_some(ReadonlyBytes buffer) { if (!has_flag(m_mode, OpenMode::Write)) { // NOTE: Same deal as Read. diff --git a/Userland/Libraries/LibCore/File.h b/Userland/Libraries/LibCore/File.h index 880aad25a62..22be6a5ec5b 100644 --- a/Userland/Libraries/LibCore/File.h +++ b/Userland/Libraries/LibCore/File.h @@ -59,9 +59,9 @@ public: return *this; } - virtual ErrorOr read(Bytes) override; + virtual ErrorOr read_some(Bytes) override; virtual ErrorOr read_until_eof(size_t block_size = 4096) override; - virtual ErrorOr write(ReadonlyBytes) override; + virtual ErrorOr write_some(ReadonlyBytes) override; virtual bool is_eof() const override; virtual bool is_open() const override; virtual void close() override; diff --git a/Userland/Libraries/LibCore/NetworkJob.h b/Userland/Libraries/LibCore/NetworkJob.h index 5b013273be5..a7c10de959e 100644 --- a/Userland/Libraries/LibCore/NetworkJob.h +++ b/Userland/Libraries/LibCore/NetworkJob.h @@ -57,7 +57,7 @@ protected: void did_fail(Error); void did_progress(Optional total_size, u32 downloaded); - ErrorOr do_write(ReadonlyBytes bytes) { return m_output_stream.write(bytes); } + ErrorOr do_write(ReadonlyBytes bytes) { return m_output_stream.write_some(bytes); } private: RefPtr m_response; diff --git a/Userland/Libraries/LibCore/SOCKSProxyClient.cpp b/Userland/Libraries/LibCore/SOCKSProxyClient.cpp index 61f3cfaa6ca..532d12604f7 100644 --- a/Userland/Libraries/LibCore/SOCKSProxyClient.cpp +++ b/Userland/Libraries/LibCore/SOCKSProxyClient.cpp @@ -102,12 +102,14 @@ ErrorOr send_version_identifier_and_method_selection_message(Core::Socket& .method_count = 1, .methods = { to_underlying(method) }, }; - auto size = TRY(socket.write({ &message, sizeof(message) })); + // FIXME: This should write the entire span. + auto size = TRY(socket.write_some({ &message, sizeof(message) })); if (size != sizeof(message)) return Error::from_string_literal("SOCKS negotiation failed: Failed to send version identifier and method selection message"); Socks5InitialResponse response; - size = TRY(socket.read({ &response, sizeof(response) })).size(); + // FIXME: This should read the entire span. + size = TRY(socket.read_some({ &response, sizeof(response) })).size(); if (size != sizeof(response)) return Error::from_string_literal("SOCKS negotiation failed: Failed to receive initial response"); @@ -133,7 +135,8 @@ ErrorOr send_connect_request_message(Core::Socket& socket, Core::SOCKSPro .port = htons(port), }; - auto size = TRY(stream.write({ &header, sizeof(header) })); + // FIXME: This should write the entire span. + auto size = TRY(stream.write_some({ &header, sizeof(header) })); if (size != sizeof(header)) return Error::from_string_literal("SOCKS negotiation failed: Failed to send connect request header"); @@ -142,10 +145,12 @@ ErrorOr send_connect_request_message(Core::Socket& socket, Core::SOCKSPro u8 address_data[2]; address_data[0] = to_underlying(AddressType::DomainName); address_data[1] = hostname.length(); - auto size = TRY(stream.write({ address_data, sizeof(address_data) })); + // FIXME: This should write the entire span. + auto size = TRY(stream.write_some({ address_data, sizeof(address_data) })); if (size != array_size(address_data)) return Error::from_string_literal("SOCKS negotiation failed: Failed to send connect request address data"); - TRY(stream.write({ hostname.characters(), hostname.length() })); + // FIXME: This should write the entire span. + TRY(stream.write_some({ hostname.characters(), hostname.length() })); return {}; }, [&](u32 ipv4) -> ErrorOr { @@ -153,25 +158,29 @@ ErrorOr send_connect_request_message(Core::Socket& socket, Core::SOCKSPro address_data[0] = to_underlying(AddressType::IPV4); u32 network_ordered_ipv4 = NetworkOrdered(ipv4); memcpy(address_data + 1, &network_ordered_ipv4, sizeof(network_ordered_ipv4)); - auto size = TRY(stream.write({ address_data, sizeof(address_data) })); + // FIXME: This should write the entire span. + auto size = TRY(stream.write_some({ address_data, sizeof(address_data) })); if (size != array_size(address_data)) return Error::from_string_literal("SOCKS negotiation failed: Failed to send connect request address data"); return {}; })); - size = TRY(stream.write({ &trailer, sizeof(trailer) })); + // FIXME: This should write the entire span. + size = TRY(stream.write_some({ &trailer, sizeof(trailer) })); if (size != sizeof(trailer)) return Error::from_string_literal("SOCKS negotiation failed: Failed to send connect request trailer"); auto buffer = TRY(ByteBuffer::create_uninitialized(stream.used_buffer_size())); TRY(stream.read_entire_buffer(buffer.bytes())); - size = TRY(socket.write({ buffer.data(), buffer.size() })); + // FIXME: This should write the entire span. + size = TRY(socket.write_some({ buffer.data(), buffer.size() })); if (size != buffer.size()) return Error::from_string_literal("SOCKS negotiation failed: Failed to send connect request"); Socks5ConnectResponseHeader response_header; - size = TRY(socket.read({ &response_header, sizeof(response_header) })).size(); + // FIXME: This should read the entire span. + size = TRY(socket.read_some({ &response_header, sizeof(response_header) })).size(); if (size != sizeof(response_header)) return Error::from_string_literal("SOCKS negotiation failed: Failed to receive connect response header"); @@ -179,26 +188,30 @@ ErrorOr send_connect_request_message(Core::Socket& socket, Core::SOCKSPro return Error::from_string_literal("SOCKS negotiation failed: Invalid version identifier"); u8 response_address_type; - size = TRY(socket.read({ &response_address_type, sizeof(response_address_type) })).size(); + // FIXME: This should read the entire span. + size = TRY(socket.read_some({ &response_address_type, sizeof(response_address_type) })).size(); if (size != sizeof(response_address_type)) return Error::from_string_literal("SOCKS negotiation failed: Failed to receive connect response address type"); switch (AddressType(response_address_type)) { case AddressType::IPV4: { u8 response_address_data[4]; - size = TRY(socket.read({ response_address_data, sizeof(response_address_data) })).size(); + // FIXME: This should read the entire span. + size = TRY(socket.read_some({ response_address_data, sizeof(response_address_data) })).size(); if (size != sizeof(response_address_data)) return Error::from_string_literal("SOCKS negotiation failed: Failed to receive connect response address data"); break; } case AddressType::DomainName: { u8 response_address_length; - size = TRY(socket.read({ &response_address_length, sizeof(response_address_length) })).size(); + // FIXME: This should read the entire span. + size = TRY(socket.read_some({ &response_address_length, sizeof(response_address_length) })).size(); if (size != sizeof(response_address_length)) return Error::from_string_literal("SOCKS negotiation failed: Failed to receive connect response address length"); ByteBuffer buffer; buffer.resize(response_address_length); - size = TRY(socket.read(buffer)).size(); + // FIXME: This should read the entire span. + size = TRY(socket.read_some(buffer)).size(); if (size != response_address_length) return Error::from_string_literal("SOCKS negotiation failed: Failed to receive connect response address data"); break; @@ -209,7 +222,8 @@ ErrorOr send_connect_request_message(Core::Socket& socket, Core::SOCKSPro } u16 bound_port; - size = TRY(socket.read({ &bound_port, sizeof(bound_port) })).size(); + // FIXME: This should read the entire span. + size = TRY(socket.read_some({ &bound_port, sizeof(bound_port) })).size(); if (size != sizeof(bound_port)) return Error::from_string_literal("SOCKS negotiation failed: Failed to receive connect response bound port"); @@ -221,37 +235,44 @@ ErrorOr send_username_password_authentication_message(Core::Socket& socket, AllocatingMemoryStream stream; u8 version = 0x01; - auto size = TRY(stream.write({ &version, sizeof(version) })); + // FIXME: This should write the entire span. + auto size = TRY(stream.write_some({ &version, sizeof(version) })); if (size != sizeof(version)) return Error::from_string_literal("SOCKS negotiation failed: Failed to send username/password authentication message"); u8 username_length = auth_data.username.length(); - size = TRY(stream.write({ &username_length, sizeof(username_length) })); + // FIXME: This should write the entire span. + size = TRY(stream.write_some({ &username_length, sizeof(username_length) })); if (size != sizeof(username_length)) return Error::from_string_literal("SOCKS negotiation failed: Failed to send username/password authentication message"); - size = TRY(stream.write({ auth_data.username.characters(), auth_data.username.length() })); + // FIXME: This should write the entire span. + size = TRY(stream.write_some({ auth_data.username.characters(), auth_data.username.length() })); if (size != auth_data.username.length()) return Error::from_string_literal("SOCKS negotiation failed: Failed to send username/password authentication message"); u8 password_length = auth_data.password.length(); - size = TRY(stream.write({ &password_length, sizeof(password_length) })); + // FIXME: This should write the entire span. + size = TRY(stream.write_some({ &password_length, sizeof(password_length) })); if (size != sizeof(password_length)) return Error::from_string_literal("SOCKS negotiation failed: Failed to send username/password authentication message"); - size = TRY(stream.write({ auth_data.password.characters(), auth_data.password.length() })); + // FIXME: This should write the entire span. + size = TRY(stream.write_some({ auth_data.password.characters(), auth_data.password.length() })); if (size != auth_data.password.length()) return Error::from_string_literal("SOCKS negotiation failed: Failed to send username/password authentication message"); auto buffer = TRY(ByteBuffer::create_uninitialized(stream.used_buffer_size())); TRY(stream.read_entire_buffer(buffer.bytes())); - size = TRY(socket.write(buffer)); + // FIXME: This should write the entire span. + size = TRY(socket.write_some(buffer)); if (size != buffer.size()) return Error::from_string_literal("SOCKS negotiation failed: Failed to send username/password authentication message"); Socks5UsernamePasswordResponse response; - size = TRY(socket.read({ &response, sizeof(response) })).size(); + // FIXME: This should read the entire span. + size = TRY(socket.read_some({ &response, sizeof(response) })).size(); if (size != sizeof(response)) return Error::from_string_literal("SOCKS negotiation failed: Failed to receive username/password authentication response"); diff --git a/Userland/Libraries/LibCore/SOCKSProxyClient.h b/Userland/Libraries/LibCore/SOCKSProxyClient.h index aff0bf1a644..24b47bb606b 100644 --- a/Userland/Libraries/LibCore/SOCKSProxyClient.h +++ b/Userland/Libraries/LibCore/SOCKSProxyClient.h @@ -37,8 +37,8 @@ public: virtual ~SOCKSProxyClient() override; // ^Stream::Stream - virtual ErrorOr read(Bytes bytes) override { return m_socket.read(bytes); } - virtual ErrorOr write(ReadonlyBytes bytes) override { return m_socket.write(bytes); } + virtual ErrorOr read_some(Bytes bytes) override { return m_socket.read_some(bytes); } + virtual ErrorOr write_some(ReadonlyBytes bytes) override { return m_socket.write_some(bytes); } virtual bool is_eof() const override { return m_socket.is_eof(); } virtual bool is_open() const override { return m_socket.is_open(); } virtual void close() override { m_socket.close(); } diff --git a/Userland/Libraries/LibCore/Socket.h b/Userland/Libraries/LibCore/Socket.h index 08310046ce3..0906b02116d 100644 --- a/Userland/Libraries/LibCore/Socket.h +++ b/Userland/Libraries/LibCore/Socket.h @@ -176,8 +176,8 @@ public: return *this; } - virtual ErrorOr read(Bytes buffer) override { return m_helper.read(buffer, default_flags()); } - virtual ErrorOr write(ReadonlyBytes buffer) override { return m_helper.write(buffer, default_flags()); } + virtual ErrorOr read_some(Bytes buffer) override { return m_helper.read(buffer, default_flags()); } + virtual ErrorOr write_some(ReadonlyBytes buffer) override { return m_helper.write(buffer, default_flags()); } virtual bool is_eof() const override { return m_helper.is_eof(); } virtual bool is_open() const override { return m_helper.is_open(); }; virtual void close() override { m_helper.close(); }; @@ -236,7 +236,7 @@ public: return *this; } - virtual ErrorOr read(Bytes buffer) override + virtual ErrorOr read_some(Bytes buffer) override { auto pending_bytes = TRY(this->pending_bytes()); if (pending_bytes > buffer.size()) { @@ -251,7 +251,7 @@ public: return m_helper.read(buffer, default_flags()); } - virtual ErrorOr write(ReadonlyBytes buffer) override { return m_helper.write(buffer, default_flags()); } + virtual ErrorOr write_some(ReadonlyBytes buffer) override { return m_helper.write(buffer, default_flags()); } virtual bool is_eof() const override { return m_helper.is_eof(); } virtual bool is_open() const override { return m_helper.is_open(); } virtual void close() override { m_helper.close(); } @@ -310,8 +310,8 @@ public: return *this; } - virtual ErrorOr read(Bytes buffer) override { return m_helper.read(buffer, default_flags()); } - virtual ErrorOr write(ReadonlyBytes buffer) override { return m_helper.write(buffer, default_flags()); } + virtual ErrorOr read_some(Bytes buffer) override { return m_helper.read(buffer, default_flags()); } + virtual ErrorOr write_some(ReadonlyBytes buffer) override { return m_helper.write(buffer, default_flags()); } virtual bool is_eof() const override { return m_helper.is_eof(); } virtual bool is_open() const override { return m_helper.is_open(); } virtual void close() override { m_helper.close(); } @@ -398,8 +398,8 @@ public: return *this; } - virtual ErrorOr read(Bytes buffer) override { return m_helper.read(move(buffer)); } - virtual ErrorOr write(ReadonlyBytes buffer) override { return m_helper.stream().write(buffer); } + virtual ErrorOr read_some(Bytes buffer) override { return m_helper.read(move(buffer)); } + virtual ErrorOr write_some(ReadonlyBytes buffer) override { return m_helper.stream().write_some(buffer); } virtual bool is_eof() const override { return m_helper.is_eof(); } virtual bool is_open() const override { return m_helper.stream().is_open(); } virtual void close() override { m_helper.stream().close(); } @@ -483,8 +483,8 @@ public: return {}; } - virtual ErrorOr read(Bytes buffer) override { return m_socket.read(move(buffer)); } - virtual ErrorOr write(ReadonlyBytes buffer) override { return m_socket.write(buffer); } + virtual ErrorOr read_some(Bytes buffer) override { return m_socket.read(move(buffer)); } + virtual ErrorOr write_some(ReadonlyBytes buffer) override { return m_socket.write(buffer); } virtual bool is_eof() const override { return m_socket.is_eof(); } virtual bool is_open() const override { return m_socket.is_open(); } virtual void close() override { m_socket.close(); } diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp index 68a47520e50..74482ed7bb3 100644 --- a/Userland/Libraries/LibGUI/TextEditor.cpp +++ b/Userland/Libraries/LibGUI/TextEditor.cpp @@ -1593,8 +1593,9 @@ ErrorOr TextEditor::write_to_file(Core::File& file) // A size 0 file doesn't need a data copy. } else { for (size_t i = 0; i < line_count(); ++i) { - TRY(file.write(line(i).to_utf8().bytes())); - TRY(file.write("\n"sv.bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(line(i).to_utf8().bytes())); + TRY(file.write_some("\n"sv.bytes())); } } document().set_unmodified(); diff --git a/Userland/Libraries/LibGemini/Job.cpp b/Userland/Libraries/LibGemini/Job.cpp index a7cde0a21f8..9cfb6483f08 100644 --- a/Userland/Libraries/LibGemini/Job.cpp +++ b/Userland/Libraries/LibGemini/Job.cpp @@ -65,7 +65,7 @@ ErrorOr Job::read_line(size_t size) ErrorOr Job::receive(size_t size) { ByteBuffer buffer = TRY(ByteBuffer::create_uninitialized(size)); - auto nread = TRY(m_socket->read(buffer)).size(); + auto nread = TRY(m_socket->read_some(buffer)).size(); return buffer.slice(0, nread); } diff --git a/Userland/Libraries/LibHTTP/Job.cpp b/Userland/Libraries/LibHTTP/Job.cpp index 4914734ff1a..1f308b214e2 100644 --- a/Userland/Libraries/LibHTTP/Job.cpp +++ b/Userland/Libraries/LibHTTP/Job.cpp @@ -184,7 +184,7 @@ ErrorOr Job::receive(size_t size) auto buffer = TRY(ByteBuffer::create_uninitialized(size)); size_t nread; do { - auto result = m_socket->read(buffer); + auto result = m_socket->read_some(buffer); if (result.is_error() && result.error().is_errno() && result.error().code() == EINTR) continue; nread = TRY(result).size(); diff --git a/Userland/Libraries/LibIMAP/Client.cpp b/Userland/Libraries/LibIMAP/Client.cpp index 894a4a0dc14..e952e73ca9b 100644 --- a/Userland/Libraries/LibIMAP/Client.cpp +++ b/Userland/Libraries/LibIMAP/Client.cpp @@ -60,7 +60,8 @@ ErrorOr Client::on_ready_to_receive() auto pending_bytes = TRY(m_socket->pending_bytes()); auto receive_buffer = TRY(m_buffer.get_bytes_for_writing(pending_bytes)); - TRY(m_socket->read(receive_buffer)); + // FIXME: This should read the entire span. + TRY(m_socket->read_some(receive_buffer)); // Once we get server hello we can start sending. if (m_connect_pending) { @@ -145,8 +146,9 @@ static ReadonlyBytes command_byte_buffer(CommandType command) ErrorOr Client::send_raw(StringView data) { - TRY(m_socket->write(data.bytes())); - TRY(m_socket->write("\r\n"sv.bytes())); + // FIXME: This should write the entire span. + TRY(m_socket->write_some(data.bytes())); + TRY(m_socket->write_some("\r\n"sv.bytes())); return {}; } diff --git a/Userland/Libraries/LibIPC/Connection.cpp b/Userland/Libraries/LibIPC/Connection.cpp index 1c94f5ad110..b791b5b8d19 100644 --- a/Userland/Libraries/LibIPC/Connection.cpp +++ b/Userland/Libraries/LibIPC/Connection.cpp @@ -74,7 +74,7 @@ ErrorOr ConnectionBase::post_message(MessageBuffer buffer) int writes_done = 0; size_t initial_size = bytes_to_write.size(); while (!bytes_to_write.is_empty()) { - auto maybe_nwritten = m_socket->write(bytes_to_write); + auto maybe_nwritten = m_socket->write_some(bytes_to_write); writes_done++; if (maybe_nwritten.is_error()) { auto error = maybe_nwritten.release_error(); diff --git a/Userland/Libraries/LibJS/Console.cpp b/Userland/Libraries/LibJS/Console.cpp index abce1392dca..cc3af07d976 100644 --- a/Userland/Libraries/LibJS/Console.cpp +++ b/Userland/Libraries/LibJS/Console.cpp @@ -680,7 +680,8 @@ ThrowCompletionOr ConsoleClient::generically_format_values(MarkedVector< bool first = true; for (auto const& value : values) { if (!first) - TRY_OR_THROW_OOM(vm, stream.write(" "sv.bytes())); + // FIXME: This should write the entire span. + TRY_OR_THROW_OOM(vm, stream.write_some(" "sv.bytes())); TRY_OR_THROW_OOM(vm, JS::print(value, ctx)); first = false; } diff --git a/Userland/Libraries/LibJS/Print.cpp b/Userland/Libraries/LibJS/Print.cpp index 6400e6abfae..dc0b3645503 100644 --- a/Userland/Libraries/LibJS/Print.cpp +++ b/Userland/Libraries/LibJS/Print.cpp @@ -148,7 +148,7 @@ ErrorOr js_out(JS::PrintContext& print_context, CheckedFormatStringwrite(bytes).release_value_but_fixme_should_propagate_errors(); + auto nwritten = stream->write_some(bytes).release_value_but_fixme_should_propagate_errors(); bytes = bytes.slice(nwritten); } lseek(fd, 0, SEEK_SET); diff --git a/Userland/Libraries/LibLine/XtermSuggestionDisplay.cpp b/Userland/Libraries/LibLine/XtermSuggestionDisplay.cpp index 5a51e951834..98833292f02 100644 --- a/Userland/Libraries/LibLine/XtermSuggestionDisplay.cpp +++ b/Userland/Libraries/LibLine/XtermSuggestionDisplay.cpp @@ -51,7 +51,8 @@ ErrorOr XtermSuggestionDisplay::display(SuggestionManager const& manager) // the suggestion list to fit in the prompt line. auto start = max_line_count - m_prompt_lines_at_suggestion_initiation; for (size_t i = start; i < max_line_count; ++i) - TRY(stderr_stream->write("\n"sv.bytes())); + // FIXME: This should write the entire span. + TRY(stderr_stream->write_some("\n"sv.bytes())); lines_used += max_line_count; longest_suggestion_length = 0; } @@ -99,7 +100,8 @@ ErrorOr XtermSuggestionDisplay::display(SuggestionManager const& manager) if (next_column > m_num_columns) { auto lines = (suggestion.text_view.length() + m_num_columns - 1) / m_num_columns; lines_used += lines; - TRY(stderr_stream->write("\n"sv.bytes())); + // FIXME: This should write the entire span. + TRY(stderr_stream->write_some("\n"sv.bytes())); num_printed = 0; } @@ -115,11 +117,13 @@ ErrorOr XtermSuggestionDisplay::display(SuggestionManager const& manager) if (spans_entire_line) { num_printed += m_num_columns; - TRY(stderr_stream->write(suggestion.text_string.bytes())); - TRY(stderr_stream->write(suggestion.display_trivia_string.bytes())); + // FIXME: This should write the entire span. + TRY(stderr_stream->write_some(suggestion.text_string.bytes())); + TRY(stderr_stream->write_some(suggestion.display_trivia_string.bytes())); } else { auto field = DeprecatedString::formatted("{: <{}} {}", suggestion.text_string, longest_suggestion_byte_length_without_trivia, suggestion.display_trivia_string); - TRY(stderr_stream->write(DeprecatedString::formatted("{: <{}}", field, longest_suggestion_byte_length + 2).bytes())); + // FIXME: This should write the entire span. + TRY(stderr_stream->write_some(DeprecatedString::formatted("{: <{}}", field, longest_suggestion_byte_length + 2).bytes())); num_printed += longest_suggestion_length + 2; } @@ -150,7 +154,8 @@ ErrorOr XtermSuggestionDisplay::display(SuggestionManager const& manager) TRY(VT::move_absolute(m_origin_row + lines_used, m_num_columns - string.length() - 1, *stderr_stream)); TRY(VT::apply_style({ Style::Background(Style::XtermColor::Green) }, *stderr_stream)); - TRY(stderr_stream->write(string.bytes())); + // FIXME: This should write the entire span. + TRY(stderr_stream->write_some(string.bytes())); TRY(VT::apply_style(Style::reset_style(), *stderr_stream)); } diff --git a/Userland/Libraries/LibProtocol/Request.cpp b/Userland/Libraries/LibProtocol/Request.cpp index 930c5e30929..c10b260978c 100644 --- a/Userland/Libraries/LibProtocol/Request.cpp +++ b/Userland/Libraries/LibProtocol/Request.cpp @@ -45,7 +45,7 @@ void Request::stream_into(Stream& stream) constexpr size_t buffer_size = 256 * KiB; static char buf[buffer_size]; do { - auto result = m_internal_stream_data->read_stream->read({ buf, buffer_size }); + auto result = m_internal_stream_data->read_stream->read_some({ buf, buffer_size }); if (result.is_error() && (!result.error().is_errno() || (result.error().is_errno() && result.error().code() != EINTR))) break; if (result.is_error()) diff --git a/Userland/Libraries/LibSQL/Heap.cpp b/Userland/Libraries/LibSQL/Heap.cpp index 3dff07f8007..9888ea72745 100644 --- a/Userland/Libraries/LibSQL/Heap.cpp +++ b/Userland/Libraries/LibSQL/Heap.cpp @@ -91,7 +91,8 @@ ErrorOr Heap::read_block(u32 block) TRY(seek_block(block)); auto buffer = TRY(ByteBuffer::create_uninitialized(BLOCKSIZE)); - auto bytes = TRY(m_file->read(buffer)); + // FIXME: This should read the entire span. + auto bytes = TRY(m_file->read_some(buffer)); dbgln_if(SQL_DEBUG, "{:hex-dump}", bytes.trim(8)); TRY(buffer.try_resize(bytes.size())); @@ -123,7 +124,8 @@ ErrorOr Heap::write_block(u32 block, ByteBuffer& buffer) } dbgln_if(SQL_DEBUG, "{:hex-dump}", buffer.bytes().trim(8)); - TRY(m_file->write(buffer)); + // FIXME: This should write the entire span. + TRY(m_file->write_some(buffer)); if (block == m_end_of_file) m_end_of_file++; diff --git a/Userland/Libraries/LibSQL/SQLClient.cpp b/Userland/Libraries/LibSQL/SQLClient.cpp index 33f21ac3b43..44e11cdd90b 100644 --- a/Userland/Libraries/LibSQL/SQLClient.cpp +++ b/Userland/Libraries/LibSQL/SQLClient.cpp @@ -67,7 +67,8 @@ static ErrorOr launch_server(DeprecatedString const& socket_path, Deprecat if (server_pid != 0) { auto server_pid_file = TRY(Core::File::open(pid_path, Core::File::OpenMode::Write)); - TRY(server_pid_file->write(DeprecatedString::number(server_pid).bytes())); + // FIXME: This should write the entire span. + TRY(server_pid_file->write_some(DeprecatedString::number(server_pid).bytes())); TRY(Core::System::kill(getpid(), SIGTERM)); } diff --git a/Userland/Libraries/LibTLS/Socket.cpp b/Userland/Libraries/LibTLS/Socket.cpp index e68d37a4d09..d8d25931d8c 100644 --- a/Userland/Libraries/LibTLS/Socket.cpp +++ b/Userland/Libraries/LibTLS/Socket.cpp @@ -18,7 +18,7 @@ constexpr static size_t MaximumApplicationDataChunkSize = 16 * KiB; namespace TLS { -ErrorOr TLSv12::read(Bytes bytes) +ErrorOr TLSv12::read_some(Bytes bytes) { m_eof = false; auto size_to_read = min(bytes.size(), m_context.application_buffer.size()); @@ -53,7 +53,7 @@ DeprecatedString TLSv12::read_line(size_t max_size) return line; } -ErrorOr TLSv12::write(ReadonlyBytes bytes) +ErrorOr TLSv12::write_some(ReadonlyBytes bytes) { if (m_context.connection_status != ConnectionStatus::Established) { dbgln_if(TLS_DEBUG, "write request while not connected"); @@ -190,7 +190,7 @@ ErrorOr TLSv12::read_from_socket() Bytes read_bytes {}; auto& stream = underlying_stream(); do { - auto result = stream.read(bytes); + auto result = stream.read_some(bytes); if (result.is_error()) { if (result.error().is_errno() && result.error().code() != EINTR) { if (result.error().code() != EAGAIN) @@ -291,7 +291,7 @@ ErrorOr TLSv12::flush() Optional error; size_t written; do { - auto result = stream.write(out_bytes); + auto result = stream.write_some(out_bytes); if (result.is_error() && result.error().code() != EINTR && result.error().code() != EAGAIN) { error = result.release_error(); dbgln("TLS Socket write error: {}", *error); diff --git a/Userland/Libraries/LibTLS/TLSv12.h b/Userland/Libraries/LibTLS/TLSv12.h index c1241163d9f..92649343dd4 100644 --- a/Userland/Libraries/LibTLS/TLSv12.h +++ b/Userland/Libraries/LibTLS/TLSv12.h @@ -360,12 +360,12 @@ public: /// The amount of bytes read can be smaller than the size of the buffer. /// Returns either the bytes that were read, or an errno in the case of /// failure. - virtual ErrorOr read(Bytes) override; + virtual ErrorOr read_some(Bytes) override; /// Tries to write the entire contents of the buffer. It is possible for /// less than the full buffer to be written. Returns either the amount of /// bytes written into the stream, or an errno in the case of failure. - virtual ErrorOr write(ReadonlyBytes) override; + virtual ErrorOr write_some(ReadonlyBytes) override; virtual bool is_eof() const override { return m_context.application_buffer.is_empty() && (m_context.connection_finished || underlying_stream().is_eof()); } diff --git a/Userland/Libraries/LibTest/JavaScriptTestRunner.h b/Userland/Libraries/LibTest/JavaScriptTestRunner.h index 107f311524d..fd944a90c92 100644 --- a/Userland/Libraries/LibTest/JavaScriptTestRunner.h +++ b/Userland/Libraries/LibTest/JavaScriptTestRunner.h @@ -220,7 +220,8 @@ inline ByteBuffer load_entire_file(StringView path) auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read)); auto file_size = TRY(file->size()); auto content = TRY(ByteBuffer::create_uninitialized(file_size)); - TRY(file->read(content.bytes())); + // FIXME: This should read the entire span. + TRY(file->read_some(content.bytes())); return content; }; diff --git a/Userland/Libraries/LibWasm/Parser/Parser.cpp b/Userland/Libraries/LibWasm/Parser/Parser.cpp index 68303398ff3..35c53be67f5 100644 --- a/Userland/Libraries/LibWasm/Parser/Parser.cpp +++ b/Userland/Libraries/LibWasm/Parser/Parser.cpp @@ -795,7 +795,7 @@ ParseResult CustomSection::parse(Stream& stream) while (!stream.is_eof()) { char buf[16]; - auto span_or_error = stream.read({ buf, 16 }); + auto span_or_error = stream.read_some({ buf, 16 }); if (span_or_error.is_error()) break; auto size = span_or_error.release_value().size(); diff --git a/Userland/Libraries/LibWasm/Types.h b/Userland/Libraries/LibWasm/Types.h index 6d7d460aca2..7d5b3303139 100644 --- a/Userland/Libraries/LibWasm/Types.h +++ b/Userland/Libraries/LibWasm/Types.h @@ -81,7 +81,7 @@ public: void unread(ReadonlyBytes data) { m_buffer.append(data.data(), data.size()); } private: - virtual ErrorOr read(Bytes bytes) override + virtual ErrorOr read_some(Bytes bytes) override { auto original_bytes = bytes; @@ -95,7 +95,7 @@ private: bytes_read_from_buffer = read_size; } - return original_bytes.trim(TRY(m_stream.read(bytes)).size() + bytes_read_from_buffer); + return original_bytes.trim(TRY(m_stream.read_some(bytes)).size() + bytes_read_from_buffer); } virtual bool is_eof() const override @@ -116,7 +116,7 @@ private: return m_stream.discard(count - bytes_discarded_from_buffer); } - virtual ErrorOr write(ReadonlyBytes) override + virtual ErrorOr write_some(ReadonlyBytes) override { return Error::from_errno(EBADF); } @@ -144,10 +144,10 @@ public: } private: - ErrorOr read(Bytes bytes) override + ErrorOr read_some(Bytes bytes) override { auto to_read = min(m_bytes_left, bytes.size()); - auto read_bytes = TRY(m_stream.read(bytes.slice(0, to_read))); + auto read_bytes = TRY(m_stream.read_some(bytes.slice(0, to_read))); m_bytes_left -= read_bytes.size(); return read_bytes; } @@ -165,7 +165,7 @@ private: return m_stream.discard(count); } - virtual ErrorOr write(ReadonlyBytes) override + virtual ErrorOr write_some(ReadonlyBytes) override { return Error::from_errno(EBADF); } diff --git a/Userland/Libraries/LibWeb/WebDriver/Client.cpp b/Userland/Libraries/LibWeb/WebDriver/Client.cpp index 81d2f2b3a55..99b645bb65c 100644 --- a/Userland/Libraries/LibWeb/WebDriver/Client.cpp +++ b/Userland/Libraries/LibWeb/WebDriver/Client.cpp @@ -213,7 +213,7 @@ ErrorOr Client::on_ready_to_read() if (!TRY(m_socket->can_read_without_blocking())) break; - auto data = TRY(m_socket->read(buffer)); + auto data = TRY(m_socket->read_some(buffer)); TRY(builder.try_append(StringView { data })); if (m_socket->is_eof()) @@ -279,10 +279,11 @@ ErrorOr Client::send_success_response(JsonValue resu builder.append("\r\n"sv); auto builder_contents = TRY(builder.to_byte_buffer()); - TRY(m_socket->write(builder_contents)); + // FIXME: This should write the entire span. + TRY(m_socket->write_some(builder_contents)); while (!content.is_empty()) { - auto bytes_sent = TRY(m_socket->write(content.bytes())); + auto bytes_sent = TRY(m_socket->write_some(content.bytes())); content = content.substring_view(bytes_sent); } @@ -319,8 +320,9 @@ ErrorOr Client::send_error_response(Error const& err header_builder.appendff("Content-Length: {}\r\n", content_builder.length()); header_builder.append("\r\n"sv); - TRY(m_socket->write(TRY(header_builder.to_byte_buffer()))); - TRY(m_socket->write(TRY(content_builder.to_byte_buffer()))); + // FIXME: This should write the entire span. + TRY(m_socket->write_some(TRY(header_builder.to_byte_buffer()))); + TRY(m_socket->write_some(TRY(content_builder.to_byte_buffer()))); log_response(error.http_status); return {}; diff --git a/Userland/Libraries/LibWebSocket/Impl/WebSocketImplSerenity.cpp b/Userland/Libraries/LibWebSocket/Impl/WebSocketImplSerenity.cpp index 401e03d9218..09d093a6154 100644 --- a/Userland/Libraries/LibWebSocket/Impl/WebSocketImplSerenity.cpp +++ b/Userland/Libraries/LibWebSocket/Impl/WebSocketImplSerenity.cpp @@ -76,7 +76,7 @@ void WebSocketImplSerenity::connect(ConnectionInfo const& connection_info) ErrorOr WebSocketImplSerenity::read(int max_size) { auto buffer = TRY(ByteBuffer::create_uninitialized(max_size)); - auto read_bytes = TRY(m_socket->read(buffer)); + auto read_bytes = TRY(m_socket->read_some(buffer)); return buffer.slice(0, read_bytes.size()); } diff --git a/Userland/Services/EchoServer/Client.cpp b/Userland/Services/EchoServer/Client.cpp index 7f12bd31c9b..ba382cedbda 100644 --- a/Userland/Services/EchoServer/Client.cpp +++ b/Userland/Services/EchoServer/Client.cpp @@ -31,7 +31,7 @@ ErrorOr Client::drain_socket() auto buffer = TRY(ByteBuffer::create_uninitialized(1024)); while (TRY(m_socket->can_read_without_blocking())) { - auto bytes_read = TRY(m_socket->read(buffer)); + auto bytes_read = TRY(m_socket->read_some(buffer)); dbgln("Read {} bytes.", bytes_read.size()); @@ -40,7 +40,8 @@ ErrorOr Client::drain_socket() break; } - TRY(m_socket->write(bytes_read)); + // FIXME: This should write the entire span. + TRY(m_socket->write_some(bytes_read)); } return {}; diff --git a/Userland/Services/FileOperation/main.cpp b/Userland/Services/FileOperation/main.cpp index e534252a520..69dbbfa3c7d 100644 --- a/Userland/Services/FileOperation/main.cpp +++ b/Userland/Services/FileOperation/main.cpp @@ -237,10 +237,11 @@ ErrorOr execute_work_items(Vector const& items) while (true) { print_progress(); - auto bytes_read = TRY(source_file->read(buffer.bytes())); + auto bytes_read = TRY(source_file->read_some(buffer.bytes())); if (bytes_read.is_empty()) break; - if (auto result = destination_file->write(bytes_read); result.is_error()) { + // FIXME: This should write the entire span. + if (auto result = destination_file->write_some(bytes_read); result.is_error()) { // FIXME: Return the formatted string directly. There is no way to do this right now without the temporary going out of scope and being destroyed. report_warning(DeprecatedString::formatted("Failed to write to destination file: {}", result.error())); return result.release_error(); diff --git a/Userland/Services/InspectorServer/InspectableProcess.cpp b/Userland/Services/InspectorServer/InspectableProcess.cpp index d9206df2d7a..dececc1e0c3 100644 --- a/Userland/Services/InspectorServer/InspectableProcess.cpp +++ b/Userland/Services/InspectorServer/InspectableProcess.cpp @@ -27,7 +27,8 @@ InspectableProcess::InspectableProcess(pid_t pid, NonnullOwnPtron_ready_to_read = [this] { char c; - [[maybe_unused]] auto buffer = m_socket->read({ &c, 1 }); + // FIXME: This should read the entire span. + [[maybe_unused]] auto buffer = m_socket->read_some({ &c, 1 }); if (m_socket->is_eof()) { Core::deferred_invoke([pid = this->m_pid] { g_processes.remove(pid); }); return; @@ -44,7 +45,8 @@ DeprecatedString InspectableProcess::wait_for_response() } u32 length {}; - auto length_bytes_read = m_socket->read({ (u8*)&length, sizeof(length) }).release_value_but_fixme_should_propagate_errors(); + // FIXME: This should read the entire span. + auto length_bytes_read = m_socket->read_some({ (u8*)&length, sizeof(length) }).release_value_but_fixme_should_propagate_errors(); if (length_bytes_read.size() != sizeof(length)) { dbgln("InspectableProcess got malformed data: PID {}", m_pid); m_socket->close(); @@ -55,7 +57,7 @@ DeprecatedString InspectableProcess::wait_for_response() auto remaining_data_buffer = data_buffer.bytes(); while (!remaining_data_buffer.is_empty()) { - auto maybe_bytes_read = m_socket->read(remaining_data_buffer); + auto maybe_bytes_read = m_socket->read_some(remaining_data_buffer); if (maybe_bytes_read.is_error()) { dbgln("InspectableProcess::wait_for_response: Failed to read data: {}", maybe_bytes_read.error()); break; @@ -80,8 +82,9 @@ void InspectableProcess::send_request(JsonObject const& request) u32 length = serialized.length(); // FIXME: Propagate errors - MUST(m_socket->write({ (u8 const*)&length, sizeof(length) })); - MUST(m_socket->write(serialized.bytes())); + // FIXME: This should write the entire span. + MUST(m_socket->write_some({ (u8 const*)&length, sizeof(length) })); + MUST(m_socket->write_some(serialized.bytes())); } } diff --git a/Userland/Services/LookupServer/LookupServer.cpp b/Userland/Services/LookupServer/LookupServer.cpp index fe2d816dfc0..c93f6b49925 100644 --- a/Userland/Services/LookupServer/LookupServer.cpp +++ b/Userland/Services/LookupServer/LookupServer.cpp @@ -239,10 +239,11 @@ ErrorOr> LookupServer::lookup(Name const& name, DeprecatedString auto udp_socket = TRY(Core::UDPSocket::connect(nameserver, 53, Time::from_seconds(1))); TRY(udp_socket->set_blocking(true)); - TRY(udp_socket->write(buffer)); + // FIXME: This should write the entire span. + TRY(udp_socket->write_some(buffer)); u8 response_buffer[4096]; - int nrecv = TRY(udp_socket->read({ response_buffer, sizeof(response_buffer) })).size(); + int nrecv = TRY(udp_socket->read_some({ response_buffer, sizeof(response_buffer) })).size(); if (udp_socket->is_eof()) return Vector {}; diff --git a/Userland/Services/TelnetServer/Client.cpp b/Userland/Services/TelnetServer/Client.cpp index 33e6aa9f670..4f0db9fc1a4 100644 --- a/Userland/Services/TelnetServer/Client.cpp +++ b/Userland/Services/TelnetServer/Client.cpp @@ -77,7 +77,7 @@ ErrorOr Client::drain_socket() auto buffer = TRY(ByteBuffer::create_uninitialized(1024)); while (TRY(m_socket->can_read_without_blocking())) { - auto read_bytes = TRY(m_socket->read(buffer)); + auto read_bytes = TRY(m_socket->read_some(buffer)); m_parser.write(StringView { read_bytes }); @@ -161,7 +161,8 @@ ErrorOr Client::send_data(StringView data) } if (fast) { - TRY(m_socket->write({ data.characters_without_null_termination(), data.length() })); + // FIXME: This should write the entire span. + TRY(m_socket->write_some({ data.characters_without_null_termination(), data.length() })); return {}; } @@ -183,7 +184,8 @@ ErrorOr Client::send_data(StringView data) } auto builder_contents = TRY(builder.to_byte_buffer()); - TRY(m_socket->write(builder_contents)); + // FIXME: This should write the entire span. + TRY(m_socket->write_some(builder_contents)); return {}; } @@ -204,7 +206,8 @@ ErrorOr Client::send_commands(Vector commands) } VERIFY(TRY(stream.tell()) == buffer.size()); - TRY(m_socket->write({ buffer.data(), buffer.size() })); + // FIXME: This should write the entire span. + TRY(m_socket->write_some({ buffer.data(), buffer.size() })); return {}; } diff --git a/Userland/Services/WebServer/Client.cpp b/Userland/Services/WebServer/Client.cpp index c241da351c7..571b09da0b5 100644 --- a/Userland/Services/WebServer/Client.cpp +++ b/Userland/Services/WebServer/Client.cpp @@ -192,18 +192,19 @@ ErrorOr Client::send_response(Stream& response, HTTP::HttpRequest const& r builder.append("\r\n"sv); auto builder_contents = TRY(builder.to_byte_buffer()); - TRY(m_socket->write(builder_contents)); + // FIXME: This should write the entire span. + TRY(m_socket->write_some(builder_contents)); log_response(200, request); char buffer[PAGE_SIZE]; do { - auto size = TRY(response.read({ buffer, sizeof(buffer) })).size(); + auto size = TRY(response.read_some({ buffer, sizeof(buffer) })).size(); if (response.is_eof() && size == 0) break; ReadonlyBytes write_buffer { buffer, size }; while (!write_buffer.is_empty()) { - auto nwritten = TRY(m_socket->write(write_buffer)); + auto nwritten = TRY(m_socket->write_some(write_buffer)); if (nwritten == 0) { dbgln("EEEEEE got 0 bytes written!"); @@ -234,7 +235,8 @@ ErrorOr Client::send_redirect(StringView redirect_path, HTTP::HttpRequest builder.append("\r\n"sv); auto builder_contents = TRY(builder.to_byte_buffer()); - TRY(m_socket->write(builder_contents)); + // FIXME: This should write the entire span. + TRY(m_socket->write_some(builder_contents)); log_response(301, request); return {}; @@ -363,8 +365,9 @@ ErrorOr Client::send_error_response(unsigned code, HTTP::HttpRequest const header_builder.append("Content-Type: text/html; charset=UTF-8\r\n"sv); header_builder.appendff("Content-Length: {}\r\n", content_builder.length()); header_builder.append("\r\n"sv); - TRY(m_socket->write(TRY(header_builder.to_byte_buffer()))); - TRY(m_socket->write(TRY(content_builder.to_byte_buffer()))); + // FIXME: This should write the entire span. + TRY(m_socket->write_some(TRY(header_builder.to_byte_buffer()))); + TRY(m_socket->write_some(TRY(content_builder.to_byte_buffer()))); log_response(code, request); return {}; diff --git a/Userland/Utilities/cat.cpp b/Userland/Utilities/cat.cpp index 0905a033528..237ba67f148 100644 --- a/Userland/Utilities/cat.cpp +++ b/Userland/Utilities/cat.cpp @@ -40,7 +40,7 @@ ErrorOr serenity_main(Main::Arguments arguments) Array buffer; for (auto const& file : files) { while (!file->is_eof()) { - auto const buffer_span = TRY(file->read(buffer)); + auto const buffer_span = TRY(file->read_some(buffer)); out("{:s}", buffer_span); } } diff --git a/Userland/Utilities/checksum.cpp b/Userland/Utilities/checksum.cpp index 78cf79ef5be..d5386d6c627 100644 --- a/Userland/Utilities/checksum.cpp +++ b/Userland/Utilities/checksum.cpp @@ -66,13 +66,13 @@ ErrorOr serenity_main(Main::Arguments arguments) Array buffer; if (!verify_from_paths) { while (!file->is_eof()) - hash.update(TRY(file->read(buffer))); + hash.update(TRY(file->read_some(buffer))); outln("{:hex-dump} {}", hash.digest().bytes(), path); } else { StringBuilder checksum_list_contents; Array checksum_list_buffer; while (!file->is_eof()) - checksum_list_contents.append(TRY(file->read(checksum_list_buffer)).data()[0]); + checksum_list_contents.append(TRY(file->read_some(checksum_list_buffer)).data()[0]); Vector const lines = checksum_list_contents.string_view().split_view("\n"sv); for (size_t i = 0; i < lines.size(); ++i) { @@ -96,7 +96,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto file_from_filename = file_from_filename_or_error.release_value(); hash.reset(); while (!file_from_filename->is_eof()) - hash.update(TRY(file_from_filename->read(buffer))); + hash.update(TRY(file_from_filename->read_some(buffer))); if (DeprecatedString::formatted("{:hex-dump}", hash.digest().bytes()) == line[0]) outln("{}: OK", filename); else { diff --git a/Userland/Utilities/cksum.cpp b/Userland/Utilities/cksum.cpp index e0c10a85d31..df389427ba1 100644 --- a/Userland/Utilities/cksum.cpp +++ b/Userland/Utilities/cksum.cpp @@ -59,7 +59,7 @@ ErrorOr serenity_main(Main::Arguments arguments) if (algorithm == "crc32") { Crypto::Checksum::CRC32 crc32; while (!file->is_eof()) { - auto data_or_error = file->read(buffer); + auto data_or_error = file->read_some(buffer); if (data_or_error.is_error()) { warnln("{}: Failed to read {}: {}", arguments.strings[0], filepath, data_or_error.error()); fail = true; @@ -72,7 +72,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } else if (algorithm == "adler32") { Crypto::Checksum::Adler32 adler32; while (!file->is_eof()) { - auto data_or_error = file->read(buffer); + auto data_or_error = file->read_some(buffer); if (data_or_error.is_error()) { warnln("{}: Failed to read {}: {}", arguments.strings[0], filepath, data_or_error.error()); fail = true; diff --git a/Userland/Utilities/cmp.cpp b/Userland/Utilities/cmp.cpp index 426fb4151e6..0ceea7f6e13 100644 --- a/Userland/Utilities/cmp.cpp +++ b/Userland/Utilities/cmp.cpp @@ -75,8 +75,8 @@ ErrorOr serenity_main(Main::Arguments arguments) }; while (true) { - TRY(file1->read(buffer1)); - TRY(file2->read(buffer2)); + TRY(file1->read_some(buffer1)); + TRY(file2->read_some(buffer2)); if (file1->is_eof() && file2->is_eof()) break; diff --git a/Userland/Utilities/file.cpp b/Userland/Utilities/file.cpp index 53279930a17..c574e1f20ae 100644 --- a/Userland/Utilities/file.cpp +++ b/Userland/Utilities/file.cpp @@ -187,7 +187,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } else if (!file_size_in_bytes) { outln("{}: empty", path); } else { - auto bytes = TRY(file->read(buffer)); + auto bytes = TRY(file->read_some(buffer)); auto file_name_guess = Core::guess_mime_type_based_on_filename(path); auto mime_type = Core::guess_mime_type_based_on_sniffed_bytes(bytes).value_or(file_name_guess); auto human_readable_description = get_description_from_mime_type(mime_type, path).value_or(mime_type); diff --git a/Userland/Utilities/gml-format.cpp b/Userland/Utilities/gml-format.cpp index ef909642490..465573d722a 100644 --- a/Userland/Utilities/gml-format.cpp +++ b/Userland/Utilities/gml-format.cpp @@ -28,7 +28,8 @@ static ErrorOr format_file(StringView path, bool inplace) return true; TRY(file->seek(0, SeekMode::SetPosition)); TRY(file->truncate(0)); - TRY(file->write(formatted_gml.bytes())); + // FIXME: This should write the entire span. + TRY(file->write_some(formatted_gml.bytes())); } else { out("{}", formatted_gml); } diff --git a/Userland/Utilities/gunzip.cpp b/Userland/Utilities/gunzip.cpp index a0fb4048a78..d04a8e90368 100644 --- a/Userland/Utilities/gunzip.cpp +++ b/Userland/Utilities/gunzip.cpp @@ -17,7 +17,7 @@ static ErrorOr decompress_file(NonnullOwnPtr input_stream, Str auto buffer = TRY(ByteBuffer::create_uninitialized(4096)); while (!gzip_stream.is_eof()) { - auto span = TRY(gzip_stream.read(buffer)); + auto span = TRY(gzip_stream.read_some(buffer)); TRY(output_stream.write_entire_buffer(span)); } diff --git a/Userland/Utilities/headless-browser.cpp b/Userland/Utilities/headless-browser.cpp index 5e624283333..7453120887b 100644 --- a/Userland/Utilities/headless-browser.cpp +++ b/Userland/Utilities/headless-browser.cpp @@ -174,7 +174,8 @@ static ErrorOr> load_page_for_screenshot_and_exit(Cor auto output_file = MUST(Core::File::open(output_file_path, Core::File::OpenMode::Write)); auto image_buffer = MUST(Gfx::PNGWriter::encode(*screenshot)); - MUST(output_file->write(image_buffer.bytes())); + // FIXME: This should write the entire buffer. + MUST(output_file->write_some(image_buffer.bytes())); } else { warnln("No screenshot available"); } diff --git a/Userland/Utilities/hexdump.cpp b/Userland/Utilities/hexdump.cpp index e27c2d2362f..67e4f20b2c6 100644 --- a/Userland/Utilities/hexdump.cpp +++ b/Userland/Utilities/hexdump.cpp @@ -86,7 +86,7 @@ ErrorOr serenity_main(Main::Arguments args) } bytes = contents.span().slice(0, bytes_to_read); - bytes = TRY(file->read(bytes)); + bytes = TRY(file->read_some(bytes)); total_bytes_read += bytes.size(); diff --git a/Userland/Utilities/js.cpp b/Userland/Utilities/js.cpp index 7a08f4beec1..db9fae8d592 100644 --- a/Userland/Utilities/js.cpp +++ b/Userland/Utilities/js.cpp @@ -188,7 +188,8 @@ static ErrorOr write_to_file(String const& path) for (size_t i = 0; i < g_repl_statements.size(); i++) { auto line = g_repl_statements[i].bytes(); if (line.size() > 0 && i != g_repl_statements.size() - 1) { - TRY(file->write(line)); + // FIXME: This should write the entire span. + TRY(file->write_some(line)); } if (i != g_repl_statements.size() - 1) { TRY(file->write_value('\n')); diff --git a/Userland/Utilities/nc.cpp b/Userland/Utilities/nc.cpp index 6d51312e5cc..858bbed77de 100644 --- a/Userland/Utilities/nc.cpp +++ b/Userland/Utilities/nc.cpp @@ -82,7 +82,8 @@ ErrorOr serenity_main(Main::Arguments arguments) auto nread = TRY(Core::System::read(STDIN_FILENO, buffer_span)); buffer_span = buffer_span.trim(nread); - TRY(socket->write({ buffer_span.data(), static_cast(nread) })); + // FIXME: This should write the entire span. + TRY(socket->write_some({ buffer_span.data(), static_cast(nread) })); } } diff --git a/Userland/Utilities/pro.cpp b/Userland/Utilities/pro.cpp index ba363711dc6..5202296dad6 100644 --- a/Userland/Utilities/pro.cpp +++ b/Userland/Utilities/pro.cpp @@ -112,18 +112,18 @@ public: { } - virtual ErrorOr read(Bytes) override + virtual ErrorOr read_some(Bytes) override { return Error::from_errno(EBADF); } - virtual ErrorOr write(ReadonlyBytes bytes) override + virtual ErrorOr write_some(ReadonlyBytes bytes) override { // Pretend that we wrote the whole buffer if the condition is untrue. if (!m_condition()) return bytes.size(); - return m_stream->write(bytes); + return m_stream->write_some(bytes); } virtual bool is_eof() const override diff --git a/Userland/Utilities/reboot.cpp b/Userland/Utilities/reboot.cpp index cd819bdb478..462e2e01117 100644 --- a/Userland/Utilities/reboot.cpp +++ b/Userland/Utilities/reboot.cpp @@ -14,7 +14,8 @@ ErrorOr serenity_main(Main::Arguments) auto file = TRY(Core::File::open("/sys/kernel/power_state"sv, Core::File::OpenMode::Write)); const DeprecatedString file_contents = "1"; - TRY(file->write(file_contents.bytes())); + // FIXME: This should write the entire span. + TRY(file->write_some(file_contents.bytes())); file->close(); return 0; diff --git a/Userland/Utilities/sed.cpp b/Userland/Utilities/sed.cpp index abb10572048..a978896bc78 100644 --- a/Userland/Utilities/sed.cpp +++ b/Userland/Utilities/sed.cpp @@ -141,8 +141,9 @@ ErrorOr serenity_main(Main::Arguments args) if (maybe_output_file.has_value()) { auto const& output_file = maybe_output_file.value(); - TRY(output_file->write(result.bytes())); - TRY(output_file->write("\n"sv.bytes())); + // FIXME: This should write the entire span. + TRY(output_file->write_some(result.bytes())); + TRY(output_file->write_some("\n"sv.bytes())); } } } diff --git a/Userland/Utilities/shot.cpp b/Userland/Utilities/shot.cpp index 08481303911..78e3c4db835 100644 --- a/Userland/Utilities/shot.cpp +++ b/Userland/Utilities/shot.cpp @@ -167,7 +167,8 @@ ErrorOr serenity_main(Main::Arguments arguments) } auto& file = *file_or_error.value(); - TRY(file.write(encoded_bitmap.bytes())); + // FIXME: This should write the entire span. + TRY(file.write_some(encoded_bitmap.bytes())); if (edit_image) TRY(Core::Process::spawn("/bin/PixelPaint"sv, Array { output_path })); diff --git a/Userland/Utilities/shutdown.cpp b/Userland/Utilities/shutdown.cpp index 432d59b251c..2547de06a53 100644 --- a/Userland/Utilities/shutdown.cpp +++ b/Userland/Utilities/shutdown.cpp @@ -18,7 +18,8 @@ ErrorOr serenity_main(Main::Arguments) auto file = TRY(Core::File::open("/sys/kernel/power_state"sv, Core::File::OpenMode::Write)); const DeprecatedString file_contents = "2"; - TRY(file->write(file_contents.bytes())); + // FIXME: This should write the entire span. + TRY(file->write_some(file_contents.bytes())); file->close(); return 0; diff --git a/Userland/Utilities/strace.cpp b/Userland/Utilities/strace.cpp index 1b285d0f390..e1afa0e22b7 100644 --- a/Userland/Utilities/strace.cpp +++ b/Userland/Utilities/strace.cpp @@ -932,6 +932,7 @@ ErrorOr serenity_main(Main::Arguments arguments) FormattedSyscallBuilder builder(syscall_name); TRY(format_syscall(builder, syscall_function, arg1, arg2, arg3, res)); - TRY(trace_file->write(builder.string_view().bytes())); + // FIXME: This should write the entire span. + TRY(trace_file->write_some(builder.string_view().bytes())); } } diff --git a/Userland/Utilities/strings.cpp b/Userland/Utilities/strings.cpp index 8f1f0ab7d23..326b826df95 100644 --- a/Userland/Utilities/strings.cpp +++ b/Userland/Utilities/strings.cpp @@ -72,7 +72,7 @@ static ErrorOr process_strings_in_file(StringView path, bool show_paths, S size_t string_offset_position = 0; bool did_show_path = false; while (!file->is_eof()) { - auto buffer_span = TRY(file->read(buffer)); + auto buffer_span = TRY(file->read_some(buffer)); while (!buffer_span.is_empty()) { string_offset_position += processed_characters; processed_characters = process_characters_in_span(output_characters, buffer_span); diff --git a/Userland/Utilities/sysctl.cpp b/Userland/Utilities/sysctl.cpp index 10b4e9ec955..90d587ed6c1 100644 --- a/Userland/Utilities/sysctl.cpp +++ b/Userland/Utilities/sysctl.cpp @@ -48,7 +48,8 @@ static bool write_variable(StringView name, StringView value) warnln("Failed to open {}: {}", path, file.error()); return false; } - if (auto result = file.value()->write(value.bytes()); result.is_error()) { + // FIXME: This should write the entire span. + if (auto result = file.value()->write_some(value.bytes()); result.is_error()) { warnln("Failed to write {}: {}", path, result.error()); return false; } diff --git a/Userland/Utilities/tail.cpp b/Userland/Utilities/tail.cpp index 687654ce1f8..3e73b69cd42 100644 --- a/Userland/Utilities/tail.cpp +++ b/Userland/Utilities/tail.cpp @@ -35,7 +35,8 @@ static ErrorOr find_seek_pos(Core::File& file, int wanted_lines) if (file.is_eof()) break; Array buffer; - auto ch = TRY(file.read(buffer)); + // FIXME: This should read the entire span. + auto ch = TRY(file.read_some(buffer)); if (*ch.data() == '\n' && (end - pos) > 1) { lines++; if (lines == wanted_lines) diff --git a/Userland/Utilities/tar.cpp b/Userland/Utilities/tar.cpp index 6d2cbb19cbe..ae8b9352fc7 100644 --- a/Userland/Utilities/tar.cpp +++ b/Userland/Utilities/tar.cpp @@ -127,7 +127,7 @@ ErrorOr serenity_main(Main::Arguments arguments) Array buffer; while (!file_stream.is_eof()) { - auto slice = TRY(file_stream.read(buffer)); + auto slice = TRY(file_stream.read_some(buffer)); long_name.append(reinterpret_cast(slice.data()), slice.size()); } @@ -162,7 +162,7 @@ ErrorOr serenity_main(Main::Arguments arguments) Array buffer; while (!file_stream.is_eof()) { - auto slice = TRY(file_stream.read(buffer)); + auto slice = TRY(file_stream.read_some(buffer)); TRY(Core::System::write(fd, slice)); } diff --git a/Userland/Utilities/uniq.cpp b/Userland/Utilities/uniq.cpp index d4826a33428..7253c5924dc 100644 --- a/Userland/Utilities/uniq.cpp +++ b/Userland/Utilities/uniq.cpp @@ -17,10 +17,11 @@ static ErrorOr write_line_content(StringView line, size_t count, bool dupl if (duplicates_only && count <= 1) return {}; + // FIXME: This should write the entire span. if (print_count) - TRY(outfile.write(DeprecatedString::formatted("{} {}\n", count, line).bytes())); + TRY(outfile.write_some(DeprecatedString::formatted("{} {}\n", count, line).bytes())); else - TRY(outfile.write(DeprecatedString::formatted("{}\n", line).bytes())); + TRY(outfile.write_some(DeprecatedString::formatted("{}\n", line).bytes())); return {}; } diff --git a/Userland/Utilities/uptime.cpp b/Userland/Utilities/uptime.cpp index ee0f65ec342..e289eb5517b 100644 --- a/Userland/Utilities/uptime.cpp +++ b/Userland/Utilities/uptime.cpp @@ -19,7 +19,7 @@ ErrorOr serenity_main(Main::Arguments) TRY(Core::System::pledge("stdio")); Array buffer; - auto read_buffer = TRY(file->read(buffer)); + auto read_buffer = TRY(file->read_some(buffer)); auto maybe_seconds = AK::StringUtils::convert_to_uint(StringView(read_buffer)); if (!maybe_seconds.has_value()) return Error::from_string_literal("Couldn't convert to number"); diff --git a/Userland/Utilities/utmpupdate.cpp b/Userland/Utilities/utmpupdate.cpp index 381e5573b9a..be2ec0334d7 100644 --- a/Userland/Utilities/utmpupdate.cpp +++ b/Userland/Utilities/utmpupdate.cpp @@ -72,7 +72,8 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(file->seek(0, SeekMode::SetPosition)); TRY(file->truncate(0)); - TRY(file->write(json.to_deprecated_string().bytes())); + // FIXME: This should write the entire span. + TRY(file->write_some(json.to_deprecated_string().bytes())); return 0; } diff --git a/Userland/Utilities/wasm.cpp b/Userland/Utilities/wasm.cpp index e02e6dd748f..b4f6f0c0467 100644 --- a/Userland/Utilities/wasm.cpp +++ b/Userland/Utilities/wasm.cpp @@ -53,12 +53,14 @@ static bool pre_interpret_hook(Wasm::Configuration& config, Wasm::InstructionPoi if (always_print_stack) config.dump_stack(); if (always_print_instruction) { - g_stdout->write(DeprecatedString::formatted("{:0>4} ", ip.value()).bytes()).release_value_but_fixme_should_propagate_errors(); + // FIXME: This should write the entire span. + g_stdout->write_some(DeprecatedString::formatted("{:0>4} ", ip.value()).bytes()).release_value_but_fixme_should_propagate_errors(); g_printer->print(instr); } if (g_continue) return true; - g_stdout->write(DeprecatedString::formatted("{:0>4} ", ip.value()).bytes()).release_value_but_fixme_should_propagate_errors(); + // FIXME: This should write the entire span. + g_stdout->write_some(DeprecatedString::formatted("{:0>4} ", ip.value()).bytes()).release_value_but_fixme_should_propagate_errors(); g_printer->print(instr); DeprecatedString last_command = ""; for (;;) { @@ -214,7 +216,8 @@ static bool pre_interpret_hook(Wasm::Configuration& config, Wasm::InstructionPoi if (!result.values().is_empty()) warnln("Returned:"); for (auto& value : result.values()) { - g_stdout->write(" -> "sv.bytes()).release_value_but_fixme_should_propagate_errors(); + // FIXME: This should write the entire span. + g_stdout->write_some(" -> "sv.bytes()).release_value_but_fixme_should_propagate_errors(); g_printer->print(value); } } @@ -454,15 +457,18 @@ ErrorOr serenity_main(Main::Arguments arguments) auto print_func = [&](auto const& address) { Wasm::FunctionInstance* fn = machine.store().get(address); - g_stdout->write(DeprecatedString::formatted("- Function with address {}, ptr = {}\n", address.value(), fn).bytes()).release_value_but_fixme_should_propagate_errors(); + // FIXME: This should write the entire span. + g_stdout->write_some(DeprecatedString::formatted("- Function with address {}, ptr = {}\n", address.value(), fn).bytes()).release_value_but_fixme_should_propagate_errors(); if (fn) { - g_stdout->write(DeprecatedString::formatted(" wasm function? {}\n", fn->has()).bytes()).release_value_but_fixme_should_propagate_errors(); + // FIXME: This should write the entire span. + g_stdout->write_some(DeprecatedString::formatted(" wasm function? {}\n", fn->has()).bytes()).release_value_but_fixme_should_propagate_errors(); fn->visit( [&](Wasm::WasmFunction const& func) { Wasm::Printer printer { *g_stdout, 3 }; - g_stdout->write(" type:\n"sv.bytes()).release_value_but_fixme_should_propagate_errors(); + // FIXME: This should write the entire span. + g_stdout->write_some(" type:\n"sv.bytes()).release_value_but_fixme_should_propagate_errors(); printer.print(func.type()); - g_stdout->write(" code:\n"sv.bytes()).release_value_but_fixme_should_propagate_errors(); + g_stdout->write_some(" code:\n"sv.bytes()).release_value_but_fixme_should_propagate_errors(); printer.print(func.code()); }, [](Wasm::HostFunction const&) {}); @@ -526,7 +532,8 @@ ErrorOr serenity_main(Main::Arguments arguments) if (!result.values().is_empty()) warnln("Returned:"); for (auto& value : result.values()) { - g_stdout->write(" -> "sv.bytes()).release_value_but_fixme_should_propagate_errors(); + // FIXME: This should write the entire span. + g_stdout->write_some(" -> "sv.bytes()).release_value_but_fixme_should_propagate_errors(); g_printer->print(value); } }