[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH RFC] mb2 loader: Use the same iteration code for MB2 as for MB1
From: |
Hans Ulrich Niedermann |
Subject: |
[PATCH RFC] mb2 loader: Use the same iteration code for MB2 as for MB1 |
Date: |
Sat, 23 May 2020 22:19:23 +0200 |
This avoids the divisions by 4 to compensate for using an
array of 32bit values instead of bytes in MB2 find_header(),
just like the MB1 find_header() does it.
Also uses the same principle for iterating through the MB2
header tags.
Why not use the same code for iterating over memory locations in
the Multiboot 2 loader as we do in the Multiboot 1 loader?
diff --git a/grub-core/loader/multiboot_mbi2.c
b/grub-core/loader/multiboot_mbi2.c
index 026109e69..38ddea088 100644
--- a/grub-core/loader/multiboot_mbi2.c
+++ b/grub-core/loader/multiboot_mbi2.c
@@ -95,7 +95,7 @@ find_header (grub_properly_aligned_t *buffer, grub_ssize_t
len)
magic plus terminator tag) and aligned on an 8-byte boundary. */
for (header = (struct multiboot_header *) buffer;
((char *) header <= (char *) buffer + len - 24);
- header = (struct multiboot_header *) ((grub_uint32_t *) header +
MULTIBOOT_HEADER_ALIGN / 4))
+ header = (struct multiboot_header *) ((char *) header +
MULTIBOOT_HEADER_ALIGN))
{
if (header->magic == MULTIBOOT2_HEADER_MAGIC
&& !(header->magic + header->architecture
@@ -152,7 +152,7 @@ grub_multiboot2_load (grub_file_t file, const char
*filename)
for (tag = (struct multiboot_header_tag *) (header + 1);
tag->type != MULTIBOOT_TAG_TYPE_END;
- tag = (struct multiboot_header_tag *) ((grub_uint32_t *) tag + ALIGN_UP
(tag->size, MULTIBOOT_TAG_ALIGN) / 4))
+ tag = (struct multiboot_header_tag *) ((char *) tag + ALIGN_UP
(tag->size, MULTIBOOT_TAG_ALIGN)))
switch (tag->type)
{
case MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST:
--
2.26.2