From 24066ba5efd3d7f1d233d629ccca33f734786ef6 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Mon, 3 Jan 2022 03:20:39 -0800 Subject: [PATCH] Kernel: Use MUST + Vector::try_append instead of Vector::append In preparation for making Vector::append unavailable during compilation of the Kernel. --- Kernel/FileSystem/Ext2FileSystem.cpp | 4 ++-- Kernel/Firmware/MultiProcessor/Parser.cpp | 4 ++-- Kernel/Graphics/VirtIOGPU/FramebufferDevice.cpp | 2 +- Kernel/Net/NetworkTask.cpp | 2 +- Kernel/Storage/StorageManagement.cpp | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index 08b9924860..ca25978cf3 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -709,14 +709,14 @@ void Ext2FS::flush_writes() // to not exist, we remember the fact that it doesn't exist by caching a nullptr. // This seems like a reasonable time to uncache ideas about unknown inodes, so do that. if (!it.value) { - unused_inodes.append(it.key); + MUST(unused_inodes.try_append(it.key)); continue; } if (it.value->ref_count() != 1) continue; if (it.value->has_watchers()) continue; - unused_inodes.append(it.key); + MUST(unused_inodes.try_append(it.key)); } for (auto index : unused_inodes) uncache_inode(index); diff --git a/Kernel/Firmware/MultiProcessor/Parser.cpp b/Kernel/Firmware/MultiProcessor/Parser.cpp index a7866e8261..d315105628 100644 --- a/Kernel/Firmware/MultiProcessor/Parser.cpp +++ b/Kernel/Firmware/MultiProcessor/Parser.cpp @@ -55,14 +55,14 @@ UNMAP_AFTER_INIT void MultiProcessorParser::parse_configuration_table() entry = (MultiProcessor::EntryHeader*)(FlatPtr)entry + sizeof(MultiProcessor::ProcessorEntry); break; case ((u8)MultiProcessor::ConfigurationTableEntryType::Bus): - m_bus_entries.append(*(const MultiProcessor::BusEntry*)entry); + MUST(m_bus_entries.try_append(*(const MultiProcessor::BusEntry*)entry)); entry = (MultiProcessor::EntryHeader*)(FlatPtr)entry + sizeof(MultiProcessor::BusEntry); break; case ((u8)MultiProcessor::ConfigurationTableEntryType::IOAPIC): entry = (MultiProcessor::EntryHeader*)(FlatPtr)entry + sizeof(MultiProcessor::IOAPICEntry); break; case ((u8)MultiProcessor::ConfigurationTableEntryType::IO_Interrupt_Assignment): - m_io_interrupt_assignment_entries.append(*(const MultiProcessor::IOInterruptAssignmentEntry*)entry); + MUST(m_io_interrupt_assignment_entries.try_append(*(const MultiProcessor::IOInterruptAssignmentEntry*)entry)); entry = (MultiProcessor::EntryHeader*)(FlatPtr)entry + sizeof(MultiProcessor::IOInterruptAssignmentEntry); break; case ((u8)MultiProcessor::ConfigurationTableEntryType::Local_Interrupt_Assignment): diff --git a/Kernel/Graphics/VirtIOGPU/FramebufferDevice.cpp b/Kernel/Graphics/VirtIOGPU/FramebufferDevice.cpp index 3aa32bbd65..cf2bdff614 100644 --- a/Kernel/Graphics/VirtIOGPU/FramebufferDevice.cpp +++ b/Kernel/Graphics/VirtIOGPU/FramebufferDevice.cpp @@ -170,7 +170,7 @@ ErrorOr FramebufferDevice::create_framebuffer() NonnullRefPtrVector pages; for (auto i = 0u; i < num_needed_pages; ++i) { - pages.append(write_sink_page); + TRY(pages.try_append(write_sink_page)); } m_framebuffer_sink_vmobject = TRY(Memory::AnonymousVMObject::try_create_with_physical_pages(pages.span())); diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp index ffa9dc25da..2b1dbcf3ca 100644 --- a/Kernel/Net/NetworkTask.cpp +++ b/Kernel/Net/NetworkTask.cpp @@ -319,7 +319,7 @@ void flush_delayed_tcp_acks() for (auto& socket : *delayed_ack_sockets) { MutexLocker locker(socket->mutex()); if (socket->should_delay_next_ack()) { - remaining_sockets.append(socket); + MUST(remaining_sockets.try_append(socket)); continue; } [[maybe_unused]] auto result = socket->send_ack(); diff --git a/Kernel/Storage/StorageManagement.cpp b/Kernel/Storage/StorageManagement.cpp index a00b2f2731..577a949b08 100644 --- a/Kernel/Storage/StorageManagement.cpp +++ b/Kernel/Storage/StorageManagement.cpp @@ -125,8 +125,8 @@ UNMAP_AFTER_INIT void StorageManagement::enumerate_disk_partitions() const continue; // FIXME: Try to not hardcode a maximum of 16 partitions per drive! auto disk_partition = DiskPartition::create(const_cast(device), (partition_index + (16 * device_index)), partition_metadata.value()); - partitions.append(disk_partition); - const_cast(device).m_partitions.append(disk_partition); + MUST(partitions.try_append(disk_partition)); + MUST(const_cast(device).m_partitions.try_append(disk_partition)); } device_index++; }