diff --git a/Userland/Utilities/strace.cpp b/Userland/Utilities/strace.cpp index dfbde587c4..56577c0215 100644 --- a/Userland/Utilities/strace.cpp +++ b/Userland/Utilities/strace.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include @@ -239,7 +239,7 @@ static ErrorOr copy_from_process(void const* source, size_t length) } template -static ErrorOr copy_from_process(const T* source) +static ErrorOr copy_from_process(T const* source) { T value {}; TRY(copy_from_process(source, Bytes { &value, sizeof(T) })); @@ -812,12 +812,11 @@ ErrorOr serenity_main(Main::Arguments arguments) Vector child_argv; - char const* output_filename = nullptr; + StringView output_filename; char const* exclude_syscalls_option = nullptr; char const* include_syscalls_option = nullptr; HashTable exclude_syscalls; HashTable include_syscalls; - auto trace_file = Core::File::standard_error(); Core::ArgsParser parser; parser.set_stop_on_first_non_option(true); @@ -831,8 +830,9 @@ ErrorOr serenity_main(Main::Arguments arguments) parser.parse(arguments); - if (output_filename != nullptr) - trace_file = TRY(Core::File::open(output_filename, Core::OpenMode::WriteOnly)); + auto trace_file = output_filename.is_empty() + ? TRY(Core::Stream::File::standard_error()) + : TRY(Core::Stream::File::open(output_filename, Core::Stream::OpenMode::Write)); auto parse_syscalls = [](char const* option, auto& hash_table) { if (option != nullptr) { @@ -933,9 +933,6 @@ ErrorOr serenity_main(Main::Arguments arguments) FormattedSyscallBuilder builder(syscall_name); format_syscall(builder, syscall_function, arg1, arg2, arg3, res); - if (!trace_file->write(builder.string_view())) { - warnln("write: {}", trace_file->error_string()); - return 1; - } + TRY(trace_file->write(builder.string_view().bytes())); } }