From 9c3de597257be9911a5eeb86c33962b15d87a701 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 1 Dec 2025 02:15:17 -0500 Subject: chore: add kInvalidType, remove redundant keywords in ce_ddk_is_valid, and sys_constexpr_cast. Signed-off-by: Amlal El Mahrouss --- src/libDDK/DriverKit/c++/driver_base.h | 8 +++++--- src/libSystem/SystemKit/Verify.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/libDDK/DriverKit/c++/driver_base.h b/src/libDDK/DriverKit/c++/driver_base.h index c130ba8b..97f07f2a 100644 --- a/src/libDDK/DriverKit/c++/driver_base.h +++ b/src/libDDK/DriverKit/c++/driver_base.h @@ -20,6 +20,8 @@ /// @author Amlal El Mahrouss namespace Kernel::DDK { +constexpr auto kInvalidType = 0; + class IDriverBase { public: explicit IDriverBase() = default; @@ -32,17 +34,17 @@ class IDriverBase { virtual BOOL IsCastable() { return NO; } virtual constexpr BOOL IsActive() { return NO; } virtual PtrType Leak() { return nullptr; } - virtual constexpr Int32 Type() { return 0; } + virtual constexpr Int32 Type() { return kInvalidType; } }; /// @brief This concept requires the Driver to be IDriverBase compliant. template concept IsValidDriver = requires(T driver_base) { - { driver_base.IsActive() && driver_base.Type() > 0 }; + { driver_base.IsActive() && driver_base.Type() > kInvalidType }; }; /// @brief Consteval helper to detect whether a template is truly based on IDriverBase. /// @note This helper is consteval only. template -inline consteval void ce_ddk_is_valid(T) {} +consteval void ce_ddk_is_valid(T) {} } // namespace Kernel::DDK diff --git a/src/libSystem/SystemKit/Verify.h b/src/libSystem/SystemKit/Verify.h index 7d15435a..b99dbecc 100644 --- a/src/libSystem/SystemKit/Verify.h +++ b/src/libSystem/SystemKit/Verify.h @@ -33,7 +33,7 @@ struct must_cast_traits { /// @author Amlal El Mahrouss /// @brief Safe constexpr cast. template -inline constexpr R* sys_constexpr_cast(T* ptr) { +constexpr R* sys_constexpr_cast(T* ptr) { static_assert(must_cast_traits::value, "constexpr cast failed! types are mismatching!"); return static_cast(ptr); } -- cgit v1.2.3