1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:14:58 +00:00

Everywhere: Remove unintentional partial stream reads and writes

This commit is contained in:
Tim Schumacher 2023-03-01 17:24:50 +01:00 committed by Linus Groh
parent 26516ee160
commit ae51c1821c
44 changed files with 109 additions and 192 deletions

View file

@ -98,8 +98,7 @@ TEST_CASE(long_streams)
u8 bytes[64] = {}; u8 bytes[64] = {};
constexpr auto test_view = "Well, hello friends"sv; constexpr auto test_view = "Well, hello friends"sv;
FixedMemoryStream stream(Bytes { bytes, sizeof(bytes) }); FixedMemoryStream stream(Bytes { bytes, sizeof(bytes) });
// FIXME: This should write the entire span. MUST(stream.write_until_depleted(test_view.bytes()));
MUST(stream.write_some(test_view.bytes()));
MUST(stream.seek(0)); MUST(stream.seek(0));
auto string = MUST(String::from_stream(stream, test_view.length())); auto string = MUST(String::from_stream(stream, test_view.length()));
@ -111,8 +110,7 @@ TEST_CASE(long_streams)
{ {
AllocatingMemoryStream stream; AllocatingMemoryStream stream;
// FIXME: This should write the entire span. MUST(stream.write_until_depleted(("abc"sv).bytes()));
MUST(stream.write_some(("abc"sv).bytes()));
auto string = MUST(String::from_stream(stream, 3u)); auto string = MUST(String::from_stream(stream, 3u));
@ -123,8 +121,7 @@ TEST_CASE(long_streams)
{ {
AllocatingMemoryStream stream; AllocatingMemoryStream stream;
// FIXME: This should write the entire span. MUST(stream.write_until_depleted(("0123456789"sv).bytes()));
MUST(stream.write_some(("0123456789"sv).bytes()));
auto string = MUST(String::from_stream(stream, 9u)); auto string = MUST(String::from_stream(stream, 9u));

View file

@ -32,8 +32,7 @@ TESTJS_GLOBAL_FUNCTION(read_binary_wasm_file, readBinaryWasmFile)
auto array = TRY(JS::Uint8Array::create(realm, file_size.value())); auto array = TRY(JS::Uint8Array::create(realm, file_size.value()));
// FIXME: This should read the entire span. auto read = file.value()->read_until_filled(array->data());
auto read = file.value()->read_some(array->data());
if (read.is_error()) if (read.is_error())
return vm.throw_completion<JS::TypeError>(error_code_to_string(read.error().code())); return vm.throw_completion<JS::TypeError>(error_code_to_string(read.error().code()));

View file

@ -211,8 +211,7 @@ TEST_CASE(regression)
auto file = MUST(Core::File::open(path, Core::File::OpenMode::Read)); auto file = MUST(Core::File::open(path, Core::File::OpenMode::Read));
auto file_size = MUST(file->size()); auto file_size = MUST(file->size());
auto content = MUST(ByteBuffer::create_uninitialized(file_size)); auto content = MUST(ByteBuffer::create_uninitialized(file_size));
// FIXME: This should read the entire span. MUST(file->read_until_filled(content.bytes()));
MUST(file->read_some(content.bytes()));
DeprecatedString file_contents { content.bytes() }; DeprecatedString file_contents { content.bytes() };
auto tokens = run_tokenizer(file_contents); auto tokens = run_tokenizer(file_contents);
u32 hash = hash_tokens(tokens); u32 hash = hash_tokens(tokens);

View file

@ -775,8 +775,7 @@ ErrorOr<void> BrowserWindow::take_screenshot(ScreenshotType type)
auto encoded = TRY(Gfx::PNGWriter::encode(*bitmap.bitmap())); auto encoded = TRY(Gfx::PNGWriter::encode(*bitmap.bitmap()));
auto screenshot_file = TRY(Core::File::open(path.string(), Core::File::OpenMode::Write)); auto screenshot_file = TRY(Core::File::open(path.string(), Core::File::OpenMode::Write));
// FIXME: This should write the entire span. TRY(screenshot_file->write_until_depleted(encoded));
TRY(screenshot_file->write_some(encoded));
return {}; return {};
} }

View file

@ -50,8 +50,7 @@ ErrorOr<void> DomainListModel::save()
TRY(builder.try_appendff("{}\n", domain)); TRY(builder.try_appendff("{}\n", domain));
auto file = TRY(Core::File::open(filter_list_file_path(), Core::File::OpenMode::Write)); auto file = TRY(Core::File::open(filter_list_file_path(), Core::File::OpenMode::Write));
// FIXME: This should write the entire span. TRY(file->write_until_depleted(TRY(builder.to_byte_buffer()).bytes()));
TRY(file->write_some(TRY(builder.to_byte_buffer()).bytes()));
return {}; return {};
} }

View file

@ -284,8 +284,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
} }
auto byte_buffer = byte_buffer_or_error.release_value(); auto byte_buffer = byte_buffer_or_error.release_value();
// FIXME: This should write the entire span. if (auto result = file->write_until_depleted(byte_buffer); result.is_error())
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); 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); save_backtrace_button.set_enabled(false);

View file

