Kernel: Use MUST + Vector::try_empend instead of Vector::empend

In preparation for making Vector::empend unavailable during
compilation of the Kernel.
This commit is contained in:
Brian Gianforcaro 2022-01-03 03:25:29 -08:00 committed by Andreas Kling
parent 24066ba5ef
commit 6c66311ade
5 changed files with 10 additions and 10 deletions

View file

@ -1174,7 +1174,7 @@ ErrorOr<void> 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<NonnullRefPtr<Inode>> Ext2FS::create_directory(Ext2FSInode& parent_inode
dbgln_if(EXT2_DEBUG, "Ext2FS: create_directory: created new directory named '{} with inode {}", name, inode->index());
Vector<Ext2FSDirectoryEntry> entries;
entries.empend(".", inode->index(), static_cast<u8>(EXT2_FT_DIR));
entries.empend("..", parent_inode.index(), static_cast<u8>(EXT2_FT_DIR));
TRY(entries.try_empend(".", inode->index(), static_cast<u8>(EXT2_FT_DIR)));
TRY(entries.try_empend("..", parent_inode.index(), static_cast<u8>(EXT2_FT_DIR)));
TRY(static_cast<Ext2FSInode&>(*inode).write_directory(entries));
TRY(parent_inode.increment_link_count());

View file

@ -119,13 +119,13 @@ UNMAP_AFTER_INIT Vector<PCIInterruptOverrideMetadata> 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));
}
}
}

View file

@ -214,11 +214,11 @@ UNMAP_AFTER_INIT void InterruptManagement::locate_apic_data()
ByteReader::load<u32>(reinterpret_cast<u8 const*>(&interrupt_override_entry->global_system_interrupt), global_system_interrupt);
u16 flags = 0;
ByteReader::load<u16>(reinterpret_cast<u8 const*>(&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,

View file

@ -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));
}
}

View file

@ -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;
}