From be4f601d9e35a4fb3a209c39d772bbbd6aae9db1 Mon Sep 17 00:00:00 2001 From: Download-Fritz Date: Sat, 30 Nov 2019 15:33:57 +0100 Subject: [PATCH] OcGuardLib: Use STATIC_ASSERT over typedef hacks --- Library/OcGuardLib/NativeOverflow.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Library/OcGuardLib/NativeOverflow.c b/Library/OcGuardLib/NativeOverflow.c index a5c0146b..edad4054 100644 --- a/Library/OcGuardLib/NativeOverflow.c +++ b/Library/OcGuardLib/NativeOverflow.c @@ -16,19 +16,24 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ +#include + #include // // Currently no architectures provide UINTN and INTN different from 32-bit or 64-bit // integers. For this reason they are the only variants supported and are enforced here. -// The lib must be C99-compliant, thus no _Static_assert. // -typedef BOOLEAN SignedIntnMustBe32or64[sizeof (INTN) == sizeof (INT64) - || sizeof (INTN) == sizeof (INT32) ? 1 : -1]; +STATIC_ASSERT ( + sizeof (INTN) == sizeof (INT64) || sizeof (INTN) == sizeof (INT32), + "INTN must be 32 or 64 Bits wide." + ); -typedef BOOLEAN UnsignedIntnMustBe32or64[sizeof (UINTN) == sizeof (UINT64) - || sizeof (UINTN) == sizeof (UINT32) ? 1 : -1]; +STATIC_ASSERT ( + sizeof (UINTN) == sizeof (UINT64) || sizeof (UINTN) == sizeof (UINT32), + "UINTN must be 32 or 64 Bits wide." + ); BOOLEAN (OcOverflowAddUN) (