@ -62,12 +62,10 @@ void HexDocumentMemory::clear_changes()
ErrorOr<void> HexDocumentMemory::write_to_file(Core::File& file) ErrorOr<void> HexDocumentMemory::write_to_file(Core::File& file)
{ {
TRY(file.seek(0, SeekMode::SetPosition)); TRY(file.seek(0, SeekMode::SetPosition));
// FIXME: This should write the entire span. TRY(file.write_until_depleted(m_buffer));
TRY(file.write_some(m_buffer));
for (auto& change : m_changes) { for (auto& change : m_changes) {
TRY(file.seek(change.key, SeekMode::SetPosition)); TRY(file.seek(change.key, SeekMode::SetPosition));
// FIXME: This should write the entire span. TRY(file.write_until_depleted({ &change.value, 1 }));
TRY(file.write_some({ &change.value, 1 }));
} }
return {}; return {};
} }
@ -89,8 +87,7 @@ ErrorOr<void> HexDocumentFile::write_to_file()
{ {
for (auto& change : m_changes) { for (auto& change : m_changes) {
TRY(m_file->seek(change.key, SeekMode::SetPosition)); TRY(m_file->seek(change.key, SeekMode::SetPosition));
// FIXME: This should write the entire span. TRY(m_file->write_until_depleted({ &change.value, 1 }));
TRY(m_file->write_some({ &change.value, 1 }));
} }
clear_changes(); clear_changes();
// make sure the next get operation triggers a read // make sure the next get operation triggers a read
@ -110,14 +107,12 @@ ErrorOr<void> HexDocumentFile::write_to_file(Core::File& file)
auto copy_buffer = TRY(m_file->read_some(buffer)); auto copy_buffer = TRY(m_file->read_some(buffer));
if (copy_buffer.size() == 0) if (copy_buffer.size() == 0)
break; break;
// FIXME: This should write the entire span. TRY(file.write_until_depleted(copy_buffer));
TRY(file.write_some(copy_buffer));
} }
for (auto& change : m_changes) { for (auto& change : m_changes) {
TRY(file.seek(change.key, SeekMode::SetPosition)); TRY(file.seek(change.key, SeekMode::SetPosition));
// FIXME: This should write the entire span. TRY(file.write_until_depleted({ &change.value, 1 }));
TRY(file.write_some({ &change.value, 1 }));
} }
return {}; return {};

View file

@ -191,8 +191,7 @@ ErrorOr<void> KeyboardMapperWidget::save_to_file(StringView filename)
// Write to file. // Write to file.
DeprecatedString file_content = map_json.to_deprecated_string(); DeprecatedString file_content = map_json.to_deprecated_string();
auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Write)); auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Write));
// FIXME: This should write the entire span. TRY(file->write_until_depleted(file_content.bytes()));
TRY(file->write_some(file_content.bytes()));
file->close(); file->close();
window()->set_modified(false); window()->set_modified(false);

View file

@ -73,8 +73,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
filename = path.basename(); filename = path.basename();
auto encoded = TRY(dump_bitmap(magnifier->current_bitmap(), path.extension())); auto encoded = TRY(dump_bitmap(magnifier->current_bitmap(), path.extension()));
// FIXME: This should write the entire span. TRY(file->write_until_depleted(encoded));
TRY(file->write_some(encoded));
return {}; return {};
}; };

View file

@ -187,8 +187,7 @@ ErrorOr<void> RunWindow::save_history()
// Write the first 25 items of history // Write the first 25 items of history
for (int i = 0; i < min(static_cast<int>(m_path_history.size()), 25); i++) for (int i = 0; i < min(static_cast<int>(m_path_history.size()), 25); i++)
// FIXME: This should write the entire span. TRY(file->write_until_depleted(DeprecatedString::formatted("{}\n", m_path_history[i]).bytes()));
TRY(file->write_some(DeprecatedString::formatted("{}\n", m_path_history[i]).bytes()));
return {}; return {};
} }

View file

