]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
cppcheck: fix unreadVariable in elf.c and sync.c
authorTulio A M Mendes <[email protected]>
Mon, 27 Apr 2026 01:59:00 +0000 (22:59 -0300)
committerTulio A M Mendes <[email protected]>
Mon, 27 Apr 2026 01:59:00 +0000 (22:59 -0300)
- elf.c: remove dead seg_vmm_flags computation from elf32_load_segments
  (re-protection is done by elf32_reprotect_segments after relocations)
- sync.c: eliminate unused deadline variable, inline into wake_at_tick

Tests: 120/120 QEMU, 33/33 battery, 69/69 host

src/arch/x86/elf.c
src/kernel/sync.c

index dfc23061cd85ea468895661d8945832e7feca3d6..288426552261eadcc80857e6d47ad2f67e0eec64 100644 (file)
@@ -144,12 +144,9 @@ static int elf32_load_segments(const uint8_t* file, uint32_t file_len,
         if ((uint64_t)ph[i].p_offset + (uint64_t)ph[i].p_filesz > (uint64_t)file_len)
             return -EINVAL;
 
-        /* Parse segment permissions: PF_R=4, PF_W=2, PF_X=1 */
-        uint32_t seg_vmm_flags = VMM_FLAG_PRESENT | VMM_FLAG_USER;
-        if (ph[i].p_flags & 0x2) seg_vmm_flags |= VMM_FLAG_RW;
-        if (!(ph[i].p_flags & 0x1)) seg_vmm_flags |= VMM_FLAG_NX;  /* no execute */
-
-        /* Map as RW initially so we can write segment data */
+        /* Map as RW initially so we can write segment data.
+         * Final permissions are applied by elf32_reprotect_segments
+         * after relocations are processed. */
         int mrc = elf32_map_user_range(as, vaddr, (size_t)ph[i].p_memsz, VMM_FLAG_RW);
         if (mrc < 0) return mrc;
 
index 0ea44e4c5352ce1915ac89e24ddc75ff96e8b8d5..2a9453ec846c538364ebbbaa8147da4e8b4f2754 100644 (file)
@@ -57,11 +57,9 @@ int ksem_wait_timeout(ksem_t* s, uint32_t timeout_ms) {
     current_process->state = PROCESS_BLOCKED;
 
     /* Set a wake timeout if requested (convert ms to ticks) */
-    uint32_t deadline = 0;
     if (timeout_ms > 0) {
         uint32_t ticks = (timeout_ms + TIMER_MS_PER_TICK - 1) / TIMER_MS_PER_TICK;
-        deadline = get_tick_count() + ticks;
-        current_process->wake_at_tick = deadline;
+        current_process->wake_at_tick = get_tick_count() + ticks;
         current_process->state = PROCESS_SLEEPING; /* timer will wake us */
     }