diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-01 02:15:17 -0500 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-01 02:15:17 -0500 |
| commit | 9c3de597257be9911a5eeb86c33962b15d87a701 (patch) | |
| tree | d6ddc16fd59d851a093700bad8dd8baca1c914dc /src | |
| parent | d3892e80f787f86062733bd8ad3e725fb548d6fe (diff) | |
chore: add kInvalidType, remove redundant keywords in ce_ddk_is_valid, and sys_constexpr_cast.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/libDDK/DriverKit/c++/driver_base.h | 8 | ||||
| -rw-r--r-- | src/libSystem/SystemKit/Verify.h | 2 |
2 files changed, 6 insertions, 4 deletions
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 <typename T> 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 <IsValidDriver T> -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<T, T> { /// @author Amlal El Mahrouss /// @brief Safe constexpr cast. template <typename T, typename R> -inline constexpr R* sys_constexpr_cast(T* ptr) { +constexpr R* sys_constexpr_cast(T* ptr) { static_assert(must_cast_traits<T, R>::value, "constexpr cast failed! types are mismatching!"); return static_cast<R*>(ptr); } |
