From 56ae5bbafbbb19dd8cecfec1e5f52b3511ee4fc2 Mon Sep 17 00:00:00 2001 From: Rainer Deyke Date: Mon, 4 Apr 2022 14:55:41 +0200 Subject: [PATCH] Fixed unsafe casts --- core/os/keyboard.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/core/os/keyboard.h b/core/os/keyboard.h index 9464f4305aa..556ba3638e2 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(static_cast(a) - static_cast(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(static_cast(a) | static_cast(b)); + return a; } constexpr Key &operator|=(Key &a, KeyModifierMask b) { - return (Key &)((int &)a |= (int)b); + a = static_cast(static_cast(a) | static_cast(b)); + return a; } constexpr Key &operator&=(Key &a, KeyModifierMask b) { - return (Key &)((int &)a &= (int)b); + a = static_cast(static_cast(a) & static_cast(b)); + return a; } constexpr Key operator|(Key a, KeyModifierMask b) {