From 6c66311ade7dcfdfed012129bc054e6c858119f1 Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Mon, 3 Jan 2022 03:25:29 -0800 Subject: [PATCH] Kernel: Use MUST + Vector::try_empend instead of Vector::empend In preparation for making Vector::empend unavailable during compilation of the Kernel. --- Kernel/FileSystem/Ext2FileSystem.cpp | 6 +++--- Kernel/Firmware/MultiProcessor/Parser.cpp | 4 ++-- Kernel/Interrupts/InterruptManagement.cpp | 4 ++-- Kernel/Storage/Partition/EBRPartitionTable.cpp | 2 +- Kernel/Storage/Partition/MBRPartitionTable.cpp | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index ca25978cf3..47a9b8b681 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -1174,7 +1174,7 @@ ErrorOr Ext2FSInode::add_child(Inode& child, StringView name, mode_t mode) TRY(child.increment_link_count()); - entries.empend(name, child.index(), to_ext2_file_type(mode)); + TRY(entries.try_empend(name, child.index(), to_ext2_file_type(mode))); TRY(write_directory(entries)); TRY(populate_lookup_cache()); @@ -1470,8 +1470,8 @@ ErrorOr> Ext2FS::create_directory(Ext2FSInode& parent_inode dbgln_if(EXT2_DEBUG, "Ext2FS: create_directory: created new directory named '{} with inode {}", name, inode->index()); Vector entries; - entries.empend(".", inode->index(), static_cast(EXT2_FT_DIR)); - entries.empend("..", parent_inode.index(), static_cast(EXT2_FT_DIR)); + TRY(entries.try_empend(".", inode->index(), static_cast(EXT2_FT_DIR))); + TRY(entries.try_empend("..", parent_inode.index(), static_cast(EXT2_FT_DIR))); TRY(static_cast(*inode).write_directory(entries)); TRY(parent_inode.increment_link_count()); diff --git a/Kernel/Firmware/MultiProcessor/Parser.cpp b/Kernel/Firmware/MultiProcessor/Parser.cpp index d315105628..8cca971e3f 100644 --- a/Kernel/Firmware/MultiProcessor/Parser.cpp +++ b/Kernel/Firmware/MultiProcessor/Parser.cpp @@ -119,13 +119,13 @@ UNMAP_AFTER_INIT Vector MultiProcessorParser::get_ entry.source_bus_irq, entry.destination_ioapic_id, entry.destination_ioapic_intin_pin); - overrides.empend( + MUST(overrides.try_empend( entry.source_bus_id, entry.polarity, entry.trigger_mode, entry.source_bus_irq, entry.destination_ioapic_id, - entry.destination_ioapic_intin_pin); + entry.destination_ioapic_intin_pin)); } } } diff --git a/Kernel/Interrupts/InterruptManagement.cpp b/Kernel/Interrupts/InterruptManagement.cpp index 3e4530b7bd..8da1f98910 100644 --- a/Kernel/Interrupts/InterruptManagement.cpp +++ b/Kernel/Interrupts/InterruptManagement.cpp @@ -214,11 +214,11 @@ UNMAP_AFTER_INIT void InterruptManagement::locate_apic_data() ByteReader::load(reinterpret_cast(&interrupt_override_entry->global_system_interrupt), global_system_interrupt); u16 flags = 0; ByteReader::load(reinterpret_cast(&interrupt_override_entry->flags), flags); - m_isa_interrupt_overrides.empend( + MUST(m_isa_interrupt_overrides.try_empend( interrupt_override_entry->bus, interrupt_override_entry->source, global_system_interrupt, - flags); + flags)); dbgln("Interrupts: Overriding INT {:#x} with GSI {}, for bus {:#x}", interrupt_override_entry->source, diff --git a/Kernel/Storage/Partition/EBRPartitionTable.cpp b/Kernel/Storage/Partition/EBRPartitionTable.cpp index 2cf0c2735f..1dc8c016cf 100644 --- a/Kernel/Storage/Partition/EBRPartitionTable.cpp +++ b/Kernel/Storage/Partition/EBRPartitionTable.cpp @@ -64,7 +64,7 @@ EBRPartitionTable::EBRPartitionTable(const StorageDevice& device) if (entry.offset == 0x00) { continue; } - m_partitions.empend(entry.offset, (entry.offset + entry.length), entry.type); + MUST(m_partitions.try_empend(entry.offset, (entry.offset + entry.length), entry.type)); } } diff --git a/Kernel/Storage/Partition/MBRPartitionTable.cpp b/Kernel/Storage/Partition/MBRPartitionTable.cpp index 49cb827345..cd773f3c05 100644 --- a/Kernel/Storage/Partition/MBRPartitionTable.cpp +++ b/Kernel/Storage/Partition/MBRPartitionTable.cpp @@ -60,7 +60,7 @@ MBRPartitionTable::MBRPartitionTable(const StorageDevice& device, u32 start_lba) if (entry.offset == 0x00) { continue; } - m_partitions.empend(entry.offset, (entry.offset + entry.length), entry.type); + MUST(m_partitions.try_empend(entry.offset, (entry.offset + entry.length), entry.type)); } m_valid = true; } @@ -79,7 +79,7 @@ MBRPartitionTable::MBRPartitionTable(const StorageDevice& device) if (entry.offset == 0x00) { continue; } - m_partitions.empend(entry.offset, (entry.offset + entry.length), entry.type); + MUST(m_partitions.try_empend(entry.offset, (entry.offset + entry.length), entry.type)); } m_valid = true; }