diff options
author | Rainer Deyke <rainerd@eldwood.com> | 2022-04-04 14:55:41 +0200 |
---|---|---|
committer | Rainer Deyke <rainerd@eldwood.com> | 2022-04-04 14:57:04 +0200 |
commit | 56ae5bbafbbb19dd8cecfec1e5f52b3511ee4fc2 (patch) | |
tree | f0de031a8bf92145188b90d06121ea933b2780b3 /core/os | |
parent | 2907ca3a4160efd9e8afe1f636f87df5e6964134 (diff) |
Fixed unsafe casts
Diffstat (limited to 'core/os')
-rw-r--r-- | core/os/keyboard.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/core/os/keyboard.h b/core/os/keyboard.h index 9464f4305a..556ba3638e 100644 --- a/core/os/keyboard.h +++ b/core/os/keyboard.h @@ -315,7 +315,8 @@ constexpr Key operator-(uint32_t a, Key b) { } constexpr Key &operator-=(Key &a, int b) { - return (Key &)((int &)a -= b); + a = static_cast<Key>(static_cast<int>(a) - static_cast<int>(b)); + return a; } constexpr Key operator+(Key a, int b) { @@ -339,15 +340,18 @@ constexpr Key operator|(Key a, Key b) { } constexpr Key &operator|=(Key &a, Key b) { - return (Key &)((int &)a |= (int)b); + a = static_cast<Key>(static_cast<int>(a) | static_cast<int>(b)); + return a; } constexpr Key &operator|=(Key &a, KeyModifierMask b) { - return (Key &)((int &)a |= (int)b); + a = static_cast<Key>(static_cast<int>(a) | static_cast<int>(b)); + return a; } constexpr Key &operator&=(Key &a, KeyModifierMask b) { - return (Key &)((int &)a &= (int)b); + a = static_cast<Key>(static_cast<int>(a) & static_cast<int>(b)); + return a; } constexpr Key operator|(Key a, KeyModifierMask b) { |