mirror of
https://github.com/SerenityOS/serenity
synced 2026-04-25 17:15:42 +02:00
AK+Kernel+Userland: Don't allow Vector::append() in the kernel
This makes it not as easy to forgot to handle OOMs in the kernel. This commit replaces most usages of this function with `try_append(...).release_value_but_fixme_should_propagate_errors()`. But in some cases, using the `TRY` macro or `unchecked_append()` is already possible. In places where allocations should not fail or an OOM would be fatal anyways, `MUST(try_append(...))` should be used explicitly.
This commit is contained in:
@@ -63,7 +63,7 @@ Vector<StringView> StringView::split_view(StringView separator, SplitBehavior sp
|
||||
{
|
||||
Vector<StringView> parts;
|
||||
for_each_split_view(separator, split_behavior, [&](StringView view) {
|
||||
parts.append(view);
|
||||
parts.try_append(view).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
return parts;
|
||||
}
|
||||
|
||||
@@ -271,8 +271,6 @@ public:
|
||||
MUST(try_extend(other));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
ALWAYS_INLINE void append(T&& value)
|
||||
{
|
||||
if constexpr (contains_reference)
|
||||
@@ -287,7 +285,6 @@ public:
|
||||
MUST(try_append(T(value)));
|
||||
}
|
||||
|
||||
#ifndef KERNEL
|
||||
void append(StorageType const* values, size_t count)
|
||||
{
|
||||
MUST(try_append(values, count));
|
||||
|
||||
@@ -36,7 +36,7 @@ void InterruptManagement::initialize()
|
||||
|
||||
void InterruptManagement::add_recipe(DeviceTree::DeviceRecipe<NonnullLockRefPtr<IRQController>> recipe)
|
||||
{
|
||||
s_recipes->append(move(recipe));
|
||||
MUST(s_recipes->try_append(move(recipe)));
|
||||
}
|
||||
|
||||
void InterruptManagement::find_controllers()
|
||||
@@ -48,7 +48,7 @@ void InterruptManagement::find_controllers()
|
||||
continue;
|
||||
}
|
||||
|
||||
m_interrupt_controllers.append(device_or_error.release_value());
|
||||
MUST(m_interrupt_controllers.try_append(device_or_error.release_value()));
|
||||
}
|
||||
|
||||
if (m_interrupt_controllers.is_empty())
|
||||
|
||||
@@ -38,7 +38,7 @@ void InterruptManagement::initialize()
|
||||
|
||||
void InterruptManagement::add_recipe(DeviceTree::DeviceRecipe<NonnullLockRefPtr<IRQController>> recipe)
|
||||
{
|
||||
s_recipes->append(move(recipe));
|
||||
MUST(s_recipes->try_append(move(recipe)));
|
||||
}
|
||||
|
||||
void InterruptManagement::find_controllers()
|
||||
@@ -50,7 +50,7 @@ void InterruptManagement::find_controllers()
|
||||
continue;
|
||||
}
|
||||
|
||||
m_interrupt_controllers.append(device_or_error.release_value());
|
||||
MUST(m_interrupt_controllers.try_append(device_or_error.release_value()));
|
||||
}
|
||||
|
||||
if (m_interrupt_controllers.is_empty())
|
||||
|
||||
@@ -33,7 +33,7 @@ Optional<PhysicalAddress> find_rsdp_in_ia_pc_specific_memory_locations()
|
||||
if (!(memory_range.type == Memory::PhysicalMemoryRangeType::ACPI_NVS || memory_range.type == Memory::PhysicalMemoryRangeType::ACPI_Reclaimable))
|
||||
return IterationDecision::Continue;
|
||||
|
||||
potential_ranges.append(memory_range);
|
||||
potential_ranges.try_append(memory_range).release_value_but_fixme_should_propagate_errors();
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
|
||||
|
||||
@@ -137,7 +137,7 @@ UNMAP_AFTER_INIT void InterruptManagement::switch_to_pic_mode()
|
||||
VERIFY(m_interrupt_controllers.is_empty());
|
||||
dmesgln("Interrupts: Switch to Legacy PIC mode");
|
||||
InterruptDisabler disabler;
|
||||
m_interrupt_controllers.append(adopt_lock_ref(*new PIC()));
|
||||
m_interrupt_controllers.try_append(adopt_lock_ref(*new PIC())).release_value_but_fixme_should_propagate_errors();
|
||||
SpuriousInterruptHandler::initialize(7);
|
||||
SpuriousInterruptHandler::initialize(15);
|
||||
dbgln("Interrupts: Detected {}", m_interrupt_controllers[0]->model());
|
||||
@@ -186,7 +186,7 @@ UNMAP_AFTER_INIT void InterruptManagement::locate_apic_data()
|
||||
auto madt = Memory::map_typed<ACPI::Structures::MADT>(m_madt_physical_address.value()).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
if (madt->flags & PCAT_COMPAT_FLAG)
|
||||
m_interrupt_controllers.append(adopt_lock_ref(*new PIC()));
|
||||
m_interrupt_controllers.try_append(adopt_lock_ref(*new PIC())).release_value_but_fixme_should_propagate_errors();
|
||||
size_t entry_index = 0;
|
||||
size_t entries_length = madt->h.length - sizeof(ACPI::Structures::MADT);
|
||||
auto* madt_entry = madt->entries;
|
||||
@@ -195,7 +195,7 @@ UNMAP_AFTER_INIT void InterruptManagement::locate_apic_data()
|
||||
if (madt_entry->type == (u8)ACPI::Structures::MADTEntryType::IOAPIC) {
|
||||
auto* ioapic_entry = (const ACPI::Structures::MADTEntries::IOAPIC*)madt_entry;
|
||||
dbgln("IOAPIC found @ MADT entry {}, MMIO Registers @ {}", entry_index, PhysicalAddress(ioapic_entry->ioapic_address));
|
||||
m_interrupt_controllers.append(adopt_lock_ref(*new IOAPIC(PhysicalAddress(ioapic_entry->ioapic_address), ioapic_entry->gsi_base)));
|
||||
m_interrupt_controllers.try_append(adopt_lock_ref(*new IOAPIC(PhysicalAddress(ioapic_entry->ioapic_address), ioapic_entry->gsi_base))).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
if (madt_entry->type == (u8)ACPI::Structures::MADTEntryType::InterruptSourceOverride) {
|
||||
auto* interrupt_override_entry = (const ACPI::Structures::MADTEntries::InterruptSourceOverride*)madt_entry;
|
||||
|
||||
@@ -339,7 +339,7 @@ Vector<unsigned> HPET::capable_interrupt_numbers(HPETComparator const& comparato
|
||||
u32 interrupt_bitfield = comparator_registers.interrupt_routing;
|
||||
for (size_t index = 0; index < 32; index++) {
|
||||
if (interrupt_bitfield & 1)
|
||||
capable_interrupts.append(index);
|
||||
capable_interrupts.try_append(index).release_value_but_fixme_should_propagate_errors();
|
||||
interrupt_bitfield >>= 1;
|
||||
}
|
||||
return capable_interrupts;
|
||||
@@ -353,7 +353,7 @@ Vector<unsigned> HPET::capable_interrupt_numbers(u8 comparator_number)
|
||||
u32 interrupt_bitfield = comparator_registers.interrupt_routing;
|
||||
for (size_t index = 0; index < 32; index++) {
|
||||
if (interrupt_bitfield & 1)
|
||||
capable_interrupts.append(index);
|
||||
capable_interrupts.try_append(index).release_value_but_fixme_should_propagate_errors();
|
||||
interrupt_bitfield >>= 1;
|
||||
}
|
||||
return capable_interrupts;
|
||||
@@ -454,8 +454,8 @@ UNMAP_AFTER_INIT HPET::HPET(PhysicalAddress acpi_hpet)
|
||||
if (regs.capabilities.attributes & (u32)HPETFlags::Attributes::LegacyReplacementRouteCapable)
|
||||
regs.configuration.low = regs.configuration.low | (u32)HPETFlags::Configuration::LegacyReplacementRoute;
|
||||
|
||||
m_comparators.append(HPETComparator::create(0, 0, is_periodic_capable(0), is_64bit_capable(0)));
|
||||
m_comparators.append(HPETComparator::create(1, 8, is_periodic_capable(1), is_64bit_capable(1)));
|
||||
m_comparators.try_append(HPETComparator::create(0, 0, is_periodic_capable(0), is_64bit_capable(0))).release_value_but_fixme_should_propagate_errors();
|
||||
m_comparators.try_append(HPETComparator::create(1, 8, is_periodic_capable(1), is_64bit_capable(1))).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
global_enable();
|
||||
}
|
||||
|
||||
@@ -315,7 +315,7 @@ Vector<NonnullOwnPtr<KString>> CommandLine::userspace_init_args() const
|
||||
if (!init_args.is_empty())
|
||||
MUST(args.try_prepend(MUST(KString::try_create(userspace_init()))));
|
||||
for (auto& init_arg : init_args)
|
||||
args.append(MUST(KString::try_create(init_arg)));
|
||||
MUST(args.try_append(MUST(KString::try_create(init_arg))));
|
||||
return args;
|
||||
}
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ ErrorOr<void> Access::add_host_controller_and_scan_for_devices(NonnullOwnPtr<Hos
|
||||
dmesgln("Failed during PCI Access::rescan_hardware due to {}", device_identifier_or_error.error());
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
m_device_identifiers.append(device_identifier_or_error.release_value());
|
||||
m_device_identifiers.try_append(device_identifier_or_error.release_value()).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
return {};
|
||||
}
|
||||
@@ -208,7 +208,7 @@ UNMAP_AFTER_INIT void Access::rescan_hardware()
|
||||
dmesgln("Failed during PCI Access::rescan_hardware due to {}", device_identifier_or_error.error());
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
m_device_identifiers.append(device_identifier_or_error.release_value());
|
||||
m_device_identifiers.try_append(device_identifier_or_error.release_value()).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ UNMAP_AFTER_INIT Vector<Capability> HostController::get_capabilities_for_functio
|
||||
u8 capability_id = capability_header & 0xff;
|
||||
|
||||
// FIXME: Don't attach a PCI address to a capability object
|
||||
capabilities.append({ Address(domain_number(), bus.value(), device.value(), function.value()), capability_id, capability_pointer });
|
||||
capabilities.try_append({ Address(domain_number(), bus.value(), device.value(), function.value()), capability_id, capability_pointer }).release_value_but_fixme_should_propagate_errors();
|
||||
capability_pointer = capability_header >> 8;
|
||||
}
|
||||
return capabilities;
|
||||
|
||||
@@ -131,7 +131,7 @@ ErrorOr<void> PCIeTransportLink::locate_configurations_and_resources(Badge<VirtI
|
||||
else if (config.cfg_type == ConfigurationType::Notify)
|
||||
m_notify_multiplier = capability.read32(0x10);
|
||||
|
||||
m_configs.append(config);
|
||||
TRY(m_configs.try_append(config));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ void FUSEDevice::shutdown_for_description(OpenFileDescription const& description
|
||||
{
|
||||
m_instances.with([&](auto& instances) {
|
||||
VERIFY(instances.active_instances.remove(&description));
|
||||
instances.closing_instances.append(&description);
|
||||
instances.closing_instances.try_append(&description).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
|
||||
evaluate_block_conditions();
|
||||
|
||||
@@ -57,7 +57,7 @@ UNMAP_AFTER_INIT ErrorOr<void> Console::initialize_virtio_resources()
|
||||
} else {
|
||||
auto port = TRY(VirtIO::ConsolePort::create(0u, *this));
|
||||
port->init_receive_buffer({});
|
||||
m_ports.append(port);
|
||||
TRY(m_ports.try_append(port));
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ LockRefPtr<StorageDevice> AHCIController::device(u32 index) const
|
||||
bit = bit_scan_forward(pi);
|
||||
if (checked_device.is_null())
|
||||
continue;
|
||||
connected_devices.append(checked_device.release_nonnull());
|
||||
connected_devices.try_append(checked_device.release_nonnull()).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
dbgln_if(AHCI_DEBUG, "Connected device count: {}, Index: {}", connected_devices.size(), index);
|
||||
if (index >= connected_devices.size())
|
||||
|
||||
@@ -181,7 +181,7 @@ public:
|
||||
u32 bitfield = m_bitfield & m_bit_mask;
|
||||
for (size_t index = 0; index < 32; index++) {
|
||||
if (bitfield & 1) {
|
||||
indices.append(index);
|
||||
indices.try_append(index).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
bitfield >>= 1;
|
||||
}
|
||||
|
||||
@@ -40,11 +40,11 @@ ErrorOr<void> AHCIPort::allocate_resources_and_initialize_ports()
|
||||
|
||||
for (size_t index = 0; index < 1; index++) {
|
||||
auto dma_page = TRY(MM.allocate_physical_page());
|
||||
m_dma_buffers.append(move(dma_page));
|
||||
TRY(m_dma_buffers.try_append(move(dma_page)));
|
||||
}
|
||||
for (size_t index = 0; index < 1; index++) {
|
||||
auto command_table_page = TRY(MM.allocate_physical_page());
|
||||
m_command_table_pages.append(move(command_table_page));
|
||||
TRY(m_command_table_pages.try_append(move(command_table_page)));
|
||||
}
|
||||
|
||||
// FIXME: Synchronize DMA buffer accesses correctly and set the MemoryType to NonCacheable.
|
||||
@@ -417,7 +417,7 @@ Optional<AsyncDeviceRequest::RequestResult> AHCIPort::prepare_and_set_scatter_li
|
||||
|
||||
Vector<NonnullRefPtr<Memory::PhysicalRAMPage>> allocated_dma_regions;
|
||||
for (size_t index = 0; index < calculate_descriptors_count(request.block_count()); index++) {
|
||||
allocated_dma_regions.append(m_dma_buffers.at(index));
|
||||
allocated_dma_regions.try_append(m_dma_buffers.at(index)).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
m_current_scatter_list = Memory::ScatterGatherList::try_create(request, allocated_dma_regions.span(), m_connected_device->block_size(), "AHCI Scattered DMA"sv).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
@@ -211,7 +211,7 @@ UNMAP_AFTER_INIT ErrorOr<void> NVMeController::identify_and_init_namespaces()
|
||||
|
||||
dbgln_if(NVME_DEBUG, "NVMe: Block count is {} and Block size is {}", block_counts, block_size);
|
||||
|
||||
m_namespaces.append(TRY(NVMeNameSpace::create(*this, m_queues, nsid, block_counts, block_size)));
|
||||
TRY(m_namespaces.try_append(TRY(NVMeNameSpace::create(*this, m_queues, nsid, block_counts, block_size))));
|
||||
m_device_count++;
|
||||
dbgln_if(NVME_DEBUG, "NVMe: Initialized namespace with NSID: {}", nsid);
|
||||
}
|
||||
@@ -443,7 +443,7 @@ UNMAP_AFTER_INIT ErrorOr<void> NVMeController::create_io_queue(u8 qid, QueueType
|
||||
|
||||
auto irq = TRY(allocate_irq(qid));
|
||||
|
||||
m_queues.append(TRY(NVMeQueue::try_create(*this, qid, irq, IO_QUEUE_SIZE, move(cq_dma_region), move(sq_dma_region), move(doorbell), queue_type)));
|
||||
TRY(m_queues.try_append(TRY(NVMeQueue::try_create(*this, qid, irq, IO_QUEUE_SIZE, move(cq_dma_region), move(sq_dma_region), move(doorbell), queue_type))));
|
||||
dbgln_if(NVME_DEBUG, "NVMe: Created IO Queue with QID{}", m_queues.size());
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ UNMAP_AFTER_INIT void StorageManagement::enumerate_pci_controllers(bool nvme_pol
|
||||
if (subclass_code == SubclassID::SATAController
|
||||
&& device_identifier.prog_if() == PCI::MassStorage::SATAProgIF::AHCI) {
|
||||
if (auto ahci_controller_or_error = AHCIController::initialize(device_identifier); !ahci_controller_or_error.is_error())
|
||||
m_controllers.append(ahci_controller_or_error.value());
|
||||
m_controllers.try_append(ahci_controller_or_error.value()).release_value_but_fixme_should_propagate_errors();
|
||||
else
|
||||
dmesgln("Unable to initialize AHCI controller: {}", ahci_controller_or_error.error());
|
||||
}
|
||||
@@ -127,13 +127,13 @@ UNMAP_AFTER_INIT void StorageManagement::enumerate_pci_controllers(bool nvme_pol
|
||||
if (controller.is_error()) {
|
||||
dmesgln("Unable to initialize NVMe controller: {}", controller.error());
|
||||
} else {
|
||||
m_controllers.append(controller.release_value());
|
||||
m_controllers.try_append(controller.release_value()).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
}
|
||||
if (VirtIOBlockController::is_handled(device_identifier)) {
|
||||
if (virtio_controller.is_null()) {
|
||||
auto controller = make_ref_counted<VirtIOBlockController>();
|
||||
m_controllers.append(controller);
|
||||
m_controllers.try_append(controller).release_value_but_fixme_should_propagate_errors();
|
||||
virtio_controller = controller;
|
||||
}
|
||||
if (auto res = virtio_controller->add_device(device_identifier); res.is_error()) {
|
||||
@@ -152,7 +152,7 @@ UNMAP_AFTER_INIT void StorageManagement::enumerate_pci_controllers(bool nvme_pol
|
||||
if (sdhc_or_error.is_error()) {
|
||||
dmesgln("PCI: Failed to initialize SD Host Controller ({} - {}): {}", device_identifier.address(), device_identifier.hardware_id(), sdhc_or_error.error());
|
||||
} else {
|
||||
m_controllers.append(sdhc_or_error.release_value());
|
||||
m_controllers.try_append(sdhc_or_error.release_value()).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -36,7 +36,7 @@ ErrorOr<void> VirtIOBlockController::add_device(PCI::DeviceIdentifier const& dev
|
||||
auto device = TRY(adopt_nonnull_lock_ref_or_enomem(new (nothrow) VirtIOBlockDevice(move(transport_link), lun, cid)));
|
||||
TRY(device->initialize_virtio_resources());
|
||||
|
||||
m_devices.append(device);
|
||||
TRY(m_devices.try_append(device));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ ErrorOr<NonnullRefPtr<OpenFileDescription>> PTYMultiplexer::open(int options)
|
||||
void PTYMultiplexer::notify_master_destroyed(Badge<MasterPTY>, unsigned index)
|
||||
{
|
||||
m_freelist.with([&](auto& freelist) {
|
||||
freelist.append(index);
|
||||
freelist.try_append(index).release_value_but_fixme_should_propagate_errors();
|
||||
dbgln_if(PTMX_DEBUG, "PTYMultiplexer: {} added to freelist", index);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ UNMAP_AFTER_INIT void VirtualConsole::initialize()
|
||||
|
||||
// Add the lines, so we also ensure they will be flushed now
|
||||
for (size_t row = 0; row < rows(); row++) {
|
||||
m_lines.append({ true, 0 });
|
||||
m_lines.try_append({ true, 0 }).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
VERIFY(m_cells);
|
||||
}
|
||||
@@ -259,7 +259,7 @@ void VirtualConsole::refresh_after_resolution_change()
|
||||
m_lines.shrink(rows());
|
||||
} else {
|
||||
for (size_t row = 0; row < (size_t)(rows() - old_rows_count); row++) {
|
||||
m_lines.append({ true, 0 });
|
||||
m_lines.try_append({ true, 0 }).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -386,7 +386,7 @@ ErrorOr<void> FATInode::allocate_and_add_cluster_to_chain()
|
||||
TRY(fs().fat_write(cluster_list->last(), allocated_cluster));
|
||||
}
|
||||
|
||||
cluster_list->append(allocated_cluster);
|
||||
cluster_list->try_append(allocated_cluster).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ void Inode::sync_all()
|
||||
Inode::all_instances().with([&](auto& all_inodes) {
|
||||
for (auto& inode : all_inodes) {
|
||||
if (inode.is_metadata_dirty())
|
||||
inodes.append(inode);
|
||||
inodes.try_append(inode).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -273,7 +273,7 @@ void VirtualFileSystem::sync_filesystems()
|
||||
Vector<NonnullRefPtr<FileSystem>, 32> file_systems;
|
||||
s_details->file_systems_list.with([&](auto const& list) {
|
||||
for (auto& fs : list)
|
||||
file_systems.append(fs);
|
||||
file_systems.try_append(fs).release_value_but_fixme_should_propagate_errors();
|
||||
});
|
||||
|
||||
for (auto& fs : file_systems) {
|
||||
|
||||
@@ -207,7 +207,7 @@ UNMAP_AFTER_INIT void Parser::process_dsdt()
|
||||
auto sdt = Memory::map_typed<Structures::FADT>(m_fadt).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// Add DSDT-pointer to expose the full table in /sys/firmware/acpi/
|
||||
m_sdt_pointers.append(PhysicalAddress(sdt->dsdt_ptr));
|
||||
m_sdt_pointers.try_append(PhysicalAddress(sdt->dsdt_ptr)).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
auto dsdt_or_error = Memory::map_typed<Structures::DSDT>(PhysicalAddress(sdt->dsdt_ptr));
|
||||
if (dsdt_or_error.is_error()) {
|
||||
@@ -361,7 +361,7 @@ UNMAP_AFTER_INIT void Parser::initialize_main_system_description_table()
|
||||
dbgln_if(ACPI_DEBUG, "ACPI: XSDT pointer @ {}", VirtualAddress { &xsdt });
|
||||
for (u32 i = 0; i < ((length - sizeof(Structures::SDTHeader)) / sizeof(u64)); i++) {
|
||||
dbgln_if(ACPI_DEBUG, "ACPI: Found new table [{0}], @ V{1:p} - P{1:p}", i, &xsdt.table_ptrs[i]);
|
||||
m_sdt_pointers.append(PhysicalAddress(xsdt.table_ptrs[i]));
|
||||
m_sdt_pointers.try_append(PhysicalAddress(xsdt.table_ptrs[i])).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
} else {
|
||||
auto& rsdt = (Structures::RSDT const&)*sdt;
|
||||
@@ -370,7 +370,7 @@ UNMAP_AFTER_INIT void Parser::initialize_main_system_description_table()
|
||||
dbgln_if(ACPI_DEBUG, "ACPI: RSDT pointer @ V{}", &rsdt);
|
||||
for (u32 i = 0; i < ((length - sizeof(Structures::SDTHeader)) / sizeof(u32)); i++) {
|
||||
dbgln_if(ACPI_DEBUG, "ACPI: Found new table [{0}], @ V{1:p} - P{1:p}", i, &rsdt.table_ptrs[i]);
|
||||
m_sdt_pointers.append(PhysicalAddress(rsdt.table_ptrs[i]));
|
||||
m_sdt_pointers.try_append(PhysicalAddress(rsdt.table_ptrs[i])).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@ UNMAP_AFTER_INIT void MemoryManager::register_reserved_ranges(GlobalData& global
|
||||
if (current_range.type != PhysicalMemoryRangeType::Reserved) {
|
||||
if (range.start.is_null())
|
||||
continue;
|
||||
global_data.reserved_memory_ranges.append(ContiguousReservedMemoryRange { range.start, current_range.start.get() - range.start.get() });
|
||||
global_data.reserved_memory_ranges.try_append(ContiguousReservedMemoryRange { range.start, current_range.start.get() - range.start.get() }).release_value_but_fixme_should_propagate_errors();
|
||||
range.start.set((FlatPtr) nullptr);
|
||||
continue;
|
||||
}
|
||||
@@ -229,7 +229,7 @@ UNMAP_AFTER_INIT void MemoryManager::register_reserved_ranges(GlobalData& global
|
||||
return;
|
||||
if (range.start.is_null())
|
||||
return;
|
||||
global_data.reserved_memory_ranges.append(ContiguousReservedMemoryRange { range.start, global_data.physical_memory_ranges.last().start.get() + global_data.physical_memory_ranges.last().length - range.start.get() });
|
||||
global_data.reserved_memory_ranges.try_append(ContiguousReservedMemoryRange { range.start, global_data.physical_memory_ranges.last().start.get() + global_data.physical_memory_ranges.last().length - range.start.get() }).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
bool MemoryManager::is_allowed_to_read_physical_memory_for_userspace(PhysicalAddress start_address, size_t read_length) const
|
||||
@@ -280,9 +280,9 @@ UNMAP_AFTER_INIT void MemoryManager::parse_memory_map()
|
||||
// **To be completely on the safe side** and never worry about where the EBDA is located, how BIOS might
|
||||
// corrupt the low memory range during power state changing, other bad behavior of some BIOS might change
|
||||
// a value in the very first 64k bytes of RAM, etc - we should just ignore this range completely.
|
||||
global_data.used_memory_ranges.append(UsedMemoryRange { UsedMemoryRangeType::LowMemory, PhysicalAddress(0x00000000), PhysicalAddress(1 * MiB) });
|
||||
global_data.used_memory_ranges.try_append(UsedMemoryRange { UsedMemoryRangeType::LowMemory, PhysicalAddress(0x00000000), PhysicalAddress(1 * MiB) }).release_value_but_fixme_should_propagate_errors();
|
||||
#endif
|
||||
global_data.used_memory_ranges.append(UsedMemoryRange { UsedMemoryRangeType::Kernel, PhysicalAddress(virtual_to_low_physical((FlatPtr)start_of_kernel_image)), PhysicalAddress(page_round_up(virtual_to_low_physical((FlatPtr)end_of_kernel_image)).release_value_but_fixme_should_propagate_errors()) });
|
||||
global_data.used_memory_ranges.try_append(UsedMemoryRange { UsedMemoryRangeType::Kernel, PhysicalAddress(virtual_to_low_physical((FlatPtr)start_of_kernel_image)), PhysicalAddress(page_round_up(virtual_to_low_physical((FlatPtr)end_of_kernel_image)).release_value_but_fixme_should_propagate_errors()) }).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
if (g_boot_info.boot_method == BootMethod::EFI)
|
||||
parse_memory_map_efi(global_data);
|
||||
@@ -343,7 +343,7 @@ UNMAP_AFTER_INIT void MemoryManager::parse_memory_map()
|
||||
if (last_contiguous_physical_range.has_value()) {
|
||||
auto range = last_contiguous_physical_range.release_value();
|
||||
// FIXME: OOM?
|
||||
global_data.physical_regions.append(PhysicalRegion::try_create(range.lower, range.upper).release_nonnull());
|
||||
global_data.physical_regions.try_append(PhysicalRegion::try_create(range.lower, range.upper).release_nonnull()).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
last_contiguous_physical_range = ContiguousPhysicalRange { .lower = addr, .upper = addr };
|
||||
} else {
|
||||
@@ -354,7 +354,7 @@ UNMAP_AFTER_INIT void MemoryManager::parse_memory_map()
|
||||
if (last_contiguous_physical_range.has_value()) {
|
||||
auto range = last_contiguous_physical_range.release_value();
|
||||
// FIXME: OOM?
|
||||
global_data.physical_regions.append(PhysicalRegion::try_create(range.lower, range.upper).release_nonnull());
|
||||
global_data.physical_regions.try_append(PhysicalRegion::try_create(range.lower, range.upper).release_nonnull()).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,7 +435,7 @@ UNMAP_AFTER_INIT void MemoryManager::parse_memory_map_efi(MemoryManager::GlobalD
|
||||
case EFI::MemoryType::BootServicesCode:
|
||||
case EFI::MemoryType::BootServicesData:
|
||||
case EFI::MemoryType::Conventional:
|
||||
global_data.physical_memory_ranges.append(PhysicalMemoryRange { PhysicalMemoryRangeType::Usable, start_paddr, length });
|
||||
global_data.physical_memory_ranges.try_append(PhysicalMemoryRange { PhysicalMemoryRangeType::Usable, start_paddr, length }).release_value_but_fixme_should_propagate_errors();
|
||||
break;
|
||||
case EFI::MemoryType::Reserved:
|
||||
case EFI::MemoryType::LoaderCode:
|
||||
@@ -466,29 +466,29 @@ UNMAP_AFTER_INIT void MemoryManager::parse_memory_map_efi(MemoryManager::GlobalD
|
||||
if ((start_paddr.get() != 0x000000fd00000000 || length != (0x000000ffffffffff - 0x000000fd00000000) + 1)
|
||||
&& (start_paddr.get() != 0x000003fff0000000 || length != 0x10000000))
|
||||
#endif
|
||||
global_data.physical_memory_ranges.append(PhysicalMemoryRange { PhysicalMemoryRangeType::Reserved, start_paddr, length });
|
||||
global_data.physical_memory_ranges.try_append(PhysicalMemoryRange { PhysicalMemoryRangeType::Reserved, start_paddr, length }).release_value_but_fixme_should_propagate_errors();
|
||||
break;
|
||||
case EFI::MemoryType::ACPIReclaim:
|
||||
global_data.physical_memory_ranges.append(PhysicalMemoryRange { PhysicalMemoryRangeType::ACPI_Reclaimable, start_paddr, length });
|
||||
global_data.physical_memory_ranges.try_append(PhysicalMemoryRange { PhysicalMemoryRangeType::ACPI_Reclaimable, start_paddr, length }).release_value_but_fixme_should_propagate_errors();
|
||||
break;
|
||||
case EFI::MemoryType::ACPI_NVS:
|
||||
global_data.physical_memory_ranges.append(PhysicalMemoryRange { PhysicalMemoryRangeType::ACPI_NVS, start_paddr, length });
|
||||
global_data.physical_memory_ranges.try_append(PhysicalMemoryRange { PhysicalMemoryRangeType::ACPI_NVS, start_paddr, length }).release_value_but_fixme_should_propagate_errors();
|
||||
break;
|
||||
case EFI::MemoryType::Unusable:
|
||||
dmesgln("MM: Warning, detected bad memory range!");
|
||||
global_data.physical_memory_ranges.append(PhysicalMemoryRange { PhysicalMemoryRangeType::BadMemory, start_paddr, length });
|
||||
global_data.physical_memory_ranges.try_append(PhysicalMemoryRange { PhysicalMemoryRangeType::BadMemory, start_paddr, length }).release_value_but_fixme_should_propagate_errors();
|
||||
break;
|
||||
default:
|
||||
dbgln("MM: Unknown EFI memory type: {}", to_underlying(descriptor->type));
|
||||
global_data.physical_memory_ranges.append(PhysicalMemoryRange { PhysicalMemoryRangeType::Unknown, start_paddr, length });
|
||||
global_data.physical_memory_ranges.try_append(PhysicalMemoryRange { PhysicalMemoryRangeType::Unknown, start_paddr, length }).release_value_but_fixme_should_propagate_errors();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// SMBIOS data can be in a BootServicesData memory region (see https://uefi.org/specs/UEFI/2.10/02_Overview.html#x64-platforms, the same requirement is listed for AArch64 and RISC-V as well).
|
||||
// BootServices* memory regions are treated as normal main memory after ExitBootServices, so we need to explicitly mark its ranges as used.
|
||||
global_data.used_memory_ranges.append(UsedMemoryRange { UsedMemoryRangeType::SMBIOS, g_boot_info.smbios.entry_point_paddr, g_boot_info.smbios.entry_point_paddr.offset(g_boot_info.smbios.entry_point_length) });
|
||||
global_data.used_memory_ranges.append(UsedMemoryRange { UsedMemoryRangeType::SMBIOS, g_boot_info.smbios.structure_table_paddr, g_boot_info.smbios.structure_table_paddr.offset(g_boot_info.smbios.maximum_structure_table_length) });
|
||||
global_data.used_memory_ranges.try_append(UsedMemoryRange { UsedMemoryRangeType::SMBIOS, g_boot_info.smbios.entry_point_paddr, g_boot_info.smbios.entry_point_paddr.offset(g_boot_info.smbios.entry_point_length) }).release_value_but_fixme_should_propagate_errors();
|
||||
global_data.used_memory_ranges.try_append(UsedMemoryRange { UsedMemoryRangeType::SMBIOS, g_boot_info.smbios.structure_table_paddr, g_boot_info.smbios.structure_table_paddr.offset(g_boot_info.smbios.maximum_structure_table_length) }).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT void MemoryManager::parse_memory_map_fdt(MemoryManager::GlobalData& global_data, u8 const* fdt_addr)
|
||||
@@ -503,9 +503,9 @@ UNMAP_AFTER_INIT void MemoryManager::parse_memory_map_fdt(MemoryManager::GlobalD
|
||||
u64 next_block_offset = fdt_header.off_mem_rsvmap + sizeof(::DeviceTree::FlattenedDeviceTreeReserveEntry);
|
||||
while ((next_block_offset < fdt_header.off_dt_struct) && (*mem_reserve_block != ::DeviceTree::FlattenedDeviceTreeReserveEntry {})) {
|
||||
dbgln("MM: Reserved Range /memreserve/: address: {} size {:#x}", PhysicalAddress { mem_reserve_block->address }, mem_reserve_block->size);
|
||||
global_data.physical_memory_ranges.append(PhysicalMemoryRange { PhysicalMemoryRangeType::Reserved, PhysicalAddress { mem_reserve_block->address }, mem_reserve_block->size });
|
||||
global_data.physical_memory_ranges.try_append(PhysicalMemoryRange { PhysicalMemoryRangeType::Reserved, PhysicalAddress { mem_reserve_block->address }, mem_reserve_block->size }).release_value_but_fixme_should_propagate_errors();
|
||||
// FIXME: Not all of these are "used", only those in "memory" are actually "used"
|
||||
global_data.used_memory_ranges.append(UsedMemoryRange { UsedMemoryRangeType::BootModule, PhysicalAddress { mem_reserve_block->address }, PhysicalAddress { mem_reserve_block->address + mem_reserve_block->size } });
|
||||
global_data.used_memory_ranges.try_append(UsedMemoryRange { UsedMemoryRangeType::BootModule, PhysicalAddress { mem_reserve_block->address }, PhysicalAddress { mem_reserve_block->address + mem_reserve_block->size } }).release_value_but_fixme_should_propagate_errors();
|
||||
++mem_reserve_block;
|
||||
next_block_offset += sizeof(::DeviceTree::FlattenedDeviceTreeReserveEntry);
|
||||
}
|
||||
@@ -695,7 +695,7 @@ UNMAP_AFTER_INIT void MemoryManager::parse_memory_map_multiboot(MemoryManager::G
|
||||
if (g_boot_info.boot_method_specific.multiboot1.flags & 0x4 && !g_boot_info.boot_method_specific.multiboot1.module_physical_ptr.is_null()) {
|
||||
dmesgln("MM: Multiboot module @ {}, length={}", g_boot_info.boot_method_specific.multiboot1.module_physical_ptr, g_boot_info.boot_method_specific.multiboot1.module_length);
|
||||
VERIFY(g_boot_info.boot_method_specific.multiboot1.module_length != 0);
|
||||
global_data.used_memory_ranges.append(UsedMemoryRange { UsedMemoryRangeType::BootModule, g_boot_info.boot_method_specific.multiboot1.module_physical_ptr, g_boot_info.boot_method_specific.multiboot1.module_physical_ptr.offset(g_boot_info.boot_method_specific.multiboot1.module_length) });
|
||||
global_data.used_memory_ranges.try_append(UsedMemoryRange { UsedMemoryRangeType::BootModule, g_boot_info.boot_method_specific.multiboot1.module_physical_ptr, g_boot_info.boot_method_specific.multiboot1.module_physical_ptr.offset(g_boot_info.boot_method_specific.multiboot1.module_length) }).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
auto const* mmap_begin = g_boot_info.boot_method_specific.multiboot1.memory_map;
|
||||
@@ -712,7 +712,7 @@ UNMAP_AFTER_INIT void MemoryManager::parse_memory_map_multiboot(MemoryManager::G
|
||||
auto start_address = PhysicalAddress(address);
|
||||
switch (mmap->type) {
|
||||
case (MULTIBOOT_MEMORY_AVAILABLE):
|
||||
global_data.physical_memory_ranges.append(PhysicalMemoryRange { PhysicalMemoryRangeType::Usable, start_address, length });
|
||||
global_data.physical_memory_ranges.try_append(PhysicalMemoryRange { PhysicalMemoryRangeType::Usable, start_address, length }).release_value_but_fixme_should_propagate_errors();
|
||||
break;
|
||||
case (MULTIBOOT_MEMORY_RESERVED):
|
||||
#if ARCH(X86_64)
|
||||
@@ -734,21 +734,21 @@ UNMAP_AFTER_INIT void MemoryManager::parse_memory_map_multiboot(MemoryManager::G
|
||||
if ((address != 0x000000fd00000000 || length != (0x000000ffffffffff - 0x000000fd00000000) + 1)
|
||||
&& (address != 0x000003fff0000000 || length != 0x10000000))
|
||||
#endif
|
||||
global_data.physical_memory_ranges.append(PhysicalMemoryRange { PhysicalMemoryRangeType::Reserved, start_address, length });
|
||||
global_data.physical_memory_ranges.try_append(PhysicalMemoryRange { PhysicalMemoryRangeType::Reserved, start_address, length }).release_value_but_fixme_should_propagate_errors();
|
||||
break;
|
||||
case (MULTIBOOT_MEMORY_ACPI_RECLAIMABLE):
|
||||
global_data.physical_memory_ranges.append(PhysicalMemoryRange { PhysicalMemoryRangeType::ACPI_Reclaimable, start_address, length });
|
||||
global_data.physical_memory_ranges.try_append(PhysicalMemoryRange { PhysicalMemoryRangeType::ACPI_Reclaimable, start_address, length }).release_value_but_fixme_should_propagate_errors();
|
||||
break;
|
||||
case (MULTIBOOT_MEMORY_NVS):
|
||||
global_data.physical_memory_ranges.append(PhysicalMemoryRange { PhysicalMemoryRangeType::ACPI_NVS, start_address, length });
|
||||
global_data.physical_memory_ranges.try_append(PhysicalMemoryRange { PhysicalMemoryRangeType::ACPI_NVS, start_address, length }).release_value_but_fixme_should_propagate_errors();
|
||||
break;
|
||||
case (MULTIBOOT_MEMORY_BADRAM):
|
||||
dmesgln("MM: Warning, detected bad memory range!");
|
||||
global_data.physical_memory_ranges.append(PhysicalMemoryRange { PhysicalMemoryRangeType::BadMemory, start_address, length });
|
||||
global_data.physical_memory_ranges.try_append(PhysicalMemoryRange { PhysicalMemoryRangeType::BadMemory, start_address, length }).release_value_but_fixme_should_propagate_errors();
|
||||
break;
|
||||
default:
|
||||
dbgln("MM: Unknown range!");
|
||||
global_data.physical_memory_ranges.append(PhysicalMemoryRange { PhysicalMemoryRangeType::Unknown, start_address, length });
|
||||
global_data.physical_memory_ranges.try_append(PhysicalMemoryRange { PhysicalMemoryRangeType::Unknown, start_address, length }).release_value_but_fixme_should_propagate_errors();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -821,7 +821,7 @@ UNMAP_AFTER_INIT void MemoryManager::initialize_physical_pages(GlobalData& globa
|
||||
} else {
|
||||
global_data.physical_pages_region = found_region->try_take_pages_from_beginning(physical_page_array_pages_and_page_tables_count);
|
||||
}
|
||||
global_data.used_memory_ranges.append({ UsedMemoryRangeType::PhysicalPages, global_data.physical_pages_region->lower(), global_data.physical_pages_region->upper() });
|
||||
global_data.used_memory_ranges.try_append({ UsedMemoryRangeType::PhysicalPages, global_data.physical_pages_region->lower(), global_data.physical_pages_region->upper() }).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
// Create the bare page directory. This is not a fully constructed page directory and merely contains the allocators!
|
||||
m_kernel_page_directory = PageDirectory::must_create_kernel_page_directory();
|
||||
|
||||
@@ -44,7 +44,8 @@ void PhysicalRegion::initialize_zones()
|
||||
size_t zone_count = 0;
|
||||
auto first_address = base_address;
|
||||
while (remaining_pages >= pages_per_zone) {
|
||||
m_zones.append(adopt_nonnull_own_or_enomem(new (nothrow) PhysicalZone(base_address, pages_per_zone)).release_value_but_fixme_should_propagate_errors());
|
||||
auto zone = adopt_nonnull_own_or_enomem(new (nothrow) PhysicalZone(base_address, pages_per_zone)).release_value_but_fixme_should_propagate_errors();
|
||||
m_zones.try_append(move(zone)).release_value_but_fixme_should_propagate_errors();
|
||||
base_address = base_address.offset(pages_per_zone * PAGE_SIZE);
|
||||
m_usable_zones.append(*m_zones.last());
|
||||
remaining_pages -= pages_per_zone;
|
||||
@@ -98,7 +99,7 @@ Vector<NonnullRefPtr<PhysicalRAMPage>> PhysicalRegion::take_contiguous_free_page
|
||||
physical_pages.ensure_capacity(count);
|
||||
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
physical_pages.append(PhysicalRAMPage::create(page_base.value().offset(i * PAGE_SIZE)));
|
||||
physical_pages.try_append(PhysicalRAMPage::create(page_base.value().offset(i * PAGE_SIZE))).release_value_but_fixme_should_propagate_errors();
|
||||
return physical_pages;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ ErrorOr<void> SharedInodeVMObject::sync_impl(off_t offset_in_pages, size_t pages
|
||||
for (size_t page_index = offset_in_pages; page_index < highest_page_to_flush; ++page_index) {
|
||||
auto& physical_page = m_physical_pages[page_index];
|
||||
if (physical_page && is_page_dirty(page_index))
|
||||
pages_to_flush.append(page_index);
|
||||
TRY(pages_to_flush.try_append(page_index));
|
||||
}
|
||||
|
||||
if (pages_to_flush.size() == 0)
|
||||
|
||||
@@ -19,9 +19,9 @@ Vector<VirtualRange, 2> VirtualRange::carve(VirtualRange const& taken) const
|
||||
if (taken == *this)
|
||||
return {};
|
||||
if (taken.base() > base())
|
||||
parts.append({ base(), taken.base().get() - base().get() });
|
||||
parts.unchecked_append({ base(), taken.base().get() - base().get() });
|
||||
if (taken.end() < end())
|
||||
parts.append({ taken.end(), end().get() - taken.end().get() });
|
||||
parts.unchecked_append({ taken.end(), end().get() - taken.end().get() });
|
||||
return parts;
|
||||
}
|
||||
|
||||
|
||||
@@ -556,7 +556,7 @@ ErrorOr<void> IPv4Socket::setsockopt(int level, int option, Userspace<void const
|
||||
return ENOTSUP;
|
||||
IPv4Address address { (u8 const*)&mreq.imr_multiaddr.s_addr };
|
||||
if (!m_multicast_memberships.contains_slow(address))
|
||||
m_multicast_memberships.append(address);
|
||||
TRY(m_multicast_memberships.try_append(address));
|
||||
return {};
|
||||
}
|
||||
case IP_DROP_MEMBERSHIP: {
|
||||
|
||||
@@ -396,7 +396,7 @@ void handle_icmp(EthernetFrameHeader const& eth, IPv4Packet const& ipv4_packet,
|
||||
IPv4Socket::all_sockets().with_exclusive([&](auto& sockets) {
|
||||
for (auto& socket : sockets) {
|
||||
if (socket.protocol() == (unsigned)TransportProtocol::ICMP)
|
||||
icmp_sockets.append(socket);
|
||||
icmp_sockets.try_append(socket).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
});
|
||||
for (auto& socket : icmp_sockets)
|
||||
|
||||
@@ -148,11 +148,11 @@ bool NetworkingManagement::initialize()
|
||||
dmesgln("Failed to initialize network adapter ({} {}): {}", device_identifier.address(), device_identifier.hardware_id(), result.error());
|
||||
return;
|
||||
}
|
||||
m_adapters.with([&](auto& adapters) { adapters.append(*result.release_value()); });
|
||||
m_adapters.with([&](auto& adapters) { adapters.try_append(*result.release_value()).release_value_but_fixme_should_propagate_errors(); });
|
||||
}));
|
||||
}
|
||||
auto loopback = MUST(LoopbackAdapter::try_create());
|
||||
m_adapters.with([&](auto& adapters) { adapters.append(*loopback); });
|
||||
m_adapters.with([&](auto& adapters) { adapters.try_append(*loopback).release_value_but_fixme_should_propagate_errors(); });
|
||||
m_loopback_adapter = *loopback;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1257,7 +1257,7 @@ UNMAP_AFTER_INIT void RTL8168NetworkAdapter::initialize_rx_descriptors()
|
||||
auto& descriptor = m_rx_descriptors[i];
|
||||
auto region = MM.allocate_contiguous_kernel_region(Memory::page_round_up(RX_BUFFER_SIZE).release_value_but_fixme_should_propagate_errors(), "RTL8168 RX buffer"sv, Memory::Region::Access::ReadWrite).release_value();
|
||||
memset(region->vaddr().as_ptr(), 0, region->size()); // MM already zeros out newly allocated pages, but we do it again in case that ever changes
|
||||
m_rx_buffers_regions.append(move(region));
|
||||
m_rx_buffers_regions.try_append(move(region)).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
descriptor.buffer_size = RX_BUFFER_SIZE;
|
||||
descriptor.flags = RXDescriptor::Ownership; // let the NIC know it can use this descriptor
|
||||
@@ -1274,7 +1274,7 @@ UNMAP_AFTER_INIT void RTL8168NetworkAdapter::initialize_tx_descriptors()
|
||||
auto& descriptor = m_tx_descriptors[i];
|
||||
auto region = MM.allocate_contiguous_kernel_region(Memory::page_round_up(TX_BUFFER_SIZE).release_value_but_fixme_should_propagate_errors(), "RTL8168 TX buffer"sv, Memory::Region::Access::ReadWrite).release_value();
|
||||
memset(region->vaddr().as_ptr(), 0, region->size()); // MM already zeros out newly allocated pages, but we do it again in case that ever changes
|
||||
m_tx_buffers_regions.append(move(region));
|
||||
m_tx_buffers_regions.try_append(move(region)).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
descriptor.flags = TXDescriptor::FirstSegment | TXDescriptor::LastSegment;
|
||||
auto physical_address = m_tx_buffers_regions[i]->physical_page(0)->paddr().get();
|
||||
|
||||
@@ -326,7 +326,7 @@ public:
|
||||
SpinlockLocker lock(m_lock);
|
||||
if (!should_add_blocker(blocker, data))
|
||||
return false;
|
||||
m_blockers.append({ &blocker, data });
|
||||
m_blockers.try_append({ &blocker, data }).release_value_but_fixme_should_propagate_errors();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ public:
|
||||
Vector<BlockerInfo, 4> taken_blockers;
|
||||
taken_blockers.ensure_capacity(move_count);
|
||||
for (size_t i = 0; i < move_count; i++)
|
||||
taken_blockers.append(m_blockers.take(i));
|
||||
taken_blockers.unchecked_append(m_blockers.take(i));
|
||||
m_blockers.remove(0, move_count);
|
||||
return taken_blockers;
|
||||
}
|
||||
@@ -411,7 +411,7 @@ public:
|
||||
}
|
||||
m_blockers.ensure_capacity(m_blockers.size() + blockers_to_append.size());
|
||||
for (size_t i = 0; i < blockers_to_append.size(); i++)
|
||||
m_blockers.append(blockers_to_append.take(i));
|
||||
m_blockers.unchecked_append(blockers_to_append.take(i));
|
||||
blockers_to_append.clear();
|
||||
}
|
||||
|
||||
@@ -1016,7 +1016,7 @@ public:
|
||||
}
|
||||
}
|
||||
if (!have_existing)
|
||||
m_holding_locks_list.append({ &lock, location, 1 });
|
||||
m_holding_locks_list.try_append({ &lock, location, 1 }).release_value_but_fixme_should_propagate_errors();
|
||||
} else {
|
||||
VERIFY(refs_delta < 0);
|
||||
bool found = false;
|
||||
|
||||
@@ -615,7 +615,7 @@ bool Thread::WaitBlockerSet::unblock(Process& process, WaitBlocker::UnblockFlags
|
||||
}
|
||||
if (!updated_existing) {
|
||||
dbgln_if(WAITBLOCK_DEBUG, "WaitBlockerSet[{}] add {} flags: {}", m_process, process, (int)flags);
|
||||
m_processes.append(ProcessBlockInfo(process, flags, signal));
|
||||
m_processes.try_append(ProcessBlockInfo(process, flags, signal)).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
}
|
||||
return did_unblock_any;
|
||||
|
||||
@@ -60,7 +60,7 @@ void TimeManagement::add_recipe(DeviceTree::DeviceRecipe<NonnullLockRefPtr<Hardw
|
||||
// as we do not support dynamic registration of timers.
|
||||
VERIFY(!is_initialized());
|
||||
|
||||
s_recipes->append(move(recipe));
|
||||
MUST(s_recipes->try_append(move(recipe)));
|
||||
}
|
||||
|
||||
// The s_scheduler_specific_current_time function provides a current time for scheduling purposes,
|
||||
@@ -330,7 +330,7 @@ UNMAP_AFTER_INIT Vector<HardwareTimerBase*> TimeManagement::scan_and_initialize_
|
||||
Vector<HardwareTimerBase*> timers;
|
||||
for (auto& hardware_timer : m_hardware_timers) {
|
||||
if (hardware_timer->is_periodic_capable()) {
|
||||
timers.append(hardware_timer);
|
||||
timers.try_append(hardware_timer).release_value_but_fixme_should_propagate_errors();
|
||||
if (should_enable)
|
||||
hardware_timer->set_periodic();
|
||||
}
|
||||
@@ -344,7 +344,7 @@ UNMAP_AFTER_INIT Vector<HardwareTimerBase*> TimeManagement::scan_for_non_periodi
|
||||
Vector<HardwareTimerBase*> timers;
|
||||
for (auto& hardware_timer : m_hardware_timers) {
|
||||
if (!hardware_timer->is_periodic_capable())
|
||||
timers.append(hardware_timer);
|
||||
timers.try_append(hardware_timer).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
return timers;
|
||||
}
|
||||
@@ -375,7 +375,7 @@ UNMAP_AFTER_INIT bool TimeManagement::probe_and_set_x86_non_legacy_hardware_time
|
||||
dbgln("HPET: Setting appropriate functions to timers.");
|
||||
|
||||
for (auto& hpet_comparator : HPET::the().comparators())
|
||||
m_hardware_timers.append(hpet_comparator);
|
||||
m_hardware_timers.try_append(hpet_comparator).release_value_but_fixme_should_propagate_errors();
|
||||
|
||||
auto periodic_timers = scan_and_initialize_periodic_timers();
|
||||
auto non_periodic_timers = scan_for_non_periodic_timers();
|
||||
@@ -447,8 +447,8 @@ UNMAP_AFTER_INIT bool TimeManagement::probe_and_set_x86_legacy_hardware_timers()
|
||||
}
|
||||
}
|
||||
|
||||
m_hardware_timers.append(PIT::initialize(TimeManagement::update_time));
|
||||
m_hardware_timers.append(RealTimeClock::create(TimeManagement::system_timer_tick));
|
||||
m_hardware_timers.try_append(PIT::initialize(TimeManagement::update_time)).release_value_but_fixme_should_propagate_errors();
|
||||
m_hardware_timers.try_append(RealTimeClock::create(TimeManagement::system_timer_tick)).release_value_but_fixme_should_propagate_errors();
|
||||
m_time_keeper_timer = m_hardware_timers[0];
|
||||
m_system_timer = m_hardware_timers[1];
|
||||
|
||||
@@ -497,7 +497,7 @@ UNMAP_AFTER_INIT bool TimeManagement::probe_and_set_aarch64_hardware_timers()
|
||||
continue;
|
||||
}
|
||||
|
||||
m_hardware_timers.append(device_or_error.release_value());
|
||||
MUST(m_hardware_timers.try_append(device_or_error.release_value()));
|
||||
}
|
||||
|
||||
if (m_hardware_timers.is_empty())
|
||||
@@ -542,7 +542,7 @@ UNMAP_AFTER_INIT bool TimeManagement::probe_and_set_aarch64_hardware_timers()
|
||||
#elif ARCH(RISCV64)
|
||||
UNMAP_AFTER_INIT bool TimeManagement::probe_and_set_riscv64_hardware_timers()
|
||||
{
|
||||
m_hardware_timers.append(RISCV64::Timer::initialize());
|
||||
MUST(m_hardware_timers.try_append(RISCV64::Timer::initialize()));
|
||||
m_system_timer = m_hardware_timers[0];
|
||||
m_time_ticks_per_second = m_system_timer->ticks_per_second();
|
||||
|
||||
|
||||
@@ -1054,7 +1054,7 @@ auto Parser::supported_resolutions() const -> ErrorOr<Vector<SupportedResolution
|
||||
return info.width == width && info.height == height;
|
||||
});
|
||||
if (it == resolutions.end()) {
|
||||
resolutions.append({ width, height, { { refresh_rate, preferred } } });
|
||||
resolutions.try_append({ width, height, { { refresh_rate, preferred } } }).release_value_but_fixme_should_propagate_errors();
|
||||
} else {
|
||||
auto& info = *it;
|
||||
SupportedResolution::RefreshRate* found_refresh_rate = nullptr;
|
||||
@@ -1067,7 +1067,7 @@ auto Parser::supported_resolutions() const -> ErrorOr<Vector<SupportedResolution
|
||||
if (found_refresh_rate)
|
||||
found_refresh_rate->preferred |= preferred;
|
||||
else
|
||||
info.refresh_rates.append({ refresh_rate, preferred });
|
||||
info.refresh_rates.try_append({ refresh_rate, preferred }).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -367,7 +367,7 @@ ErrorOr<ParsedReportDescriptor> ReportDescriptorParser::parse()
|
||||
break;
|
||||
|
||||
case GlobalItemTag::Push:
|
||||
m_item_state_table_stack.append(m_current_item_state_table);
|
||||
TRY(m_item_state_table_stack.try_append(m_current_item_state_table));
|
||||
break;
|
||||
|
||||
case GlobalItemTag::Pop:
|
||||
|
||||
@@ -29,7 +29,7 @@ void EBRPartitionTable::search_extended_partition(MBRPartitionTable& checked_ebr
|
||||
|
||||
// If we are pointed to an invalid logical partition, something is seriously wrong.
|
||||
VERIFY(checked_logical_partition.has_value());
|
||||
m_partitions.append(checked_logical_partition.value().offset(current_block_offset));
|
||||
m_partitions.try_append(checked_logical_partition.value().offset(current_block_offset)).release_value_but_fixme_should_propagate_errors();
|
||||
if (!checked_ebr.contains_ebr())
|
||||
return;
|
||||
current_block_offset += checked_ebr.partition(1).value().start_block();
|
||||
|
||||
@@ -108,7 +108,7 @@ bool GUIDPartitionTable::initialize()
|
||||
Array<u8, 16> unique_guid {};
|
||||
unique_guid.span().overwrite(0, entry.unique_guid, unique_guid.size());
|
||||
dbgln("Detected GPT partition (entry={}), offset={}, limit={}", entry_index, entry.first_lba, entry.last_lba);
|
||||
m_partitions.append({ entry.first_lba, entry.last_lba, partition_type, unique_guid, entry.attributes });
|
||||
m_partitions.try_append({ entry.first_lba, entry.last_lba, partition_type, unique_guid, entry.attributes }).release_value_but_fixme_should_propagate_errors();
|
||||
raw_byte_index += header().partition_entry_size;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ Vector<EscapeSequenceParser::OscParameter> EscapeSequenceParser::osc_parameters(
|
||||
// This should not be a problem as we won't dereference the 0-length Span that's created.
|
||||
// Using &m_osc_raw[prev_idx] to get the start pointer checks whether we're out of bounds,
|
||||
// so we would crash.
|
||||
params.append({ m_osc_raw.data() + prev_idx, end_idx - prev_idx });
|
||||
params.try_append({ m_osc_raw.data() + prev_idx, end_idx - prev_idx }).release_value_but_fixme_should_propagate_errors();
|
||||
prev_idx = end_idx;
|
||||
}
|
||||
return params;
|
||||
@@ -57,7 +57,7 @@ void EscapeSequenceParser::perform_action(EscapeSequenceStateMachine::Action act
|
||||
if (m_param_vector.size() == MAX_PARAMETERS)
|
||||
m_ignoring = true;
|
||||
else
|
||||
m_param_vector.append(m_param);
|
||||
m_param_vector.try_append(m_param).release_value_but_fixme_should_propagate_errors();
|
||||
m_executor.dcs_hook(m_param_vector, intermediates(), m_ignoring, byte);
|
||||
break;
|
||||
case EscapeSequenceStateMachine::Action::Put:
|
||||
@@ -91,17 +91,17 @@ void EscapeSequenceParser::perform_action(EscapeSequenceStateMachine::Action act
|
||||
if (m_osc_parameter_indexes.size() == MAX_OSC_PARAMETERS) {
|
||||
dbgln("EscapeSequenceParser::perform_action: shenanigans! OSC sequence has too many parameters");
|
||||
} else {
|
||||
m_osc_parameter_indexes.append(m_osc_raw.size());
|
||||
m_osc_parameter_indexes.try_append(m_osc_raw.size()).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
} else {
|
||||
m_osc_raw.append(byte);
|
||||
m_osc_raw.try_append(byte).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
break;
|
||||
case EscapeSequenceStateMachine::Action::OscEnd:
|
||||
if (m_osc_parameter_indexes.size() == MAX_OSC_PARAMETERS) {
|
||||
dbgln("EscapeSequenceParser::perform_action: shenanigans! OSC sequence has too many parameters");
|
||||
} else {
|
||||
m_osc_parameter_indexes.append(m_osc_raw.size());
|
||||
m_osc_parameter_indexes.try_append(m_osc_raw.size()).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
m_executor.execute_osc_sequence(osc_parameters(), byte);
|
||||
break;
|
||||
@@ -113,7 +113,7 @@ void EscapeSequenceParser::perform_action(EscapeSequenceStateMachine::Action act
|
||||
dbgln("EscapeSequenceParser::perform_action: shenanigans! CSI sequence has too many parameters");
|
||||
m_ignoring = true;
|
||||
} else {
|
||||
m_param_vector.append(m_param);
|
||||
m_param_vector.try_append(m_param).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
m_executor.execute_csi_sequence(m_param_vector, intermediates(), m_ignoring, byte);
|
||||
@@ -136,7 +136,7 @@ void EscapeSequenceParser::perform_action(EscapeSequenceStateMachine::Action act
|
||||
m_ignoring = true;
|
||||
} else {
|
||||
if (byte == ';') {
|
||||
m_param_vector.append(m_param);
|
||||
m_param_vector.try_append(m_param).release_value_but_fixme_should_propagate_errors();
|
||||
m_param = 0;
|
||||
} else if (byte == ':') {
|
||||
dbgln("EscapeSequenceParser::perform_action: subparameters are not yet implemented");
|
||||
|
||||
Reference in New Issue
Block a user