diff --git a/Userland/Libraries/LibAudio/Loader.cpp b/Userland/Libraries/LibAudio/Loader.cpp index c504b028bd..47cb71c036 100644 --- a/Userland/Libraries/LibAudio/Loader.cpp +++ b/Userland/Libraries/LibAudio/Loader.cpp @@ -45,13 +45,15 @@ static constexpr LoaderPluginInitializer s_initializers[] = { ErrorOr, LoaderError> Loader::create(StringView path) { auto stream = TRY(Core::MappedFile::map(path, Core::MappedFile::Mode::ReadOnly)); - return adopt_ref(*new (nothrow) Loader(TRY(Loader::create_plugin(move(stream))))); + auto plugin = TRY(Loader::create_plugin(move(stream))); + return adopt_ref(*new (nothrow) Loader(move(plugin))); } ErrorOr, LoaderError> Loader::create(ReadonlyBytes buffer) { auto stream = TRY(try_make(buffer)); - return adopt_ref(*new (nothrow) Loader(TRY(Loader::create_plugin(move(stream))))); + auto plugin = TRY(Loader::create_plugin(move(stream))); + return adopt_ref(*new (nothrow) Loader(move(plugin))); } ErrorOr, LoaderError> Loader::create_plugin(NonnullOwnPtr stream) diff --git a/Userland/Libraries/LibChess/UCICommand.cpp b/Userland/Libraries/LibChess/UCICommand.cpp index c969617683..17fb770a1d 100644 --- a/Userland/Libraries/LibChess/UCICommand.cpp +++ b/Userland/Libraries/LibChess/UCICommand.cpp @@ -94,9 +94,9 @@ ErrorOr> SetOptionCommand::from_string(StringVie VERIFY(!name.is_empty()); - return adopt_nonnull_own_or_enomem(new (nothrow) SetOptionCommand( - TRY(String::from_utf8(name.string_view().trim_whitespace())), - TRY(String::from_utf8(value.string_view().trim_whitespace())))); + auto name_string = TRY(String::from_utf8(name.string_view().trim_whitespace())); + auto value_string = TRY(String::from_utf8(value.string_view().trim_whitespace())); + return adopt_nonnull_own_or_enomem(new (nothrow) SetOptionCommand(name_string, value_string)); } ErrorOr SetOptionCommand::to_string() const @@ -259,10 +259,11 @@ ErrorOr> IdCommand::from_string(StringView command) TRY(value.try_append(tokens[i])); } + auto value_string = TRY(value.to_string()); if (tokens[1] == "name") { - return adopt_nonnull_own_or_enomem(new (nothrow) IdCommand(Type::Name, TRY(value.to_string()))); + return adopt_nonnull_own_or_enomem(new (nothrow) IdCommand(Type::Name, value_string)); } else if (tokens[1] == "author") { - return adopt_nonnull_own_or_enomem(new (nothrow) IdCommand(Type::Author, TRY(value.to_string()))); + return adopt_nonnull_own_or_enomem(new (nothrow) IdCommand(Type::Author, value_string)); } VERIFY_NOT_REACHED(); } diff --git a/Userland/Libraries/LibGUI/InputBox.cpp b/Userland/Libraries/LibGUI/InputBox.cpp index 92b476c6f9..a6869603a6 100644 --- a/Userland/Libraries/LibGUI/InputBox.cpp +++ b/Userland/Libraries/LibGUI/InputBox.cpp @@ -19,14 +19,18 @@ namespace GUI { ErrorOr> InputBox::create(Window* parent_window, String text_value, StringView prompt, StringView title, InputType input_type, RefPtr icon) { VERIFY(input_type != InputType::Numeric); - auto box = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) InputBox(parent_window, text_value, TRY(String::from_utf8(title)), TRY(String::from_utf8(prompt)), input_type, move(icon)))); + auto title_string = TRY(String::from_utf8(title)); + auto prompt_string = TRY(String::from_utf8(prompt)); + auto box = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) InputBox(parent_window, text_value, title_string, prompt_string, input_type, move(icon)))); TRY(box->build()); return box; } ErrorOr> InputBox::create_numeric(Window* parent_window, int value, StringView title, StringView prompt, RefPtr icon) { - auto box = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) InputBox(parent_window, value, TRY(String::from_utf8(title)), TRY(String::from_utf8(prompt)), move(icon)))); + auto title_string = TRY(String::from_utf8(title)); + auto prompt_string = TRY(String::from_utf8(prompt)); + auto box = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) InputBox(parent_window, value, title_string, prompt_string, move(icon)))); TRY(box->build()); return box; } diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp index 75b7791757..276bf913e2 100644 --- a/Userland/Shell/Shell.cpp +++ b/Userland/Shell/Shell.cpp @@ -420,8 +420,10 @@ ErrorOr> Shell::look_up_local_variable(StringView name) ErrorOr> Shell::get_argument(size_t index) const { - if (index == 0) - return adopt_ref(*new AST::StringValue(TRY(String::from_deprecated_string(current_script)))); + if (index == 0) { + auto current_script_string = TRY(String::from_deprecated_string(current_script)); + return adopt_ref(*new AST::StringValue(current_script_string)); + } --index; if (auto argv = TRY(look_up_local_variable("ARGV"sv))) {