mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
Everywhere: Remove needless copies of Error / ErrorOr instances
Either take the underlying objects with release_* methods or move() the instances around.
This commit is contained in:
parent
52687814ea
commit
4a916cd379
Notes:
sideshowbarker
2024-07-17 03:03:15 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/4a916cd379 Pull-request: https://github.com/SerenityOS/serenity/pull/17399 Reviewed-by: https://github.com/linusg
@ -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());
|
||||
|
@ -137,7 +137,7 @@ ErrorOr<void> Access::add_host_controller_and_scan_for_devices(NonnullOwnPtr<Hos
|
||||
m_host_controllers.get(domain_number).value()->enumerate_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());
|
||||
|
@ -403,7 +403,7 @@ ErrorOr<size_t> 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);
|
||||
|
@ -22,7 +22,7 @@ PerformanceEventBuffer::PerformanceEventBuffer(NonnullOwnPtr<KBuffer> buffer)
|
||||
{
|
||||
}
|
||||
|
||||
NEVER_INLINE ErrorOr<void> PerformanceEventBuffer::append(int type, FlatPtr arg1, FlatPtr arg2, StringView arg3, Thread* current_thread, FlatPtr arg4, u64 arg5, ErrorOr<FlatPtr> arg6)
|
||||
NEVER_INLINE ErrorOr<void> PerformanceEventBuffer::append(int type, FlatPtr arg1, FlatPtr arg2, StringView arg3, Thread* current_thread, FlatPtr arg4, u64 arg5, ErrorOr<FlatPtr> 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<FlatPtr, PerformanceEvent::max_stack_frame_count> raw_backtrace(Fl
|
||||
}
|
||||
|
||||
ErrorOr<void> 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<FlatPtr> arg6)
|
||||
int type, u32 lost_samples, FlatPtr arg1, FlatPtr arg2, StringView arg3, FlatPtr arg4, u64 arg5, ErrorOr<FlatPtr> const& arg6)
|
||||
{
|
||||
return append_with_ip_and_bp(pid, tid, regs.ip(), regs.bp(), type, lost_samples, arg1, arg2, arg3, arg4, arg5, arg6);
|
||||
}
|
||||
|
||||
ErrorOr<void> 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<FlatPtr> arg6)
|
||||
FlatPtr ip, FlatPtr bp, int type, u32 lost_samples, FlatPtr arg1, FlatPtr arg2, StringView arg3, FlatPtr arg4, u64 arg5, ErrorOr<FlatPtr> const& arg6)
|
||||
{
|
||||
if (count() >= capacity())
|
||||
return ENOBUFS;
|
||||
|
@ -110,11 +110,11 @@ class PerformanceEventBuffer {
|
||||
public:
|
||||
static OwnPtr<PerformanceEventBuffer> try_create_with_size(size_t buffer_size);
|
||||
|
||||
ErrorOr<void> append(int type, FlatPtr arg1, FlatPtr arg2, StringView arg3, Thread* current_thread = Thread::current(), FlatPtr arg4 = 0, u64 arg5 = 0, ErrorOr<FlatPtr> arg6 = 0);
|
||||
ErrorOr<void> append(int type, FlatPtr arg1, FlatPtr arg2, StringView arg3, Thread* current_thread = Thread::current(), FlatPtr arg4 = 0, u64 arg5 = 0, ErrorOr<FlatPtr> const& arg6 = 0);
|
||||
ErrorOr<void> 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<FlatPtr> arg6 = 0);
|
||||
int type, u32 lost_samples, FlatPtr arg1, FlatPtr arg2, StringView arg3, FlatPtr arg4 = 0, u64 arg5 = {}, ErrorOr<FlatPtr> const& arg6 = 0);
|
||||
ErrorOr<void> 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<FlatPtr> arg6 = 0);
|
||||
int type, u32 lost_samples, FlatPtr arg1, FlatPtr arg2, StringView arg3, FlatPtr arg4 = 0, u64 arg5 = {}, ErrorOr<FlatPtr> const& arg6 = 0);
|
||||
|
||||
void clear()
|
||||
{
|
||||
|
@ -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<FlatPtr> result)
|
||||
static void add_read_event(Thread& thread, int fd, size_t size, OpenFileDescription const& file_description, u64 start_timestamp, ErrorOr<FlatPtr> const& result)
|
||||
{
|
||||
if (thread.is_profiling_suppressed())
|
||||
return;
|
||||
|
@ -74,7 +74,7 @@ ErrorOr<FlatPtr> Process::sys$readv(int fd, Userspace<const struct iovec*> iov,
|
||||
ErrorOr<FlatPtr> Process::sys$read(int fd, Userspace<u8*> 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;
|
||||
|
@ -101,9 +101,9 @@ ErrorOr<void> 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<void> 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<void> 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<void> 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<SelectionUndoCommand>(*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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<void> 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;
|
||||
|
@ -54,16 +54,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
if (!path.has_value())
|
||||
return;
|
||||
|
||||
ErrorOr<void> 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<void> 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<int> serenity_main(Main::Arguments arguments)
|
||||
if (!save_path.has_value())
|
||||
return;
|
||||
|
||||
ErrorOr<void> 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(
|
||||
|
@ -1021,8 +1021,8 @@ ErrorOr<NonnullRefPtr<GUI::Action>> 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<NonnullRefPtr<GUI::Action>> 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(
|
||||
|
@ -47,7 +47,7 @@ ErrorOr<NonnullRefPtr<ConfigFile>> 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()));
|
||||
}
|
||||
|
@ -531,7 +531,7 @@ ErrorOr<void, File::CopyError> 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);
|
||||
|
@ -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<ValueType>(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<ValueType> with_type_check(ErrorOr<DecodedType>&& value_or_error)
|
||||
{
|
||||
if (value_or_error.is_error())
|
||||
return value_or_error.error();
|
||||
return value_or_error.release_error();
|
||||
|
||||
if constexpr (IsSame<ValueType, bool> && !IsSame<DecodedType, bool>) {
|
||||
return Error::from_string_literal("ASN1::Decoder: Trying to decode a boolean from a non-boolean type");
|
||||
@ -162,10 +162,7 @@ private:
|
||||
template<typename ValueType>
|
||||
ErrorOr<ValueType> 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<ValueType>(data);
|
||||
|
@ -907,14 +907,14 @@ ErrorOr<IterationDecision> Parser::for_each_detailed_timing(Function<IterationDe
|
||||
});
|
||||
if (result.is_error()) {
|
||||
dbgln("Failed to iterate DTDs in CEA861 extension block: {}", result.error());
|
||||
extension_error = result.error();
|
||||
extension_error = result.release_error();
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
|
||||
return result.value();
|
||||
}));
|
||||
if (extension_error.has_value())
|
||||
return extension_error.value();
|
||||
return extension_error.release_value();
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -948,7 +948,7 @@ ErrorOr<IterationDecision> Parser::for_each_short_video_descriptor(Function<Iter
|
||||
return callback(block_id, is_native, vic);
|
||||
});
|
||||
if (result.is_error()) {
|
||||
extension_error = result.error();
|
||||
extension_error = result.release_error();
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
return result.value();
|
||||
@ -985,14 +985,14 @@ ErrorOr<IterationDecision> Parser::for_each_display_descriptor(Function<Iteratio
|
||||
});
|
||||
if (result.is_error()) {
|
||||
dbgln("Failed to iterate display descriptors in CEA861 extension block: {}", result.error());
|
||||
extension_error = result.error();
|
||||
extension_error = result.release_error();
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
|
||||
return result.value();
|
||||
}));
|
||||
if (extension_error.has_value())
|
||||
return extension_error.value();
|
||||
return extension_error.release_value();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ ErrorOr<void> 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<void> 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();
|
||||
|
@ -33,7 +33,7 @@ ErrorOr<void> 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();
|
||||
|
@ -53,7 +53,7 @@ ErrorOr<void> 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();
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -172,7 +172,7 @@ void ResourceLoader::load(LoadRequest& request, Function<void(ReadonlyBytes, Has
|
||||
dbgln("ResourceLoader: Finished load of: \"{}\", Duration: {}ms", url_for_logging, load_time_ms);
|
||||
};
|
||||
|
||||
auto const log_failure = [url_for_logging, id](auto const& request, auto const error_message) {
|
||||
auto const log_failure = [url_for_logging, id](auto const& request, auto const& error_message) {
|
||||
auto load_time_ms = request.load_time().to_milliseconds();
|
||||
emit_signpost(DeprecatedString::formatted("Failed load: {}", url_for_logging), id);
|
||||
dbgln("ResourceLoader: Failed load of: \"{}\", \033[31;1mError: {}\033[0m, Duration: {}ms", url_for_logging, error_message, load_time_ms);
|
||||
|
@ -243,7 +243,7 @@ ErrorOr<int> execute_work_items(Vector<WorkItem> 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();
|
||||
|
@ -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:
|
||||
|
@ -65,10 +65,9 @@ ErrorOr<int> 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ ErrorOr<int> 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 <path>/<filename> as the effective path.
|
||||
|
@ -46,7 +46,7 @@ ErrorOr<int> 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;
|
||||
|
@ -110,7 +110,7 @@ ErrorOr<int> 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<int> 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;
|
||||
|
@ -181,7 +181,7 @@ ErrorOr<int> 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:
|
||||
|
Loading…
Reference in New Issue
Block a user