OcGuardLib: Use STATIC_ASSERT over typedef hacks

This commit is contained in:
Download-Fritz 2019-11-30 15:33:57 +01:00
parent 469cc6ef33
commit be4f601d9e

View File

@ -16,19 +16,24 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Base.h>
#include <Library/OcGuardLib.h>
//
// 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) (