From 836c22ea1370703279791a864645ab2c6aad2dac Mon Sep 17 00:00:00 2001 From: Brian Gianforcaro Date: Sat, 2 Oct 2021 15:11:01 -0700 Subject: [PATCH] Kernel: Remove AK::String usage from Storage/StorageManagement.cpp --- Kernel/Storage/StorageManagement.cpp | 13 ++++++++----- Kernel/Storage/StorageManagement.h | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Kernel/Storage/StorageManagement.cpp b/Kernel/Storage/StorageManagement.cpp index 71c12c2022..cb13081b52 100644 --- a/Kernel/Storage/StorageManagement.cpp +++ b/Kernel/Storage/StorageManagement.cpp @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -25,6 +26,8 @@ namespace Kernel { static Singleton s_the; static Atomic s_device_minor_number; +static constexpr StringView partition_uuid_prefix = "PARTUUID="sv; + UNMAP_AFTER_INIT StorageManagement::StorageManagement() { } @@ -36,7 +39,7 @@ void StorageManagement::remove_device(StorageDevice& device) bool StorageManagement::boot_argument_contains_partition_uuid() { - return m_boot_argument.starts_with("PARTUUID="); + return m_boot_argument.starts_with(partition_uuid_prefix); } UNMAP_AFTER_INIT void StorageManagement::enumerate_controllers(bool force_pio) @@ -120,7 +123,7 @@ UNMAP_AFTER_INIT void StorageManagement::enumerate_disk_partitions() const UNMAP_AFTER_INIT void StorageManagement::determine_boot_device() { VERIFY(!m_controllers.is_empty()); - if (m_boot_argument.starts_with("/dev/")) { + if (m_boot_argument.starts_with("/dev/"sv)) { StringView storage_name = m_boot_argument.substring_view(5); for (auto& storage_device : m_storage_devices) { if (storage_device.storage_name() == storage_name) { @@ -137,9 +140,9 @@ UNMAP_AFTER_INIT void StorageManagement::determine_boot_device() UNMAP_AFTER_INIT void StorageManagement::determine_boot_device_with_partition_uuid() { VERIFY(!m_storage_devices.is_empty()); - VERIFY(m_boot_argument.starts_with("PARTUUID=")); + VERIFY(m_boot_argument.starts_with(partition_uuid_prefix)); - auto partition_uuid = UUID(m_boot_argument.substring_view(strlen("PARTUUID="))); + auto partition_uuid = UUID(m_boot_argument.substring_view(partition_uuid_prefix.length())); if (partition_uuid.to_string().length() != 36) { PANIC("StorageManagement: Specified partition UUID is not valid"); @@ -189,7 +192,7 @@ NonnullRefPtr StorageManagement::root_filesystem() const return file_system; } -UNMAP_AFTER_INIT void StorageManagement::initialize(String root_device, bool force_pio) +UNMAP_AFTER_INIT void StorageManagement::initialize(StringView root_device, bool force_pio) { VERIFY(s_device_minor_number == 0); m_boot_argument = root_device; diff --git a/Kernel/Storage/StorageManagement.h b/Kernel/Storage/StorageManagement.h index b648110836..656a5f5a71 100644 --- a/Kernel/Storage/StorageManagement.h +++ b/Kernel/Storage/StorageManagement.h @@ -24,7 +24,7 @@ class StorageManagement { public: StorageManagement(); static bool initialized(); - void initialize(String boot_argument, bool force_pio); + void initialize(StringView boot_argument, bool force_pio); static StorageManagement& the(); NonnullRefPtr root_filesystem() const; @@ -48,7 +48,7 @@ private: RefPtr boot_block_device() const; - String m_boot_argument; + StringView m_boot_argument; WeakPtr m_boot_block_device; NonnullRefPtrVector m_controllers; IntrusiveList<&StorageDevice::m_list_node> m_storage_devices;