@ -632,25 +632,24 @@ ErrorOr<void> ChessWidget::import_pgn(Core::File& file)
ErrorOr<void> ChessWidget::export_pgn(Core::File& file) const ErrorOr<void> ChessWidget::export_pgn(Core::File& file) const
{ {
// Tag Pair Section // Tag Pair Section
// FIXME: This should write the entire span. TRY(file.write_until_depleted("[Event \"Casual Game\"]\n"sv.bytes()));
TRY(file.write_some("[Event \"Casual Game\"]\n"sv.bytes())); TRY(file.write_until_depleted("[Site \"SerenityOS Chess\"]\n"sv.bytes()));
TRY(file.write_some("[Site \"SerenityOS Chess\"]\n"sv.bytes())); TRY(file.write_until_depleted(DeprecatedString::formatted("[Date \"{}\"]\n", Core::DateTime::now().to_deprecated_string("%Y.%m.%d"sv)).bytes()));
TRY(file.write_some(DeprecatedString::formatted("[Date \"{}\"]\n", Core::DateTime::now().to_deprecated_string("%Y.%m.%d"sv)).bytes())); TRY(file.write_until_depleted("[Round \"1\"]\n"sv.bytes()));
TRY(file.write_some("[Round \"1\"]\n"sv.bytes()));
DeprecatedString username(getlogin()); DeprecatedString username(getlogin());
auto const player1 = (!username.is_empty() ? username.view() : "?"sv.bytes()); auto const player1 = (!username.is_empty() ? username.view() : "?"sv.bytes());
auto const player2 = (!m_engine.is_null() ? "SerenityOS ChessEngine"sv.bytes() : "?"sv.bytes()); auto const player2 = (!m_engine.is_null() ? "SerenityOS ChessEngine"sv.bytes() : "?"sv.bytes());
TRY(file.write_some(DeprecatedString::formatted("[White \"{}\"]\n", m_side == Chess::Color::White ? player1 : player2).bytes())); TRY(file.write_until_depleted(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_until_depleted(DeprecatedString::formatted("[Black \"{}\"]\n", m_side == Chess::Color::Black ? player1 : player2).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_until_depleted(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_until_depleted("[WhiteElo \"?\"]\n"sv.bytes()));
TRY(file.write_some("[BlackElo \"?\"]\n"sv.bytes())); TRY(file.write_until_depleted("[BlackElo \"?\"]\n"sv.bytes()));
TRY(file.write_some("[Variant \"Standard\"]\n"sv.bytes())); TRY(file.write_until_depleted("[Variant \"Standard\"]\n"sv.bytes()));
TRY(file.write_some("[TimeControl \"-\"]\n"sv.bytes())); TRY(file.write_until_depleted("[TimeControl \"-\"]\n"sv.bytes()));
TRY(file.write_some("[Annotator \"SerenityOS Chess\"]\n"sv.bytes())); TRY(file.write_until_depleted("[Annotator \"SerenityOS Chess\"]\n"sv.bytes()));
TRY(file.write_some("\n"sv.bytes())); TRY(file.write_until_depleted("\n"sv.bytes()));
// Movetext Section // Movetext Section
for (size_t i = 0, move_no = 1; i < m_board.moves().size(); i += 2, move_no++) { for (size_t i = 0, move_no = 1; i < m_board.moves().size(); i += 2, move_no++) {
@ -658,17 +657,17 @@ ErrorOr<void> ChessWidget::export_pgn(Core::File& file) const
if (i + 1 < m_board.moves().size()) { if (i + 1 < m_board.moves().size()) {
const DeprecatedString black = m_board.moves().at(i + 1).to_algebraic(); const DeprecatedString black = m_board.moves().at(i + 1).to_algebraic();
TRY(file.write_some(DeprecatedString::formatted("{}. {} {} ", move_no, white, black).bytes())); TRY(file.write_until_depleted(DeprecatedString::formatted("{}. {} {} ", move_no, white, black).bytes()));
} else { } else {
TRY(file.write_some(DeprecatedString::formatted("{}. {} ", move_no, white).bytes())); TRY(file.write_until_depleted(DeprecatedString::formatted("{}. {} ", move_no, white).bytes()));
} }
} }
TRY(file.write_some("{ "sv.bytes())); TRY(file.write_until_depleted("{ "sv.bytes()));
TRY(file.write_some(Chess::Board::result_to_string(m_board.game_result(), m_board.turn()).bytes())); TRY(file.write_until_depleted(Chess::Board::result_to_string(m_board.game_result(), m_board.turn()).bytes()));
TRY(file.write_some(" } "sv.bytes())); TRY(file.write_until_depleted(" } "sv.bytes()));
TRY(file.write_some(Chess::Board::result_to_points_string(m_board.game_result(), m_board.turn()).bytes())); TRY(file.write_until_depleted(Chess::Board::result_to_points_string(m_board.game_result(), m_board.turn()).bytes()));
TRY(file.write_some("\n"sv.bytes())); TRY(file.write_until_depleted("\n"sv.bytes()));
return {}; return {};
} }

View file

@ -233,9 +233,7 @@ ErrorOr<MP3::MP3Frame, LoaderError> MP3LoaderPlugin::read_frame_data(MP3::Header
size_t old_reservoir_size = m_bit_reservoir.used_buffer_size(); size_t old_reservoir_size = m_bit_reservoir.used_buffer_size();
LOADER_TRY(m_bitstream->read_until_filled(buffer)); LOADER_TRY(m_bitstream->read_until_filled(buffer));
// FIXME: This should write the entire span. LOADER_TRY(m_bit_reservoir.write_until_depleted(buffer));
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). // If we don't have enough data in the reservoir to process this frame, skip it (but keep the data).
if (old_reservoir_size < static_cast<size_t>(frame.main_data_begin)) if (old_reservoir_size < static_cast<size_t>(frame.main_data_begin))

View file

@ -225,10 +225,8 @@ ErrorOr<Bytes> DeflateDecompressor::read_some(Bytes bytes)
if (block_type == 0b00) { if (block_type == 0b00) {
m_input_stream->align_to_byte_boundary(); m_input_stream->align_to_byte_boundary();
// FIXME: This should read the entire span. u16 length = TRY(m_input_stream->read_value<LittleEndian<u16>>());
LittleEndian<u16> length, negated_length; u16 negated_length = TRY(m_input_stream->read_value<LittleEndian<u16>>());
TRY(m_input_stream->read_some(length.bytes()));
TRY(m_input_stream->read_some(negated_length.bytes()));
if ((length ^ 0xffff) != negated_length) if ((length ^ 0xffff) != negated_length)
return Error::from_string_literal("Calculated negated length does not equal stored negated length"); return Error::from_string_literal("Calculated negated length does not equal stored negated length");

View file

@ -75,10 +75,8 @@ ErrorOr<Bytes> GzipDecompressor::read_some(Bytes bytes)
current_member().m_nread += current_slice.size(); current_member().m_nread += current_slice.size();
if (current_slice.size() < slice.size()) { if (current_slice.size() < slice.size()) {
// FIXME: This should read the entire span. u32 crc32 = TRY(m_input_stream->read_value<LittleEndian<u32>>());
LittleEndian<u32> crc32, input_size; u32 input_size = TRY(m_input_stream->read_value<LittleEndian<u32>>());
TRY(m_input_stream->read_some(crc32.bytes()));
TRY(m_input_stream->read_some(input_size.bytes()));
if (crc32 != current_member().m_checksum.digest()) if (crc32 != current_member().m_checksum.digest())
return Error::from_string_literal("Stored CRC32 does not match the calculated CRC32 of the current member"); return Error::from_string_literal("Stored CRC32 does not match the calculated CRC32 of the current member");
@ -116,18 +114,16 @@ ErrorOr<Bytes> GzipDecompressor::read_some(Bytes bytes)
return Error::from_string_literal("Header is not supported by implementation"); return Error::from_string_literal("Header is not supported by implementation");
if (header.flags & Flags::FEXTRA) { if (header.flags & Flags::FEXTRA) {
// FIXME: This should read the entire span. u16 subfield_id = TRY(m_input_stream->read_value<LittleEndian<u16>>());
LittleEndian<u16> subfield_id, length; u16 length = TRY(m_input_stream->read_value<LittleEndian<u16>>());
TRY(m_input_stream->read_some(subfield_id.bytes()));
TRY(m_input_stream->read_some(length.bytes()));
TRY(m_input_stream->discard(length)); TRY(m_input_stream->discard(length));
(void)subfield_id;
} }
auto discard_string = [&]() -> ErrorOr<void> { auto discard_string = [&]() -> ErrorOr<void> {
char next_char; char next_char;
do { do {
// FIXME: This should read the entire span. next_char = TRY(m_input_stream->read_value<char>());
TRY(m_input_stream->read_some({ &next_char, sizeof(next_char) }));
} while (next_char); } while (next_char);
return {}; return {};
@ -140,10 +136,9 @@ ErrorOr<Bytes> GzipDecompressor::read_some(Bytes bytes)
TRY(discard_string()); TRY(discard_string());
if (header.flags & Flags::FHCRC) { if (header.flags & Flags::FHCRC) {
// FIXME: This should read the entire span. u16 crc = TRY(m_input_stream->read_value<LittleEndian<u16>>());
LittleEndian<u16> crc16;
TRY(m_input_stream->read_some(crc16.bytes()));
// FIXME: we should probably verify this instead of just assuming it matches // FIXME: we should probably verify this instead of just assuming it matches
(void)crc;
} }
m_current_member = TRY(Member::construct(header, *m_input_stream)); m_current_member = TRY(Member::construct(header, *m_input_stream));

View file

@ -113,8 +113,7 @@ ErrorOr<void> ZlibCompressor::write_header(ZlibCompressionMethod compression_met
// FIXME: Support pre-defined dictionaries. // FIXME: Support pre-defined dictionaries.
// FIXME: This should write the entire span. TRY(m_output_stream->write_until_depleted(header.as_u16.bytes()));
TRY(m_output_stream->write_some(header.as_u16.bytes()));
return {}; return {};
} }
@ -155,8 +154,7 @@ ErrorOr<void> ZlibCompressor::finish()
TRY(static_cast<DeflateCompressor*>(m_compressor.ptr())->final_flush()); TRY(static_cast<DeflateCompressor*>(m_compressor.ptr())->final_flush());
NetworkOrdered<u32> adler_sum = m_adler32_checksum.digest(); NetworkOrdered<u32> adler_sum = m_adler32_checksum.digest();
// FIXME: This should write the entire span. TRY(m_output_stream->write_value(adler_sum));
TRY(m_output_stream->write_some(adler_sum.bytes()));
m_finished = true; m_finished = true;

View file

@ -179,11 +179,10 @@ ErrorOr<void> ConfigFile::sync()
TRY(m_file->seek(0, SeekMode::SetPosition)); TRY(m_file->seek(0, SeekMode::SetPosition));
for (auto& it : m_groups) { for (auto& it : m_groups) {
// FIXME: This should write the entire span. TRY(m_file->write_until_depleted(DeprecatedString::formatted("[{}]\n", it.key).bytes()));
TRY(m_file->write_some(DeprecatedString::formatted("[{}]\n", it.key).bytes()));
for (auto& jt : it.value) for (auto& jt : it.value)
TRY(m_file->write_some(DeprecatedString::formatted("{}={}\n", jt.key, jt.value).bytes())); TRY(m_file->write_until_depleted(DeprecatedString::formatted("{}={}\n", jt.key, jt.value).bytes()));
TRY(m_file->write_some("\n"sv.bytes())); TRY(m_file->write_until_depleted("\n"sv.bytes()));
} }
m_dirty = false; m_dirty = false;

View file

@ -221,9 +221,7 @@ public:
auto bytes_to_send = serialized.bytes(); auto bytes_to_send = serialized.bytes();
u32 length = bytes_to_send.size(); u32 length = bytes_to_send.size();
// FIXME: Propagate errors // FIXME: Propagate errors
// FIXME: This should write the entire span. MUST(m_socket->write_value(length));
auto sent = MUST(m_socket->write_some({ (u8 const*)&length, sizeof(length) }));
VERIFY(sent == sizeof(length));
while (!bytes_to_send.is_empty()) { while (!bytes_to_send.is_empty()) {
size_t bytes_sent = MUST(m_socket->write_some(bytes_to_send)); size_t bytes_sent = MUST(m_socket->write_some(bytes_to_send));
bytes_to_send = bytes_to_send.slice(bytes_sent); bytes_to_send = bytes_to_send.slice(bytes_sent);

View file

@ -1593,9 +1593,8 @@ ErrorOr<void> TextEditor::write_to_file(Core::File& file)
// A size 0 file doesn't need a data copy. // A size 0 file doesn't need a data copy.
} else { } else {
for (size_t i = 0; i < line_count(); ++i) { for (size_t i = 0; i < line_count(); ++i) {
// FIXME: This should write the entire span. TRY(file.write_until_depleted(line(i).to_utf8().bytes()));
TRY(file.write_some(line(i).to_utf8().bytes())); TRY(file.write_until_depleted("\n"sv.bytes()));
TRY(file.write_some("\n"sv.bytes()));
} }
} }
document().set_unmodified(); document().set_unmodified();

View file

@ -60,8 +60,7 @@ ErrorOr<void> Client::on_ready_to_receive()
auto pending_bytes = TRY(m_socket->pending_bytes()); auto pending_bytes = TRY(m_socket->pending_bytes());
auto receive_buffer = TRY(m_buffer.get_bytes_for_writing(pending_bytes)); auto receive_buffer = TRY(m_buffer.get_bytes_for_writing(pending_bytes));
// FIXME: This should read the entire span. TRY(m_socket->read_until_filled(receive_buffer));
TRY(m_socket->read_some(receive_buffer));
// Once we get server hello we can start sending. // Once we get server hello we can start sending.
if (m_connect_pending) { if (m_connect_pending) {
@ -146,9 +145,8 @@ static ReadonlyBytes command_byte_buffer(CommandType command)
ErrorOr<void> Client::send_raw(StringView data) ErrorOr<void> Client::send_raw(StringView data)
{ {
// FIXME: This should write the entire span. TRY(m_socket->write_until_depleted(data.bytes()));
TRY(m_socket->write_some(data.bytes())); TRY(m_socket->write_until_depleted("\r\n"sv.bytes()));
TRY(m_socket->write_some("\r\n"sv.bytes()));
return {}; return {};
} }

View file

@ -680,8 +680,7 @@ ThrowCompletionOr<String> ConsoleClient::generically_format_values(MarkedVector<
bool first = true; bool first = true;
for (auto const& value : values) { for (auto const& value : values) {
if (!first) if (!first)
// FIXME: This should write the entire span. TRY_OR_THROW_OOM(vm, stream.write_until_depleted(" "sv.bytes()));
TRY_OR_THROW_OOM(vm, stream.write_some(" "sv.bytes()));
TRY_OR_THROW_OOM(vm, JS::print(value, ctx)); TRY_OR_THROW_OOM(vm, JS::print(value, ctx));
first = false; first = false;
} }

View file

@ -51,8 +51,7 @@ ErrorOr<void> XtermSuggestionDisplay::display(SuggestionManager const& manager)
// the suggestion list to fit in the prompt line. // the suggestion list to fit in the prompt line.
auto start = max_line_count - m_prompt_lines_at_suggestion_initiation; auto start = max_line_count - m_prompt_lines_at_suggestion_initiation;
for (size_t i = start; i < max_line_count; ++i) for (size_t i = start; i < max_line_count; ++i)
// FIXME: This should write the entire span. TRY(stderr_stream->write_until_depleted("\n"sv.bytes()));
TRY(stderr_stream->write_some("\n"sv.bytes()));
lines_used += max_line_count; lines_used += max_line_count;
longest_suggestion_length = 0; longest_suggestion_length = 0;
} }
@ -100,8 +99,7 @@ ErrorOr<void> XtermSuggestionDisplay::display(SuggestionManager const& manager)
if (next_column > m_num_columns) { if (next_column > m_num_columns) {
auto lines = (suggestion.text_view.length() + m_num_columns - 1) / m_num_columns; auto lines = (suggestion.text_view.length() + m_num_columns - 1) / m_num_columns;
lines_used += lines; lines_used += lines;
// FIXME: This should write the entire span. TRY(stderr_stream->write_until_depleted("\n"sv.bytes()));
TRY(stderr_stream->write_some("\n"sv.bytes()));
num_printed = 0; num_printed = 0;
} }
@ -117,13 +115,11 @@ ErrorOr<void> XtermSuggestionDisplay::display(SuggestionManager const& manager)
if (spans_entire_line) { if (spans_entire_line) {
num_printed += m_num_columns; num_printed += m_num_columns;
// FIXME: This should write the entire span. TRY(stderr_stream->write_until_depleted(suggestion.text_string.bytes()));
TRY(stderr_stream->write_some(suggestion.text_string.bytes())); TRY(stderr_stream->write_until_depleted(suggestion.display_trivia_string.bytes()));
TRY(stderr_stream->write_some(suggestion.display_trivia_string.bytes()));
} else { } else {
auto field = DeprecatedString::formatted("{: <{}} {}", suggestion.text_string, longest_suggestion_byte_length_without_trivia, suggestion.display_trivia_string); auto field = DeprecatedString::formatted("{: <{}} {}", suggestion.text_string, longest_suggestion_byte_length_without_trivia, suggestion.display_trivia_string);
// FIXME: This should write the entire span. TRY(stderr_stream->write_until_depleted(DeprecatedString::formatted("{: <{}}", field, longest_suggestion_byte_length + 2).bytes()));
TRY(stderr_stream->write_some(DeprecatedString::formatted("{: <{}}", field, longest_suggestion_byte_length + 2).bytes()));
num_printed += longest_suggestion_length + 2; num_printed += longest_suggestion_length + 2;
} }
@ -154,8 +150,7 @@ ErrorOr<void> XtermSuggestionDisplay::display(SuggestionManager const& manager)
TRY(VT::move_absolute(m_origin_row + lines_used, m_num_columns - string.length() - 1, *stderr_stream)); 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(VT::apply_style({ Style::Background(Style::XtermColor::Green) }, *stderr_stream));
// FIXME: This should write the entire span. TRY(stderr_stream->write_until_depleted(string.bytes()));
TRY(stderr_stream->write_some(string.bytes()));
TRY(VT::apply_style(Style::reset_style(), *stderr_stream)); TRY(VT::apply_style(Style::reset_style(), *stderr_stream));
} }

View file

@ -67,8 +67,7 @@ static ErrorOr<void> launch_server(DeprecatedString const& socket_path, Deprecat
if (server_pid != 0) { if (server_pid != 0) {
auto server_pid_file = TRY(Core::File::open(pid_path, Core::File::OpenMode::Write)); auto server_pid_file = TRY(Core::File::open(pid_path, Core::File::OpenMode::Write));
// FIXME: This should write the entire span. TRY(server_pid_file->write_until_depleted(DeprecatedString::number(server_pid).bytes()));
TRY(server_pid_file->write_some(DeprecatedString::number(server_pid).bytes()));
TRY(Core::System::kill(getpid(), SIGTERM)); TRY(Core::System::kill(getpid(), SIGTERM));
} }

View file

@ -220,8 +220,7 @@ inline ByteBuffer load_entire_file(StringView path)
auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read)); auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
auto file_size = TRY(file->size()); auto file_size = TRY(file->size());
auto content = TRY(ByteBuffer::create_uninitialized(file_size)); auto content = TRY(ByteBuffer::create_uninitialized(file_size));
// FIXME: This should read the entire span. TRY(file->read_until_filled(content.bytes()));
TRY(file->read_some(content.bytes()));
return content; return content;
}; };

View file

@ -279,8 +279,7 @@ ErrorOr<void, Client::WrappedError> Client::send_success_response(JsonValue resu
builder.append("\r\n"sv); builder.append("\r\n"sv);
auto builder_contents = TRY(builder.to_byte_buffer()); auto builder_contents = TRY(builder.to_byte_buffer());
// FIXME: This should write the entire span. TRY(m_socket->write_until_depleted(builder_contents));
TRY(m_socket->write_some(builder_contents));
while (!content.is_empty()) { while (!content.is_empty()) {
auto bytes_sent = TRY(m_socket->write_some(content.bytes())); auto bytes_sent = TRY(m_socket->write_some(content.bytes()));
@ -320,9 +319,8 @@ ErrorOr<void, Client::WrappedError> Client::send_error_response(Error const& err
header_builder.appendff("Content-Length: {}\r\n", content_builder.length()); header_builder.appendff("Content-Length: {}\r\n", content_builder.length());
header_builder.append("\r\n"sv); header_builder.append("\r\n"sv);
// FIXME: This should write the entire span. TRY(m_socket->write_until_depleted(TRY(header_builder.to_byte_buffer())));
TRY(m_socket->write_some(TRY(header_builder.to_byte_buffer()))); TRY(m_socket->write_until_depleted(TRY(content_builder.to_byte_buffer())));
TRY(m_socket->write_some(TRY(content_builder.to_byte_buffer())));
log_response(error.http_status); log_response(error.http_status);
return {}; return {};

View file

@ -40,8 +40,7 @@ ErrorOr<void> Client::drain_socket()
break; break;
} }
// FIXME: This should write the entire span. TRY(m_socket->write_until_depleted(bytes_read));
TRY(m_socket->write_some(bytes_read));
} }
return {}; return {};

View file

@ -240,8 +240,7 @@ ErrorOr<int> execute_work_items(Vector<WorkItem> const& items)
auto bytes_read = TRY(source_file->read_some(buffer.bytes())); auto bytes_read = TRY(source_file->read_some(buffer.bytes()));
if (bytes_read.is_empty()) if (bytes_read.is_empty())
break; break;
// FIXME: This should write the entire span. if (auto result = destination_file->write_until_depleted(bytes_read); result.is_error()) {
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. // 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())); report_warning(DeprecatedString::formatted("Failed to write to destination file: {}", result.error()));
return result.release_error(); return result.release_error();

View file

@ -26,9 +26,8 @@ InspectableProcess::InspectableProcess(pid_t pid, NonnullOwnPtr<Core::LocalSocke
MUST(m_socket->set_blocking(true)); MUST(m_socket->set_blocking(true));
m_socket->on_ready_to_read = [this] { m_socket->on_ready_to_read = [this] {
char c; [[maybe_unused]] auto c = m_socket->read_value<char>().release_value_but_fixme_should_propagate_errors();
// FIXME: This should read the entire span.
[[maybe_unused]] auto buffer = m_socket->read_some({ &c, 1 });
if (m_socket->is_eof()) { if (m_socket->is_eof()) {
Core::deferred_invoke([pid = this->m_pid] { g_processes.remove(pid); }); Core::deferred_invoke([pid = this->m_pid] { g_processes.remove(pid); });
return; return;
@ -44,14 +43,7 @@ DeprecatedString InspectableProcess::wait_for_response()
return {}; return {};
} }
u32 length {}; auto length = m_socket->read_value<u32>().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();
return {};
}
auto data_buffer = ByteBuffer::create_uninitialized(length).release_value_but_fixme_should_propagate_errors(); auto data_buffer = ByteBuffer::create_uninitialized(length).release_value_but_fixme_should_propagate_errors();
auto remaining_data_buffer = data_buffer.bytes(); auto remaining_data_buffer = data_buffer.bytes();
@ -82,9 +74,8 @@ void InspectableProcess::send_request(JsonObject const& request)
u32 length = serialized.length(); u32 length = serialized.length();
// FIXME: Propagate errors // FIXME: Propagate errors
// FIXME: This should write the entire span. MUST(m_socket->write_value(length));
MUST(m_socket->write_some({ (u8 const*)&length, sizeof(length) })); MUST(m_socket->write_until_depleted(serialized.bytes()));
MUST(m_socket->write_some(serialized.bytes()));
} }
} }

View file

@ -239,8 +239,7 @@ ErrorOr<Vector<Answer>> LookupServer::lookup(Name const& name, DeprecatedString
auto udp_socket = TRY(Core::UDPSocket::connect(nameserver, 53, Time::from_seconds(1))); auto udp_socket = TRY(Core::UDPSocket::connect(nameserver, 53, Time::from_seconds(1)));
TRY(udp_socket->set_blocking(true)); TRY(udp_socket->set_blocking(true));
// FIXME: This should write the entire span. TRY(udp_socket->write_until_depleted(buffer));
TRY(udp_socket->write_some(buffer));
u8 response_buffer[4096]; u8 response_buffer[4096];
int nrecv = TRY(udp_socket->read_some({ response_buffer, sizeof(response_buffer) })).size(); int nrecv = TRY(udp_socket->read_some({ response_buffer, sizeof(response_buffer) })).size();

View file

@ -161,8 +161,7 @@ ErrorOr<void> Client::send_data(StringView data)
} }
if (fast) { if (fast) {
// FIXME: This should write the entire span. TRY(m_socket->write_until_depleted({ data.characters_without_null_termination(), data.length() }));
TRY(m_socket->write_some({ data.characters_without_null_termination(), data.length() }));
return {}; return {};
} }
@ -184,8 +183,7 @@ ErrorOr<void> Client::send_data(StringView data)
} }
auto builder_contents = TRY(builder.to_byte_buffer()); auto builder_contents = TRY(builder.to_byte_buffer());
// FIXME: This should write the entire span. TRY(m_socket->write_until_depleted(builder_contents));
TRY(m_socket->write_some(builder_contents));
return {}; return {};
} }
@ -206,8 +204,7 @@ ErrorOr<void> Client::send_commands(Vector<Command> commands)
} }
VERIFY(TRY(stream.tell()) == buffer.size()); VERIFY(TRY(stream.tell()) == buffer.size());
// FIXME: This should write the entire span. TRY(m_socket->write_until_depleted({ buffer.data(), buffer.size() }));
TRY(m_socket->write_some({ buffer.data(), buffer.size() }));
return {}; return {};
} }

