]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
cppcheck: const cleanups (partial)
authorTulio A M Mendes <[email protected]>
Sun, 8 Feb 2026 07:14:56 +0000 (04:14 -0300)
committerTulio A M Mendes <[email protected]>
Sun, 8 Feb 2026 07:14:56 +0000 (04:14 -0300)
src/arch/x86/arch_early_setup.c
src/arch/x86/arch_platform.c
src/arch/x86/vmm.c
src/kernel/scheduler.c
src/kernel/shell.c

index 5d16980250fadc086275d9b3319efb54b0b02a34..866e5b25dccc5cda6de33fbd97bea3a0cffa8cd0 100644 (file)
@@ -70,13 +70,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;
             }
         }
index 711c6fcd201f0025d2d4542b40a4ecbd32ecef35..678fe06a8db5db65758865a5cfd316df503b9c6a 100644 (file)
@@ -97,7 +97,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
index d45e21716d49ea53d3b9d3bde9def6cf1447b916..4797b4a2ac574c918fb3ad7145816b6aa883b709 100644 (file)
@@ -133,7 +133,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++) {
@@ -141,7 +141,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];
@@ -229,7 +229,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;
@@ -263,7 +263,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);
index 027bfb0e1d32b83709467c0915be0ef0bb4a8980..df587babdea8960b5e5df691ed6d9fe758d4d1b4 100644 (file)
@@ -36,7 +36,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;
index f7a0a95f9ac7de64a4a6ea4289bbc00532e4fb67..d971f07aa3bbe2f50802cfecee8ed2b2d6e718c2 100644 (file)
@@ -55,7 +55,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);