From: Tulio A M Mendes Date: Mon, 27 Apr 2026 01:59:00 +0000 (-0300) Subject: cppcheck: fix unreadVariable in elf.c and sync.c X-Git-Url: https://projects.tadryanom.me/?a=commitdiff_plain;h=7306d074e6964ac55bc00bf304ed3903e9b75de5;p=AdrOS.git cppcheck: fix unreadVariable in elf.c and sync.c - 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 --- diff --git a/src/arch/x86/elf.c b/src/arch/x86/elf.c index dfc23061..28842655 100644 --- a/src/arch/x86/elf.c +++ b/src/arch/x86/elf.c @@ -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; diff --git a/src/kernel/sync.c b/src/kernel/sync.c index 0ea44e4c..2a9453ec 100644 --- a/src/kernel/sync.c +++ b/src/kernel/sync.c @@ -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 */ }