diff --git a/AK/BufferedStream.h b/AK/BufferedStream.h index 8ff0c9b889..528bd49a98 100644 --- a/AK/BufferedStream.h +++ b/AK/BufferedStream.h @@ -238,12 +238,12 @@ private: auto result = stream().read(fillable_slice); if (result.is_error()) { if (!result.error().is_errno()) - return result.error(); + return result.release_error(); if (result.error().code() == EINTR) continue; if (result.error().code() == EAGAIN) break; - return result.error(); + return result.release_error(); } auto const filled_slice = result.value(); VERIFY(m_buffer.write(filled_slice) == filled_slice.size()); diff --git a/Kernel/Bus/PCI/Access.cpp b/Kernel/Bus/PCI/Access.cpp index 4a78f43b99..507e968145 100644 --- a/Kernel/Bus/PCI/Access.cpp +++ b/Kernel/Bus/PCI/Access.cpp @@ -137,7 +137,7 @@ ErrorOr Access::add_host_controller_and_scan_for_devices(NonnullOwnPtrenumerate_attached_devices([&](EnumerableDeviceIdentifier const& device_identifier) -> IterationDecision { auto device_identifier_or_error = DeviceIdentifier::from_enumerable_identifier(device_identifier); if (device_identifier_or_error.is_error()) { - error_or_void = device_identifier_or_error.error(); + error_or_void = device_identifier_or_error.release_error(); return IterationDecision::Break; } m_device_identifiers.append(device_identifier_or_error.release_value()); @@ -167,7 +167,7 @@ UNMAP_AFTER_INIT void Access::rescan_hardware() (*it).value->enumerate_attached_devices([this, &error_or_void](EnumerableDeviceIdentifier device_identifier) -> IterationDecision { auto device_identifier_or_error = DeviceIdentifier::from_enumerable_identifier(device_identifier); if (device_identifier_or_error.is_error()) { - error_or_void = device_identifier_or_error.error(); + error_or_void = device_identifier_or_error.release_error(); return IterationDecision::Break; } m_device_identifiers.append(device_identifier_or_error.release_value()); diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index 21de0cca03..c6dfeceb77 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -403,7 +403,7 @@ ErrorOr IPv4Socket::recvfrom(OpenFileDescription& description, UserOrKer nreceived = receive_packet_buffered(description, offset_buffer, offset_buffer_length, flags, user_addr, user_addr_length, packet_timestamp, blocking); if (nreceived.is_error()) - total_nreceived = nreceived; + total_nreceived = move(nreceived); else total_nreceived.value() += nreceived.value(); } while ((flags & MSG_WAITALL) && !total_nreceived.is_error() && total_nreceived.value() < buffer_length); diff --git a/Kernel/PerformanceEventBuffer.cpp b/Kernel/PerformanceEventBuffer.cpp index 71781b8b77..9c6c765fca 100644 --- a/Kernel/PerformanceEventBuffer.cpp +++ b/Kernel/PerformanceEventBuffer.cpp @@ -22,7 +22,7 @@ PerformanceEventBuffer::PerformanceEventBuffer(NonnullOwnPtr buffer) { } -NEVER_INLINE ErrorOr PerformanceEventBuffer::append(int type, FlatPtr arg1, FlatPtr arg2, StringView arg3, Thread* current_thread, FlatPtr arg4, u64 arg5, ErrorOr arg6) +NEVER_INLINE ErrorOr PerformanceEventBuffer::append(int type, FlatPtr arg1, FlatPtr arg2, StringView arg3, Thread* current_thread, FlatPtr arg4, u64 arg5, ErrorOr const& arg6) { FlatPtr base_pointer = (FlatPtr)__builtin_frame_address(0); return append_with_ip_and_bp(current_thread->pid(), current_thread->tid(), 0, base_pointer, type, 0, arg1, arg2, arg3, arg4, arg5, arg6); @@ -66,13 +66,13 @@ static Vector raw_backtrace(Fl } ErrorOr PerformanceEventBuffer::append_with_ip_and_bp(ProcessID pid, ThreadID tid, RegisterState const& regs, - int type, u32 lost_samples, FlatPtr arg1, FlatPtr arg2, StringView arg3, FlatPtr arg4, u64 arg5, ErrorOr arg6) + int type, u32 lost_samples, FlatPtr arg1, FlatPtr arg2, StringView arg3, FlatPtr arg4, u64 arg5, ErrorOr const& arg6) { return append_with_ip_and_bp(pid, tid, regs.ip(), regs.bp(), type, lost_samples, arg1, arg2, arg3, arg4, arg5, arg6); } ErrorOr PerformanceEventBuffer::append_with_ip_and_bp(ProcessID pid, ThreadID tid, - FlatPtr ip, FlatPtr bp, int type, u32 lost_samples, FlatPtr arg1, FlatPtr arg2, StringView arg3, FlatPtr arg4, u64 arg5, ErrorOr arg6) + FlatPtr ip, FlatPtr bp, int type, u32 lost_samples, FlatPtr arg1, FlatPtr arg2, StringView arg3, FlatPtr arg4, u64 arg5, ErrorOr const& arg6) { if (count() >= capacity()) return ENOBUFS; diff --git a/Kernel/PerformanceEventBuffer.h b/Kernel/PerformanceEventBuffer.h index bd246176b8..07cf54983d 100644 --- a/Kernel/PerformanceEventBuffer.h +++ b/Kernel/PerformanceEventBuffer.h @@ -110,11 +110,11 @@ class PerformanceEventBuffer { public: static OwnPtr try_create_with_size(size_t buffer_size); - ErrorOr append(int type, FlatPtr arg1, FlatPtr arg2, StringView arg3, Thread* current_thread = Thread::current(), FlatPtr arg4 = 0, u64 arg5 = 0, ErrorOr arg6 = 0); + ErrorOr append(int type, FlatPtr arg1, FlatPtr arg2, StringView arg3, Thread* current_thread = Thread::current(), FlatPtr arg4 = 0, u64 arg5 = 0, ErrorOr const& arg6 = 0); ErrorOr append_with_ip_and_bp(ProcessID pid, ThreadID tid, FlatPtr eip, FlatPtr ebp, - int type, u32 lost_samples, FlatPtr arg1, FlatPtr arg2, StringView arg3, FlatPtr arg4 = 0, u64 arg5 = {}, ErrorOr arg6 = 0); + int type, u32 lost_samples, FlatPtr arg1, FlatPtr arg2, StringView arg3, FlatPtr arg4 = 0, u64 arg5 = {}, ErrorOr const& arg6 = 0); ErrorOr append_with_ip_and_bp(ProcessID pid, ThreadID tid, RegisterState const& regs, - int type, u32 lost_samples, FlatPtr arg1, FlatPtr arg2, StringView arg3, FlatPtr arg4 = 0, u64 arg5 = {}, ErrorOr arg6 = 0); + int type, u32 lost_samples, FlatPtr arg1, FlatPtr arg2, StringView arg3, FlatPtr arg4 = 0, u64 arg5 = {}, ErrorOr const& arg6 = 0); void clear() { diff --git a/Kernel/PerformanceManager.h b/Kernel/PerformanceManager.h index a236334339..36283e9da1 100644 --- a/Kernel/PerformanceManager.h +++ b/Kernel/PerformanceManager.h @@ -127,7 +127,7 @@ public: } } - static void add_read_event(Thread& thread, int fd, size_t size, OpenFileDescription const& file_description, u64 start_timestamp, ErrorOr result) + static void add_read_event(Thread& thread, int fd, size_t size, OpenFileDescription const& file_description, u64 start_timestamp, ErrorOr const& result) { if (thread.is_profiling_suppressed()) return; diff --git a/Kernel/Syscalls/read.cpp b/Kernel/Syscalls/read.cpp index f272b0c6de..3314b2bf37 100644 --- a/Kernel/Syscalls/read.cpp +++ b/Kernel/Syscalls/read.cpp @@ -74,7 +74,7 @@ ErrorOr Process::sys$readv(int fd, Userspace iov, ErrorOr Process::sys$read(int fd, Userspace buffer, size_t size) { auto const start_timestamp = TimeManagement::the().uptime_ms(); - auto const result = read_impl(fd, buffer, size); + auto result = read_impl(fd, buffer, size); if (Thread::current()->is_profiling_suppressed()) return result; diff --git a/Userland/Applications/FontEditor/MainWidget.cpp b/Userland/Applications/FontEditor/MainWidget.cpp index 1f4930ec9b..a3dc9d71a7 100644 --- a/Userland/Applications/FontEditor/MainWidget.cpp +++ b/Userland/Applications/FontEditor/MainWidget.cpp @@ -101,9 +101,9 @@ ErrorOr MainWidget::create_actions() new_font_wizard->hide(); auto maybe_font = new_font_wizard->create_font(); if (maybe_font.is_error()) - return show_error(maybe_font.error(), "Creating new font failed"sv); + return show_error(maybe_font.release_error(), "Creating new font failed"sv); if (auto result = initialize({}, move(maybe_font.value())); result.is_error()) - show_error(result.error(), "Initializing new font failed"sv); + show_error(result.release_error(), "Initializing new font failed"sv); }); m_new_action->set_status_tip("Create a new font"); @@ -114,14 +114,14 @@ ErrorOr MainWidget::create_actions() if (!open_path.has_value()) return; if (auto result = open_file(open_path.value()); result.is_error()) - show_error(result.error(), "Opening"sv, LexicalPath { open_path.value() }.basename()); + show_error(result.release_error(), "Opening"sv, LexicalPath { open_path.value() }.basename()); }); m_save_action = GUI::CommonActions::make_save_action([&](auto&) { if (m_path.is_empty()) return m_save_as_action->activate(); if (auto result = save_file(m_path); result.is_error()) - show_error(result.error(), "Saving"sv, LexicalPath { m_path }.basename()); + show_error(result.release_error(), "Saving"sv, LexicalPath { m_path }.basename()); }); m_save_as_action = GUI::CommonActions::make_save_as_action([&](auto&) { @@ -130,17 +130,17 @@ ErrorOr MainWidget::create_actions() if (!save_path.has_value()) return; if (auto result = save_file(save_path.value()); result.is_error()) - show_error(result.error(), "Saving"sv, lexical_path.basename()); + show_error(result.release_error(), "Saving"sv, lexical_path.basename()); }); m_cut_action = GUI::CommonActions::make_cut_action([&](auto&) { if (auto result = cut_selected_glyphs(); result.is_error()) - show_error(result.error(), "Cutting selection failed"sv); + show_error(result.release_error(), "Cutting selection failed"sv); }); m_copy_action = GUI::CommonActions::make_copy_action([&](auto&) { if (auto result = copy_selected_glyphs(); result.is_error()) - show_error(result.error(), "Copying selection failed"sv); + show_error(result.release_error(), "Copying selection failed"sv); }); m_paste_action = GUI::CommonActions::make_paste_action([&](auto&) { @@ -178,7 +178,7 @@ ErrorOr MainWidget::create_actions() m_open_preview_action = GUI::Action::create("&Preview Font", { Mod_Ctrl, Key_P }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/find.png"sv)), [&](auto&) { if (!m_font_preview_window) { if (auto maybe_window = create_preview_window(); maybe_window.is_error()) - show_error(maybe_window.error(), "Creating preview window failed"sv); + show_error(maybe_window.release_error(), "Creating preview window failed"sv); else m_font_preview_window = maybe_window.release_value(); } @@ -792,12 +792,12 @@ void MainWidget::push_undo() { auto maybe_state = m_undo_selection->save_state(); if (maybe_state.is_error()) - return show_error(maybe_state.error(), "Saving undo state failed"sv); + return show_error(maybe_state.release_error(), "Saving undo state failed"sv); auto maybe_command = try_make(*m_undo_selection, move(maybe_state.value())); if (maybe_command.is_error()) - return show_error(maybe_command.error(), "Making undo command failed"sv); + return show_error(maybe_command.release_error(), "Making undo command failed"sv); if (auto maybe_push = m_undo_stack->try_push(move(maybe_command.value())); maybe_push.is_error()) - show_error(maybe_push.error(), "Pushing undo stack failed"sv); + show_error(maybe_push.release_error(), "Pushing undo stack failed"sv); } void MainWidget::reset_selection_and_push_undo() @@ -976,7 +976,7 @@ void MainWidget::drop_event(GUI::DropEvent& event) return; if (auto result = open_file(urls.first().path()); result.is_error()) - show_error(result.error(), "Opening"sv, LexicalPath { urls.first().path() }.basename()); + show_error(result.release_error(), "Opening"sv, LexicalPath { urls.first().path() }.basename()); } } diff --git a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp index 099d3179d7..9d97082a3b 100644 --- a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp +++ b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp @@ -27,9 +27,8 @@ bool KeyboardMapperWidget::request_close() return true; auto result = GUI::MessageBox::ask_about_unsaved_changes(window(), m_filename); if (result == GUI::MessageBox::ExecResult::Yes) { - ErrorOr error_or = save(); - if (error_or.is_error()) - show_error_to_user(error_or.error()); + if (auto error_or = save(); error_or.is_error()) + show_error_to_user(error_or.release_error()); if (!window()->is_modified()) return true; diff --git a/Userland/Applications/KeyboardMapper/main.cpp b/Userland/Applications/KeyboardMapper/main.cpp index 77ef321792..015e0270a2 100644 --- a/Userland/Applications/KeyboardMapper/main.cpp +++ b/Userland/Applications/KeyboardMapper/main.cpp @@ -54,16 +54,14 @@ ErrorOr serenity_main(Main::Arguments arguments) if (!path.has_value()) return; - ErrorOr error_or = keyboard_mapper_widget->load_map_from_file(path.value()); - if (error_or.is_error()) - keyboard_mapper_widget->show_error_to_user(error_or.error()); + if (auto error_or = keyboard_mapper_widget->load_map_from_file(path.value()); error_or.is_error()) + keyboard_mapper_widget->show_error_to_user(error_or.release_error()); }); auto save_action = GUI::CommonActions::make_save_action( [&](auto&) { - ErrorOr error_or = keyboard_mapper_widget->save(); - if (error_or.is_error()) - keyboard_mapper_widget->show_error_to_user(error_or.error()); + if (auto error_or = keyboard_mapper_widget->save(); error_or.is_error()) + keyboard_mapper_widget->show_error_to_user(error_or.release_error()); }); auto save_as_action = GUI::CommonActions::make_save_as_action([&](auto&) { @@ -72,9 +70,8 @@ ErrorOr serenity_main(Main::Arguments arguments) if (!save_path.has_value()) return; - ErrorOr error_or = keyboard_mapper_widget->save_to_file(save_path.value()); - if (error_or.is_error()) - keyboard_mapper_widget->show_error_to_user(error_or.error()); + if (auto error_or = keyboard_mapper_widget->save_to_file(save_path.value()); error_or.is_error()) + keyboard_mapper_widget->show_error_to_user(error_or.release_error()); }); auto quit_action = GUI::CommonActions::make_quit_action( diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 0132cc71d2..7cfd771a4c 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -1021,8 +1021,8 @@ ErrorOr> HackStudioWidget::create_debug_action() return; } - Debugger::the().set_child_setup_callback([this, ptm_res]() { - return m_terminal_wrapper->setup_slave_pseudoterminal(ptm_res.value()); + Debugger::the().set_child_setup_callback([this, ptm_res = ptm_res.release_value()]() { + return m_terminal_wrapper->setup_slave_pseudoterminal(ptm_res); }); m_debugger_thread = Threading::Thread::construct(Debugger::start_static); @@ -1789,7 +1789,7 @@ ErrorOr> HackStudioWidget::create_open_project_config auto maybe_error = Core::System::mkdir(LexicalPath::absolute_path(m_project->root_path(), parent_directory), 0755); if (maybe_error.is_error() && maybe_error.error().code() != EEXIST) - return maybe_error.error(); + return maybe_error.release_error(); auto file = TRY(Core::Stream::File::open(absolute_config_file_path, Core::Stream::OpenMode::Write)); TRY(file->write_entire_buffer( diff --git a/Userland/Libraries/LibCore/ConfigFile.cpp b/Userland/Libraries/LibCore/ConfigFile.cpp index e0f3d73423..f26f0a0722 100644 --- a/Userland/Libraries/LibCore/ConfigFile.cpp +++ b/Userland/Libraries/LibCore/ConfigFile.cpp @@ -47,7 +47,7 @@ ErrorOr> ConfigFile::open(DeprecatedString const& file // the same as if we had opened an empty file. This behavior is a little weird, but is required by // user code, which does not check the config file exists before opening. if (!(allow_altering == AllowWriting::No && maybe_file.error().code() == ENOENT)) - return maybe_file.error(); + return maybe_file.release_error(); } else { buffered_file = TRY(Stream::BufferedFile::create(maybe_file.release_value())); } diff --git a/Userland/Libraries/LibCore/File.cpp b/Userland/Libraries/LibCore/File.cpp index 5cf699c625..77a649fc33 100644 --- a/Userland/Libraries/LibCore/File.cpp +++ b/Userland/Libraries/LibCore/File.cpp @@ -531,7 +531,7 @@ ErrorOr File::copy_directory(DeprecatedString const& dst_ DeprecatedString::formatted("{}/{}", src_path, filename), RecursionMode::Allowed, link, AddDuplicateFileMarker::Yes, preserve_mode); if (result.is_error()) - return result.error(); + return result.release_error(); } auto my_umask = umask(0); diff --git a/Userland/Libraries/LibCrypto/ASN1/DER.h b/Userland/Libraries/LibCrypto/ASN1/DER.h index e899c34237..634a91ff0f 100644 --- a/Userland/Libraries/LibCrypto/ASN1/DER.h +++ b/Userland/Libraries/LibCrypto/ASN1/DER.h @@ -71,13 +71,13 @@ public: auto tag_or_error = peek(); if (tag_or_error.is_error()) { m_stack = move(previous_position); - return tag_or_error.error(); + return tag_or_error.release_error(); } auto length_or_error = read_length(); if (length_or_error.is_error()) { m_stack = move(previous_position); - return length_or_error.error(); + return length_or_error.release_error(); } auto length = length_or_error.value(); @@ -85,7 +85,7 @@ public: auto bytes_result = read_bytes(length); if (bytes_result.is_error()) { m_stack = move(previous_position); - return bytes_result.error(); + return bytes_result.release_error(); } m_current_tag.clear(); @@ -106,13 +106,13 @@ public: auto tag_or_error = peek(); if (tag_or_error.is_error()) { m_stack = move(previous_position); - return tag_or_error.error(); + return tag_or_error.release_error(); } auto length_or_error = read_length(); if (length_or_error.is_error()) { m_stack = move(previous_position); - return length_or_error.error(); + return length_or_error.release_error(); } auto tag = tag_or_error.value(); @@ -121,7 +121,7 @@ public: auto value_or_error = read_value(class_override.value_or(tag.class_), kind_override.value_or(tag.kind), length); if (value_or_error.is_error()) { m_stack = move(previous_position); - return value_or_error.error(); + return value_or_error.release_error(); } m_current_tag.clear(); @@ -146,7 +146,7 @@ private: ErrorOr with_type_check(ErrorOr&& value_or_error) { if (value_or_error.is_error()) - return value_or_error.error(); + return value_or_error.release_error(); if constexpr (IsSame && !IsSame) { return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type"); @@ -162,10 +162,7 @@ private: template ErrorOr read_value(Class klass, Kind kind, size_t length) { - auto data_or_error = read_bytes(length); - if (data_or_error.is_error()) - return data_or_error.error(); - auto data = data_or_error.value(); + auto data = TRY(read_bytes(length)); if (klass != Class::Universal) return with_type_check(data); diff --git a/Userland/Libraries/LibEDID/EDID.cpp b/Userland/Libraries/LibEDID/EDID.cpp index 566f828915..f89d82aea8 100644 --- a/Userland/Libraries/LibEDID/EDID.cpp +++ b/Userland/Libraries/LibEDID/EDID.cpp @@ -907,14 +907,14 @@ ErrorOr Parser::for_each_detailed_timing(Function Parser::for_each_short_video_descriptor(Function Parser::for_each_display_descriptor(Function Program::link(GPU::Device& device) if (linked_vertex_shader_or_error.is_error()) { m_link_status = false; m_info_log = linker.messages(); - return linked_vertex_shader_or_error.error(); + return linked_vertex_shader_or_error.release_error(); } m_linked_vertex_shader = linked_vertex_shader_or_error.release_value(); @@ -81,7 +81,7 @@ ErrorOr Program::link(GPU::Device& device) if (linked_fragment_shader_or_error.is_error()) { m_link_status = false; m_info_log = linker.messages(); - return linked_fragment_shader_or_error.error(); + return linked_fragment_shader_or_error.release_error(); } m_linked_fragment_shader = linked_fragment_shader_or_error.release_value(); diff --git a/Userland/Libraries/LibGL/Shaders/Shader.cpp b/Userland/Libraries/LibGL/Shaders/Shader.cpp index ebc77d86f3..7e2a1a82cb 100644 --- a/Userland/Libraries/LibGL/Shaders/Shader.cpp +++ b/Userland/Libraries/LibGL/Shaders/Shader.cpp @@ -33,7 +33,7 @@ ErrorOr Shader::compile() if (object_file_or_error.is_error()) { m_compile_status = false; m_info_log = compiler.messages(); - return object_file_or_error.error(); + return object_file_or_error.release_error(); } m_object_file = object_file_or_error.release_value(); diff --git a/Userland/Libraries/LibSQL/Heap.cpp b/Userland/Libraries/LibSQL/Heap.cpp index ff75f84f5f..6ad28a51d0 100644 --- a/Userland/Libraries/LibSQL/Heap.cpp +++ b/Userland/Libraries/LibSQL/Heap.cpp @@ -53,7 +53,7 @@ ErrorOr Heap::open() if (file_size > 0) { if (auto error_maybe = read_zero_block(); error_maybe.is_error()) { m_file = nullptr; - return error_maybe.error(); + return error_maybe.release_error(); } } else { initialize_zero_block(); diff --git a/Userland/Libraries/LibVideo/PlaybackManager.cpp b/Userland/Libraries/LibVideo/PlaybackManager.cpp index 296c78bfe6..b3953a01a0 100644 --- a/Userland/Libraries/LibVideo/PlaybackManager.cpp +++ b/Userland/Libraries/LibVideo/PlaybackManager.cpp @@ -85,7 +85,7 @@ void PlaybackManager::dispatch_fatal_error(Error error) // FIXME: For threading, this will have to use a pre-allocated event to send to the main loop // to be able to gracefully handle OOM. VERIFY(&m_main_loop == &Core::EventLoop::current()); - FatalPlaybackErrorEvent event { error }; + FatalPlaybackErrorEvent event { move(error) }; m_event_handler.dispatch_event(event); } diff --git a/Userland/Libraries/LibVideo/PlaybackManager.h b/Userland/Libraries/LibVideo/PlaybackManager.h index 39c42c09b1..99909f7c12 100644 --- a/Userland/Libraries/LibVideo/PlaybackManager.h +++ b/Userland/Libraries/LibVideo/PlaybackManager.h @@ -247,11 +247,11 @@ class FatalPlaybackErrorEvent : public Core::Event { public: explicit FatalPlaybackErrorEvent(Error error) : Core::Event(FatalPlaybackError) - , m_error(error) + , m_error(move(error)) { } virtual ~FatalPlaybackErrorEvent() = default; - Error error() { return m_error; } + Error const& error() { return m_error; } private: Error m_error; diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp index acba0370fb..7b50a85ea9 100644 --- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp @@ -172,7 +172,7 @@ void ResourceLoader::load(LoadRequest& request, Function execute_work_items(Vector const& items) if (auto result = destination_file->write(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.error(); + return result.release_error(); } item_done += bytes_read.size(); executed_work_bytes += bytes_read.size(); diff --git a/Userland/Utilities/headless-browser.cpp b/Userland/Utilities/headless-browser.cpp index fb0e2df08b..de0783c099 100644 --- a/Userland/Utilities/headless-browser.cpp +++ b/Userland/Utilities/headless-browser.cpp @@ -238,8 +238,8 @@ public: void request_file(Web::FileRequest request) override { - auto const file = Core::System::open(request.path(), O_RDONLY); - request.on_file_request_finish(file); + auto file = Core::System::open(request.path(), O_RDONLY); + request.on_file_request_finish(move(file)); } private: diff --git a/Userland/Utilities/keymap.cpp b/Userland/Utilities/keymap.cpp index 25629ad1a7..3b03cd7ede 100644 --- a/Userland/Utilities/keymap.cpp +++ b/Userland/Utilities/keymap.cpp @@ -65,10 +65,9 @@ ErrorOr serenity_main(Main::Arguments arguments) // Verify that all specified keymaps are loadable for (auto& keymap_name : mappings_vector) { - auto keymap = Keyboard::CharacterMap::load_from_file(keymap_name); - if (keymap.is_error()) { + if (auto keymap = Keyboard::CharacterMap::load_from_file(keymap_name); keymap.is_error()) { warnln("Cannot load keymap {}: {}({})", keymap_name, keymap.error().string_literal(), keymap.error().code()); - return keymap.error(); + return keymap.release_error(); } } diff --git a/Userland/Utilities/ln.cpp b/Userland/Utilities/ln.cpp index a113857974..8d84257297 100644 --- a/Userland/Utilities/ln.cpp +++ b/Userland/Utilities/ln.cpp @@ -33,7 +33,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto stat = Core::System::lstat(path); if (stat.is_error() && stat.error().code() != ENOENT) - return stat.error(); + return stat.release_error(); if (!stat.is_error() && S_ISDIR(stat.value().st_mode)) { // The target path is a directory, so we presumably want / as the effective path. diff --git a/Userland/Utilities/rm.cpp b/Userland/Utilities/rm.cpp index 01f7b2be85..15670ec53d 100644 --- a/Userland/Utilities/rm.cpp +++ b/Userland/Utilities/rm.cpp @@ -46,7 +46,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto result = Core::File::remove(path, recursive ? Core::File::RecursionMode::Allowed : Core::File::RecursionMode::Disallowed); if (result.is_error()) { - auto error = result.error(); + auto error = result.release_error(); if (force && error.is_errno() && error.code() == ENOENT) continue; diff --git a/Userland/Utilities/tail.cpp b/Userland/Utilities/tail.cpp index c4a7f1e34b..96b5fe0234 100644 --- a/Userland/Utilities/tail.cpp +++ b/Userland/Utilities/tail.cpp @@ -110,7 +110,7 @@ ErrorOr serenity_main(Main::Arguments arguments) if (event.type == Core::FileWatcherEvent::Type::ContentModified) { auto buffer_or_error = f->read_until_eof(); if (buffer_or_error.is_error()) { - auto error = buffer_or_error.error(); + auto error = buffer_or_error.release_error(); warnln(error.string_literal()); event_loop.quit(error.code()); return; @@ -120,7 +120,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto potential_error = f->seek(0, SeekMode::FromEndPosition); if (potential_error.is_error()) { - auto error = potential_error.error(); + auto error = potential_error.release_error(); warnln(error.string_literal()); event_loop.quit(error.code()); return; diff --git a/Userland/Utilities/tar.cpp b/Userland/Utilities/tar.cpp index eb4e804552..75fa1ff0fe 100644 --- a/Userland/Utilities/tar.cpp +++ b/Userland/Utilities/tar.cpp @@ -181,7 +181,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto result_or_error = Core::System::mkdir(absolute_path, header_mode); if (result_or_error.is_error() && result_or_error.error().code() != EEXIST) - return result_or_error.error(); + return result_or_error.release_error(); break; } default: