From: Vladimir Serbinenko Date: Sun, 13 Aug 2023 07:18:53 +0000 (+0200) Subject: gpt: Add compile time asserts for guid and gpt_partentry sizes X-Git-Tag: grub-2.12~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64e3cee72ab8f5876abfebb263b5e6cf7c4a9a4e;p=thirdparty%2Fgrub.git gpt: Add compile time asserts for guid and gpt_partentry sizes With new alignment specification it's easy to screw up. Fortunately if it happens the size will be bigger than intended. Compile time assert will catch this. Signed-off-by: Vladimir Serbinenko Reviewed-by: Daniel Kiper --- diff --git a/grub-core/partmap/gpt.c b/grub-core/partmap/gpt.c index 877ceefc3..426f616ae 100644 --- a/grub-core/partmap/gpt.c +++ b/grub-core/partmap/gpt.c @@ -229,6 +229,9 @@ static struct grub_partition_map grub_gpt_partition_map = GRUB_MOD_INIT(part_gpt) { + COMPILE_TIME_ASSERT(sizeof(grub_guid_t) == 16); + COMPILE_TIME_ASSERT(sizeof(grub_packed_guid_t) == 16); + COMPILE_TIME_ASSERT(sizeof(struct grub_gpt_partentry) == 128); grub_partition_map_register (&grub_gpt_partition_map); }