View file

@ -192,8 +192,7 @@ ErrorOr<void> Client::send_response(Stream& response, HTTP::HttpRequest const& r
builder.append("\r\n"sv); builder.append("\r\n"sv);
auto builder_contents = TRY(builder.to_byte_buffer()); auto builder_contents = TRY(builder.to_byte_buffer());
// FIXME: This should write the entire span. TRY(m_socket->write_until_depleted(builder_contents));
TRY(m_socket->write_some(builder_contents));
log_response(200, request); log_response(200, request);
char buffer[PAGE_SIZE]; char buffer[PAGE_SIZE];
@ -235,8 +234,7 @@ ErrorOr<void> Client::send_redirect(StringView redirect_path, HTTP::HttpRequest
builder.append("\r\n"sv); builder.append("\r\n"sv);
auto builder_contents = TRY(builder.to_byte_buffer()); auto builder_contents = TRY(builder.to_byte_buffer());
// FIXME: This should write the entire span. TRY(m_socket->write_until_depleted(builder_contents));
TRY(m_socket->write_some(builder_contents));
log_response(301, request); log_response(301, request);
return {}; return {};
@ -365,9 +363,8 @@ ErrorOr<void> Client::send_error_response(unsigned code, HTTP::HttpRequest const
header_builder.append("Content-Type: text/html; charset=UTF-8\r\n"sv); 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.appendff("Content-Length: {}\r\n", content_builder.length());
header_builder.append("\r\n"sv); header_builder.append("\r\n"sv);
// FIXME: This should write the entire span. TRY(m_socket->write_until_depleted(TRY(header_builder.to_byte_buffer())));
TRY(m_socket->write_some(TRY(header_builder.to_byte_buffer()))); TRY(m_socket->write_until_depleted(TRY(content_builder.to_byte_buffer())));
TRY(m_socket->write_some(TRY(content_builder.to_byte_buffer())));
log_response(code, request); log_response(code, request);
return {}; return {};

View file

@ -28,8 +28,7 @@ static ErrorOr<bool> format_file(StringView path, bool inplace)
return true; return true;
TRY(file->seek(0, SeekMode::SetPosition)); TRY(file->seek(0, SeekMode::SetPosition));
TRY(file->truncate(0)); TRY(file->truncate(0));
// FIXME: This should write the entire span. TRY(file->write_until_depleted(formatted_gml.bytes()));
TRY(file->write_some(formatted_gml.bytes()));
} else { } else {
out("{}", formatted_gml); out("{}", formatted_gml);
} }

View file

@ -174,8 +174,7 @@ static ErrorOr<NonnullRefPtr<Core::Timer>> load_page_for_screenshot_and_exit(Cor
auto output_file = MUST(Core::File::open(output_file_path, Core::File::OpenMode::Write)); auto output_file = MUST(Core::File::open(output_file_path, Core::File::OpenMode::Write));
auto image_buffer = MUST(Gfx::PNGWriter::encode(*screenshot)); auto image_buffer = MUST(Gfx::PNGWriter::encode(*screenshot));
// FIXME: This should write the entire buffer. MUST(output_file->write_until_depleted(image_buffer.bytes()));
MUST(output_file->write_some(image_buffer.bytes()));
} else { } else {
warnln("No screenshot available"); warnln("No screenshot available");
} }

