From: Tulio A M Mendes Date: Sun, 8 Feb 2026 07:14:56 +0000 (-0300) Subject: cppcheck: const cleanups (partial) X-Git-Url: https://projects.tadryanom.me/sitemap.xml?a=commitdiff_plain;h=48e6dd09e741907d26d086cd81bb7a240073af0c;p=AdrOS.git cppcheck: const cleanups (partial) --- diff --git a/src/arch/x86/arch_early_setup.c b/src/arch/x86/arch_early_setup.c index 10eae7a..f18dfe4 100644 --- a/src/arch/x86/arch_early_setup.c +++ b/src/arch/x86/arch_early_setup.c @@ -61,13 +61,13 @@ static uint32_t multiboot_copy_size; tag->type != MULTIBOOT_TAG_TYPE_END; tag = (struct multiboot_tag*)((uint8_t*)tag + ((tag->size + 7) & ~7))) { if (tag->type == MULTIBOOT_TAG_TYPE_MODULE) { - struct multiboot_tag_module* mod = (struct multiboot_tag_module*)tag; + const struct multiboot_tag_module* mod = (const struct multiboot_tag_module*)tag; bi.initrd_start = mod->mod_start; bi.initrd_end = mod->mod_end; break; } if (tag->type == MULTIBOOT_TAG_TYPE_CMDLINE) { - struct multiboot_tag_string* s = (struct multiboot_tag_string*)tag; + const struct multiboot_tag_string* s = (const struct multiboot_tag_string*)tag; bi.cmdline = s->string; } } diff --git a/src/arch/x86/arch_platform.c b/src/arch/x86/arch_platform.c index 0999272..5d8580a 100644 --- a/src/arch/x86/arch_platform.c +++ b/src/arch/x86/arch_platform.c @@ -88,7 +88,7 @@ int arch_platform_setup(const struct boot_info* bi) { int arch_platform_start_userspace(const struct boot_info* bi) { (void)bi; #if defined(__i386__) - struct process* p = process_create_kernel(userspace_init_thread); + const struct process* p = process_create_kernel(userspace_init_thread); if (!p) return -1; return 0; #else diff --git a/src/arch/x86/vmm.c b/src/arch/x86/vmm.c index 7d91f96..9745545 100644 --- a/src/arch/x86/vmm.c +++ b/src/arch/x86/vmm.c @@ -124,7 +124,7 @@ uintptr_t vmm_as_clone_user(uintptr_t src_as) { return 0; } - uint32_t* src_pd = (uint32_t*)P2V((uint32_t)src_as); + const uint32_t* src_pd = (const uint32_t*)P2V((uint32_t)src_as); // Best-effort clone: copy present user mappings (USER PTEs), ignore kernel half. for (uint32_t pdi = 0; pdi < 768; pdi++) { @@ -132,7 +132,7 @@ uintptr_t vmm_as_clone_user(uintptr_t src_as) { if (!(pde & X86_PTE_PRESENT)) continue; uint32_t src_pt_phys = pde & 0xFFFFF000; - uint32_t* src_pt = (uint32_t*)P2V(src_pt_phys); + const uint32_t* src_pt = (const uint32_t*)P2V(src_pt_phys); for (uint32_t pti = 0; pti < 1024; pti++) { uint32_t pte = src_pt[pti]; @@ -220,7 +220,7 @@ void vmm_set_page_flags(uint64_t virt, uint32_t flags) { uint32_t pd_index = virt >> 22; uint32_t pt_index = (virt >> 12) & 0x03FF; - uint32_t* pd = vmm_active_pd_virt(); + const uint32_t* pd = vmm_active_pd_virt(); if (!(pd[pd_index] & X86_PTE_PRESENT)) { return; @@ -254,7 +254,7 @@ void vmm_unmap_page(uint64_t virt) { uint32_t pd_index = virt >> 22; uint32_t pt_index = (virt >> 12) & 0x03FF; - uint32_t* pd = vmm_active_pd_virt(); + const uint32_t* pd = vmm_active_pd_virt(); if (pd[pd_index] & X86_PTE_PRESENT) { uint32_t pt_phys = pd[pd_index] & 0xFFFFF000; uint32_t* pt = (uint32_t*)P2V(pt_phys); diff --git a/src/kernel/scheduler.c b/src/kernel/scheduler.c index 0b4f367..1934dfc 100644 --- a/src/kernel/scheduler.c +++ b/src/kernel/scheduler.c @@ -27,7 +27,7 @@ static struct process* process_find_locked(uint32_t pid) { if (!ready_queue_head) return NULL; struct process* it = ready_queue_head; - struct process* start = it; + const struct process* const start = it; do { if (it->pid == pid) return it; it = it->next; diff --git a/src/kernel/shell.c b/src/kernel/shell.c index cd38db5..42c6cc8 100644 --- a/src/kernel/shell.c +++ b/src/kernel/shell.c @@ -46,7 +46,7 @@ void execute_command(char* cmd) { if (!fs_root) { uart_print("No filesystem mounted.\n"); } else { - char* fname = cmd + 4; + const char* fname = cmd + 4; fs_node_t* file = NULL; if (fname[0] == '/') { file = vfs_lookup(fname);