Kernel: Use MUST + Vector::try_append instead of Vector::append

In preparation for making Vector::append unavailable during
compilation of the Kernel.
This commit is contained in:
Brian Gianforcaro 2022-01-03 03:20:39 -08:00 committed by Andreas Kling
parent 8bcce82887
commit 24066ba5ef
5 changed files with 8 additions and 8 deletions

View file

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

View file

@ -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):

View file

@ -170,7 +170,7 @@ ErrorOr<void> FramebufferDevice::create_framebuffer()
NonnullRefPtrVector<Memory::PhysicalPage> 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()));

View file

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

View file

@ -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<StorageDevice&>(device), (partition_index + (16 * device_index)), partition_metadata.value());
partitions.append(disk_partition);
const_cast<StorageDevice&>(device).m_partitions.append(disk_partition);
MUST(partitions.try_append(disk_partition));
MUST(const_cast<StorageDevice&>(device).m_partitions.try_append(disk_partition));
}
device_index++;
}