View file

@ -188,8 +188,7 @@ static ErrorOr<void> write_to_file(String const& path)
for (size_t i = 0; i < g_repl_statements.size(); i++) { for (size_t i = 0; i < g_repl_statements.size(); i++) {
auto line = g_repl_statements[i].bytes(); auto line = g_repl_statements[i].bytes();
if (line.size() > 0 && i != g_repl_statements.size() - 1) { if (line.size() > 0 && i != g_repl_statements.size() - 1) {
// FIXME: This should write the entire span. TRY(file->write_until_depleted(line));
TRY(file->write_some(line));
} }
if (i != g_repl_statements.size() - 1) { if (i != g_repl_statements.size() - 1) {
TRY(file->write_value('\n')); TRY(file->write_value('\n'));

View file

@ -82,8 +82,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto nread = TRY(Core::System::read(STDIN_FILENO, buffer_span)); auto nread = TRY(Core::System::read(STDIN_FILENO, buffer_span));
buffer_span = buffer_span.trim(nread); buffer_span = buffer_span.trim(nread);
// FIXME: This should write the entire span. TRY(socket->write_until_depleted({ buffer_span.data(), static_cast<size_t>(nread) }));
TRY(socket->write_some({ buffer_span.data(), static_cast<size_t>(nread) }));
} }
} }

