diff options
author | Brian Gianforcaro <bgianf@serenityos.org> | 2021-09-12 08:17:31 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-12 18:24:15 +0200 |
commit | a61857eb0a5ad6adf27fc8451cd38bf16a575fd2 (patch) | |
tree | 858c0ff8e4c94dcae68271f3b336d36b36f6f669 /Kernel/Thread.cpp | |
parent | 2afa28d297bb2660fe8cba309b25c6384626bf7b (diff) | |
download | serenity-a61857eb0a5ad6adf27fc8451cd38bf16a575fd2.zip |
Kernel: Use AK::to_underlying in lock rank tracking
AK::to_underlying simplifies the code a bit, instead of having to
manually cast to the underlying type.
Diffstat (limited to 'Kernel/Thread.cpp')
-rw-r--r-- | Kernel/Thread.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index 4de3f03ccf..aa9d116289 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -1246,13 +1246,11 @@ void Thread::track_lock_release(LockRank rank) if (rank == LockRank::None) return; - using PrimitiveType = UnderlyingType<LockRank>; - // The rank value from the caller should only contain a single bit, otherwise // we are disabling the tracking for multiple locks at once which will corrupt // the lock tracking mask, and we will assert somewhere else. auto rank_is_a_single_bit = [](auto rank_enum) -> bool { - auto rank = static_cast<PrimitiveType>(rank_enum); + auto rank = to_underlying(rank_enum); auto rank_without_least_significant_bit = rank - 1; return (rank & rank_without_least_significant_bit) == 0; }; @@ -1263,8 +1261,8 @@ void Thread::track_lock_release(LockRank rank) // mask. If the rank we are releasing is truly the highest rank then the mask // we get back will be equal to the current mask of stored on the thread. auto rank_is_in_order = [](auto mask_enum, auto rank_enum) -> bool { - auto mask = static_cast<PrimitiveType>(mask_enum); - auto rank = static_cast<PrimitiveType>(rank_enum); + auto mask = to_underlying(mask_enum); + auto rank = to_underlying(rank_enum); auto mask_without_least_significant_bit = mask - 1; return ((mask & mask_without_least_significant_bit) | rank) == mask; }; |