From 23c479c41150102ad9d6414c71b4c341558ff5bf Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Thu, 13 Jan 2022 17:53:22 +0500 Subject: [PATCH] Add macro KERNAUX_MULTIBOOT2_TAG_NEXT --- include/kernaux/multiboot2.h | 3 +++ src/multiboot2/header_helpers.c | 4 ++-- src/multiboot2/info_helpers.c | 4 ++-- src/multiboot2/info_is_valid.c | 3 +-- src/multiboot2/info_print.c | 3 +-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/kernaux/multiboot2.h b/include/kernaux/multiboot2.h index 856bf05..b3424b8 100644 --- a/include/kernaux/multiboot2.h +++ b/include/kernaux/multiboot2.h @@ -11,6 +11,9 @@ extern "C" { #define KERNAUX_MULTIBOOT2_MAGIC 0x36d76289 #define KERNAUX_MULTIBOOT2_DATA(ptr) (((uint8_t*)(ptr)) + sizeof(*(ptr))) + +#define KERNAUX_MULTIBOOT2_TAG_NEXT(tag_base) \ + ((uint8_t*)tag_base + KERNAUX_MULTIBOOT2_TAG_SIZE_ALIGN(tag_base)) #define KERNAUX_MULTIBOOT2_TAG_SIZE_ALIGN(tag_base) \ (((tag_base)->size + 7) & ~7) diff --git a/src/multiboot2/header_helpers.c b/src/multiboot2/header_helpers.c index 764fa4b..c077fcf 100644 --- a/src/multiboot2/header_helpers.c +++ b/src/multiboot2/header_helpers.c @@ -25,7 +25,7 @@ const struct KernAux_Multiboot2_HTagBase if (tag_base->type == tag_type) return tag_base; tag_base = (struct KernAux_Multiboot2_HTagBase*)( - (uint8_t*)tag_base + KERNAUX_MULTIBOOT2_TAG_SIZE_ALIGN(tag_base) + KERNAUX_MULTIBOOT2_TAG_NEXT(tag_base) ); } @@ -51,7 +51,7 @@ const struct KernAux_Multiboot2_HTagBase if (tag_base->type == tag_type && tag_base > after_tag) return tag_base; tag_base = (struct KernAux_Multiboot2_HTagBase*)( - (uint8_t*)tag_base + KERNAUX_MULTIBOOT2_TAG_SIZE_ALIGN(tag_base) + KERNAUX_MULTIBOOT2_TAG_NEXT(tag_base) ); } diff --git a/src/multiboot2/info_helpers.c b/src/multiboot2/info_helpers.c index 2496e59..767216c 100644 --- a/src/multiboot2/info_helpers.c +++ b/src/multiboot2/info_helpers.c @@ -24,7 +24,7 @@ const struct KernAux_Multiboot2_ITagBase if (tag_base->type == tag_type) return tag_base; tag_base = (struct KernAux_Multiboot2_ITagBase*)( - (uint8_t*)tag_base + KERNAUX_MULTIBOOT2_TAG_SIZE_ALIGN(tag_base) + KERNAUX_MULTIBOOT2_TAG_NEXT(tag_base) ); } @@ -49,7 +49,7 @@ const struct KernAux_Multiboot2_ITagBase if (tag_base->type == tag_type && tag_base > after_tag) return tag_base; tag_base = (struct KernAux_Multiboot2_ITagBase*)( - (uint8_t*)tag_base + KERNAUX_MULTIBOOT2_TAG_SIZE_ALIGN(tag_base) + KERNAUX_MULTIBOOT2_TAG_NEXT(tag_base) ); } diff --git a/src/multiboot2/info_is_valid.c b/src/multiboot2/info_is_valid.c index c3934a9..459f3d2 100644 --- a/src/multiboot2/info_is_valid.c +++ b/src/multiboot2/info_is_valid.c @@ -30,8 +30,7 @@ bool KernAux_Multiboot2_Info_is_valid( } tag_base = (struct KernAux_Multiboot2_ITagBase*)( - (unsigned char*)tag_base + - KERNAUX_MULTIBOOT2_TAG_SIZE_ALIGN(tag_base) + KERNAUX_MULTIBOOT2_TAG_NEXT(tag_base) ); } diff --git a/src/multiboot2/info_print.c b/src/multiboot2/info_print.c index b939145..03c4211 100644 --- a/src/multiboot2/info_print.c +++ b/src/multiboot2/info_print.c @@ -94,8 +94,7 @@ void KernAux_Multiboot2_Info_print( KernAux_Multiboot2_ITagBase_print(tag_base, printf); tag_base = (struct KernAux_Multiboot2_ITagBase*)( - (unsigned char*)tag_base + - KERNAUX_MULTIBOOT2_TAG_SIZE_ALIGN(tag_base) + KERNAUX_MULTIBOOT2_TAG_NEXT(tag_base) ); } }