View file

@ -14,8 +14,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
auto file = TRY(Core::File::open("/sys/kernel/power_state"sv, Core::File::OpenMode::Write)); auto file = TRY(Core::File::open("/sys/kernel/power_state"sv, Core::File::OpenMode::Write));
const DeprecatedString file_contents = "1"; const DeprecatedString file_contents = "1";
// FIXME: This should write the entire span. TRY(file->write_until_depleted(file_contents.bytes()));
TRY(file->write_some(file_contents.bytes()));
file->close(); file->close();
return 0; return 0;

View file

@ -141,9 +141,8 @@ ErrorOr<int> serenity_main(Main::Arguments args)
if (maybe_output_file.has_value()) { if (maybe_output_file.has_value()) {
auto const& output_file = maybe_output_file.value(); auto const& output_file = maybe_output_file.value();
// FIXME: This should write the entire span. TRY(output_file->write_until_depleted(result.bytes()));
TRY(output_file->write_some(result.bytes())); TRY(output_file->write_until_depleted("\n"sv.bytes()));
TRY(output_file->write_some("\n"sv.bytes()));
} }
} }
} }

View file

@ -167,8 +167,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
} }
auto& file = *file_or_error.value(); auto& file = *file_or_error.value();
// FIXME: This should write the entire span. TRY(file.write_until_depleted(encoded_bitmap.bytes()));
TRY(file.write_some(encoded_bitmap.bytes()));
if (edit_image) if (edit_image)
TRY(Core::Process::spawn("/bin/PixelPaint"sv, Array { output_path })); TRY(Core::Process::spawn("/bin/PixelPaint"sv, Array { output_path }));

