From 6ae60137d78aa2934625e19643dbd24d39687ce4 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 29 Aug 2021 02:07:57 +0200 Subject: [PATCH] Kernel: Use StringView instead of C strings in Mutex --- Kernel/Locking/Mutex.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Kernel/Locking/Mutex.h b/Kernel/Locking/Mutex.h index 481c8fc9fa..f64153f63f 100644 --- a/Kernel/Locking/Mutex.h +++ b/Kernel/Locking/Mutex.h @@ -26,7 +26,7 @@ class Mutex { public: using Mode = LockMode; - Mutex(const char* name = nullptr) + Mutex(StringView name = {}) : m_name(name) { } @@ -52,19 +52,19 @@ public: return false; } - [[nodiscard]] const char* name() const { return m_name; } + [[nodiscard]] StringView name() const { return m_name; } - static const char* mode_to_string(Mode mode) + static StringView mode_to_string(Mode mode) { switch (mode) { case Mode::Unlocked: - return "unlocked"; + return "unlocked"sv; case Mode::Exclusive: - return "exclusive"; + return "exclusive"sv; case Mode::Shared: - return "shared"; + return "shared"sv; default: - return "invalid"; + return "invalid"sv; } } @@ -80,7 +80,7 @@ private: void block(Thread&, Mode, SpinlockLocker>&, u32); void unblock_waiters(Mode); - const char* m_name { nullptr }; + StringView m_name; Mode m_mode { Mode::Unlocked }; // When locked exclusively, only the thread already holding the lock can