1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:54: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

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