View file

@ -18,8 +18,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
auto file = TRY(Core::File::open("/sys/kernel/power_state"sv, Core::File::OpenMode::Write)); auto file = TRY(Core::File::open("/sys/kernel/power_state"sv, Core::File::OpenMode::Write));
const DeprecatedString file_contents = "2"; const DeprecatedString file_contents = "2";
// FIXME: This should write the entire span. TRY(file->write_until_depleted(file_contents.bytes()));
TRY(file->write_some(file_contents.bytes()));
file->close(); file->close();
return 0; return 0;

View file

@ -932,7 +932,6 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
FormattedSyscallBuilder builder(syscall_name); FormattedSyscallBuilder builder(syscall_name);
TRY(format_syscall(builder, syscall_function, arg1, arg2, arg3, res)); TRY(format_syscall(builder, syscall_function, arg1, arg2, arg3, res));
// FIXME: This should write the entire span. TRY(trace_file->write_until_depleted(builder.string_view().bytes()));
TRY(trace_file->write_some(builder.string_view().bytes()));
} }
} }

View file

@ -48,8 +48,7 @@ static bool write_variable(StringView name, StringView value)
warnln("Failed to open {}: {}", path, file.error()); warnln("Failed to open {}: {}", path, file.error());
return false; return false;
} }
// FIXME: This should write the entire span. if (auto result = file.value()->write_until_depleted(value.bytes()); result.is_error()) {
if (auto result = file.value()->write_some(value.bytes()); result.is_error()) {
warnln("Failed to write {}: {}", path, result.error()); warnln("Failed to write {}: {}", path, result.error());
return false; return false;
} }

