grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: "Vladimir 'phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: [PATCH 4/4] gpt: Add compile time asserts for guid and gpt_partentry sizes
Date: Tue, 31 Oct 2023 20:35:58 +0100	[thread overview]
Message-ID: <CAEaD8JPmmk+bu4mxTFGyOC0w-nas28RgBM=_5BYAqABUm0A15A@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 257 bytes --]

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 <phcoder@gmail.com>

-- 
Regards
Vladimir 'phcoder' Serbinenko

[-- Attachment #2: 0004-gpt-Add-compile-time-asserts-for-guid-and-gpt_parten.patch --]
[-- Type: text/x-patch, Size: 1041 bytes --]

From 6a4e58a9fe989dbe0f6b3ef9865cab05a55ac19a Mon Sep 17 00:00:00 2001
From: Vladimir Serbinenko <phcoder@gmail.com>
Date: Sun, 13 Aug 2023 09:18:53 +0200
Subject: [PATCH 4/4] 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 <phcoder@gmail.com>
---
 grub-core/partmap/gpt.c | 3 +++
 1 file changed, 3 insertions(+)

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);
 }
 
-- 
2.39.2


[-- Attachment #3: Type: text/plain, Size: 141 bytes --]

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

             reply	other threads:[~2023-10-31 19:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-31 19:35 Vladimir 'phcoder' Serbinenko [this message]
2023-10-31 21:44 ` [PATCH 4/4] gpt: Add compile time asserts for guid and gpt_partentry sizes John Paul Adrian Glaubitz
  -- strict thread matches above, loose matches on Subject: below --
2023-10-07 15:08 Vladimir 'phcoder' Serbinenko
2023-10-17 16:43 ` Daniel Kiper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEaD8JPmmk+bu4mxTFGyOC0w-nas28RgBM=_5BYAqABUm0A15A@mail.gmail.com' \
    --to=phcoder@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).