luna, kernel: Replace some uses of char by truly 1-byte wide types
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-01-16 19:52:34 +01:00
parent 329e8ab182
commit 1d92784608
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 5 additions and 7 deletions

View File

@ -433,7 +433,7 @@ namespace MemoryManager
uintptr_t user_ptr = (uintptr_t)user;
uintptr_t user_page = align_down<ARCH_PAGE_SIZE>(user_ptr);
const char* kernel_ptr = (const char*)kernel;
const u8* kernel_ptr = (const u8*)kernel;
// Userspace pointer not aligned on page boundary
if (user_ptr != user_page)
@ -449,7 +449,7 @@ namespace MemoryManager
if (!validate_user_writable_page(user_ptr)) return false;
}
*(char*)user_ptr = *kernel_ptr++;
*(u8*)user_ptr = *kernel_ptr++;
user_ptr++;
}
@ -461,7 +461,7 @@ namespace MemoryManager
uintptr_t user_ptr = (uintptr_t)user;
uintptr_t user_page = align_down<ARCH_PAGE_SIZE>(user_ptr);
char* kernel_ptr = (char*)kernel;
u8* kernel_ptr = (u8*)kernel;
// Userspace pointer not aligned on page boundary
if (user_ptr != user_page)
@ -477,7 +477,7 @@ namespace MemoryManager
if (!validate_user_readable_page(user_ptr)) return false;
}
*kernel_ptr++ = *(const char*)user_ptr;
*kernel_ptr++ = *(const u8*)user_ptr;
user_ptr++;
}

View File

@ -49,7 +49,5 @@ static_assert(get_blocks_from_size(0, 256) == 0);
// arithmetic.
template <typename T, typename Offset> constexpr T* offset_ptr(T* ptr, Offset offset)
{
// FIXME: The C standard does not mandate that char be 1 byte. This function (and probably many others) rely on that
// assumption.
return (T*)((char*)ptr + offset);
return (T*)((u8*)ptr + offset);
}