View file

@ -34,10 +34,8 @@ static ErrorOr<off_t> find_seek_pos(Core::File& file, int wanted_lines)
if (file.is_eof()) if (file.is_eof())
break; break;
Array<u8, 1> buffer; auto ch = TRY(file.read_value<u8>());
// FIXME: This should read the entire span. if (ch == '\n' && (end - pos) > 1) {
auto ch = TRY(file.read_some(buffer));
if (*ch.data() == '\n' && (end - pos) > 1) {
lines++; lines++;
if (lines == wanted_lines) if (lines == wanted_lines)
break; break;

View file

@ -17,11 +17,10 @@ static ErrorOr<void> write_line_content(StringView line, size_t count, bool dupl
if (duplicates_only && count <= 1) if (duplicates_only && count <= 1)
return {}; return {};
// FIXME: This should write the entire span.
if (print_count) if (print_count)
TRY(outfile.write_some(DeprecatedString::formatted("{} {}\n", count, line).bytes())); TRY(outfile.write_until_depleted(DeprecatedString::formatted("{} {}\n", count, line).bytes()));
else else
TRY(outfile.write_some(DeprecatedString::formatted("{}\n", line).bytes())); TRY(outfile.write_until_depleted(DeprecatedString::formatted("{}\n", line).bytes()));
return {}; return {};
} }

View file

@ -72,8 +72,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(file->seek(0, SeekMode::SetPosition)); TRY(file->seek(0, SeekMode::SetPosition));
TRY(file->truncate(0)); TRY(file->truncate(0));
// FIXME: This should write the entire span. TRY(file->write_until_depleted(json.to_deprecated_string().bytes()));
TRY(file->write_some(json.to_deprecated_string().bytes()));
return 0; return 0;
} }

View file

@ -53,14 +53,12 @@ static bool pre_interpret_hook(Wasm::Configuration& config, Wasm::InstructionPoi
if (always_print_stack) if (always_print_stack)
config.dump_stack(); config.dump_stack();
if (always_print_instruction) { if (always_print_instruction) {
// FIXME: This should write the entire span. g_stdout->write_until_depleted(DeprecatedString::formatted("{:0>4} ", ip.value()).bytes()).release_value_but_fixme_should_propagate_errors();
g_stdout->write_some(DeprecatedString::formatted("{:0>4} ", ip.value()).bytes()).release_value_but_fixme_should_propagate_errors();
g_printer->print(instr); g_printer->print(instr);
} }
if (g_continue) if (g_continue)
return true; return true;
// FIXME: This should write the entire span. g_stdout->write_until_depleted(DeprecatedString::formatted("{:0>4} ", ip.value()).bytes()).release_value_but_fixme_should_propagate_errors();
g_stdout->write_some(DeprecatedString::formatted("{:0>4} ", ip.value()).bytes()).release_value_but_fixme_should_propagate_errors();
g_printer->print(instr); g_printer->print(instr);
DeprecatedString last_command = ""; DeprecatedString last_command = "";
for (;;) { for (;;) {
@ -216,8 +214,7 @@ static bool pre_interpret_hook(Wasm::Configuration& config, Wasm::InstructionPoi
if (!result.values().is_empty()) if (!result.values().is_empty())
warnln("Returned:"); warnln("Returned:");
for (auto& value : result.values()) { for (auto& value : result.values()) {
// FIXME: This should write the entire span. g_stdout->write_until_depleted(" -> "sv.bytes()).release_value_but_fixme_should_propagate_errors();
g_stdout->write_some(" -> "sv.bytes()).release_value_but_fixme_should_propagate_errors();
g_printer->print(value); g_printer->print(value);
} }
} }
@ -457,18 +454,15 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto print_func = [&](auto const& address) { auto print_func = [&](auto const& address) {
Wasm::FunctionInstance* fn = machine.store().get(address); Wasm::FunctionInstance* fn = machine.store().get(address);
// FIXME: This should write the entire span. g_stdout->write_until_depleted(DeprecatedString::formatted("- Function with address {}, ptr = {}\n", address.value(), fn).bytes()).release_value_but_fixme_should_propagate_errors();
g_stdout->write_some(DeprecatedString::formatted("- Function with address {}, ptr = {}\n", address.value(), fn).bytes()).release_value_but_fixme_should_propagate_errors();
if (fn) { if (fn) {
// FIXME: This should write the entire span. g_stdout->write_until_depleted(DeprecatedString::formatted(" wasm function? {}\n", fn->has<Wasm::WasmFunction>()).bytes()).release_value_but_fixme_should_propagate_errors();
g_stdout->write_some(DeprecatedString::formatted(" wasm function? {}\n", fn->has<Wasm::WasmFunction>()).bytes()).release_value_but_fixme_should_propagate_errors();
fn->visit( fn->visit(
[&](Wasm::WasmFunction const& func) { [&](Wasm::WasmFunction const& func) {
Wasm::Printer printer { *g_stdout, 3 }; Wasm::Printer printer { *g_stdout, 3 };
// FIXME: This should write the entire span. g_stdout->write_until_depleted(" type:\n"sv.bytes()).release_value_but_fixme_should_propagate_errors();
g_stdout->write_some(" type:\n"sv.bytes()).release_value_but_fixme_should_propagate_errors();
printer.print(func.type()); printer.print(func.type());
g_stdout->write_some(" code:\n"sv.bytes()).release_value_but_fixme_should_propagate_errors(); g_stdout->write_until_depleted(" code:\n"sv.bytes()).release_value_but_fixme_should_propagate_errors();
printer.print(func.code()); printer.print(func.code());
}, },
[](Wasm::HostFunction const&) {}); [](Wasm::HostFunction const&) {});
@ -532,8 +526,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (!result.values().is_empty()) if (!result.values().is_empty())
warnln("Returned:"); warnln("Returned:");
for (auto& value : result.values()) { for (auto& value : result.values()) {
// FIXME: This should write the entire span. g_stdout->write_until_depleted(" -> "sv.bytes()).release_value_but_fixme_should_propagate_errors();
g_stdout->write_some(" -> "sv.bytes()).release_value_but_fixme_should_propagate_errors();
g_printer->print(value); g_printer->print(value);
} }
} }