mirror of
https://github.com/tailix/libkernaux.git
synced 2025-04-07 17:32:45 -04:00
Fix compiler warnings
This commit is contained in:
parent
5b3fd3fbf1
commit
e2c29728a4
5 changed files with 29 additions and 17 deletions
|
@ -32,11 +32,7 @@ bool KernAux_ELF_Header_is_valid(
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!(
|
||||
header->os_abi >= 0 &&
|
||||
header->os_abi <= 0x12 &&
|
||||
header->os_abi != 0x05
|
||||
)) {
|
||||
if (!(header->os_abi <= 0x12 && header->os_abi != 0x05)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,12 +13,15 @@ const struct KernAux_Multiboot2_TagBase *KernAux_Multiboot2_first_tag_with_type(
|
|||
const struct KernAux_Multiboot2_TagBase *tag_base =
|
||||
(struct KernAux_Multiboot2_TagBase*)multiboot2->data;
|
||||
|
||||
while ((void*)tag_base < (void*)multiboot2 + multiboot2->total_size) {
|
||||
while (tag_base <
|
||||
(struct KernAux_Multiboot2_TagBase*)
|
||||
((unsigned char*)multiboot2 + multiboot2->total_size))
|
||||
{
|
||||
if (!KernAux_Multiboot2_TagBase_is_valid(tag_base)) return NULL;
|
||||
if (tag_base->type == tag_type) return tag_base;
|
||||
|
||||
tag_base = (struct KernAux_Multiboot2_TagBase*)(
|
||||
(void*)tag_base + ((tag_base->size + 7) & ~7)
|
||||
(unsigned char*)tag_base + ((tag_base->size + 7) & ~7)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -33,12 +36,15 @@ const struct KernAux_Multiboot2_TagBase *KernAux_Multiboot2_tag_with_type_after(
|
|||
const struct KernAux_Multiboot2_TagBase *tag_base =
|
||||
(struct KernAux_Multiboot2_TagBase*)multiboot2->data;
|
||||
|
||||
while ((void*)tag_base < (void*)multiboot2 + multiboot2->total_size) {
|
||||
while (tag_base <
|
||||
(struct KernAux_Multiboot2_TagBase*)
|
||||
(unsigned char*)multiboot2 + multiboot2->total_size)
|
||||
{
|
||||
if (!KernAux_Multiboot2_TagBase_is_valid(tag_base)) return NULL;
|
||||
if (tag_base->type == tag_type && tag_base > after_tag) return tag_base;
|
||||
|
||||
tag_base = (struct KernAux_Multiboot2_TagBase*)(
|
||||
(void*)tag_base + ((tag_base->size + 7) & ~7)
|
||||
(unsigned char*)tag_base + ((tag_base->size + 7) & ~7)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,10 @@ bool KernAux_Multiboot2_is_valid(
|
|||
|
||||
const struct KernAux_Multiboot2_TagBase *none_tag_base = NULL;
|
||||
|
||||
while ((void*)tag_base < (void*)multiboot2 + multiboot2->total_size) {
|
||||
while (tag_base <
|
||||
(struct KernAux_Multiboot2_TagBase*)
|
||||
((unsigned char*)multiboot2 + multiboot2->total_size))
|
||||
{
|
||||
if (!KernAux_Multiboot2_TagBase_is_valid(tag_base)) return false;
|
||||
|
||||
if (tag_base->type == KERNAUX_MULTIBOOT2_TAGTYPE_NONE &&
|
||||
|
@ -26,17 +29,21 @@ bool KernAux_Multiboot2_is_valid(
|
|||
}
|
||||
|
||||
tag_base = (struct KernAux_Multiboot2_TagBase*)(
|
||||
(void*)tag_base + ((tag_base->size + 7) & ~7)
|
||||
(unsigned char*)tag_base + ((tag_base->size + 7) & ~7)
|
||||
);
|
||||
}
|
||||
|
||||
if ((void*)tag_base != (void*)multiboot2 + multiboot2->total_size) {
|
||||
if (tag_base !=
|
||||
(struct KernAux_Multiboot2_TagBase*)
|
||||
((unsigned char*)multiboot2 + multiboot2->total_size))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (none_tag_base !=
|
||||
(void*)tag_base - sizeof(struct KernAux_Multiboot2_Tag_None)
|
||||
) {
|
||||
(struct KernAux_Multiboot2_TagBase*)
|
||||
((unsigned char*)tag_base - sizeof(struct KernAux_Multiboot2_Tag_None)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -86,13 +86,16 @@ void KernAux_Multiboot2_print(
|
|||
const struct KernAux_Multiboot2_TagBase *tag_base =
|
||||
(struct KernAux_Multiboot2_TagBase*)multiboot2->data;
|
||||
|
||||
while ((void*)tag_base < (void*)multiboot2 + multiboot2->total_size) {
|
||||
while (tag_base <
|
||||
(struct KernAux_Multiboot2_TagBase*)
|
||||
((unsigned char*)multiboot2 + multiboot2->total_size))
|
||||
{
|
||||
if (!KernAux_Multiboot2_TagBase_is_valid(tag_base)) return;
|
||||
|
||||
KernAux_Multiboot2_TagBase_print(tag_base, printf);
|
||||
|
||||
tag_base = (struct KernAux_Multiboot2_TagBase*)(
|
||||
(void*)tag_base + ((tag_base->size + 7) & ~7)
|
||||
(unsigned char*)tag_base + ((tag_base->size + 7) & ~7)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ int main(int argc, char **argv)
|
|||
const size_t size = fread(buffer, sizeof(unsigned char), BUFFER_SIZE, fd);
|
||||
assert(size > 0);
|
||||
|
||||
assert(KernAux_ELF_Header_is_valid(buffer));
|
||||
assert(KernAux_ELF_Header_is_valid((struct KernAux_ELF_Header*)buffer));
|
||||
|
||||
fclose(fd);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue