]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
cppcheck: fix overlayfs unreadVariable, scheduler duplicateCondition, syscall duplica...
authorTulio A M Mendes <[email protected]>
Mon, 27 Apr 2026 17:10:39 +0000 (14:10 -0300)
committerTulio A M Mendes <[email protected]>
Mon, 4 May 2026 23:52:08 +0000 (20:52 -0300)
- overlayfs: remove dead 'written' assignment before early return
- scheduler: merge two consecutive if(current_process) blocks
- syscall: simplify addr_space assignment (condition was always true)
- test_utils: suppress unusedStructMember for ELF test struct fields

src/kernel/overlayfs.c
src/kernel/scheduler.c
src/kernel/syscall.c
tests/test_utils.c

index 9ec13d2e56b48cf536c905b0e3fa8899d98a9c47..c7c6c10f2a9c06f6f628580085cecd0a24ed9c6a 100644 (file)
@@ -212,7 +212,6 @@ static int overlay_readdir_impl(struct fs_node* node, uint32_t* inout_index, voi
         uint32_t upper_idx = idx;
         int rc = dir->upper->i_ops->readdir(dir->upper, &upper_idx, ents, buf_len);
         if (rc > 0) {
-            written = (uint32_t)rc / (uint32_t)sizeof(struct vfs_dirent);
             *inout_index = upper_idx;
             return rc;
         }
index 9ff855c44eac76ade84a938a77c4a462d37817c4..3b3d3ad33ab3d448369f06ec7ffe5b011a42fe6f 100644 (file)
@@ -652,18 +652,16 @@ struct process* process_fork_create(uintptr_t child_as, const void* child_regs)
 
     if (current_process) {
         memcpy(proc->fpu_state, current_process->fpu_state, FPU_STATE_SIZE);
-    } else {
-        arch_fpu_init_state(proc->fpu_state);
-    }
 
-    /* POSIX: fork inherits signal handlers and blocked/pending masks.
-     * Pending signals are cleared in the child (POSIX spec). */
-    if (current_process) {
+        /* POSIX: fork inherits signal handlers and blocked/pending masks.
+         * Pending signals are cleared in the child (POSIX spec). */
         for (int i = 0; i < PROCESS_MAX_SIG; i++) {
             proc->sigactions[i] = current_process->sigactions[i];
         }
         proc->sig_blocked_mask = current_process->sig_blocked_mask;
         /* sig_pending_mask stays 0 (memset) — POSIX: pending signals are not inherited */
+    } else {
+        arch_fpu_init_state(proc->fpu_state);
     }
 
     /* Copy parent's file descriptors under sched_lock so the child
index b87464beb688e338ea85222995b858c613777f20..a292b51440a94845d3d65b3b66367f0f5b7d8e99 100644 (file)
@@ -963,9 +963,7 @@ static int syscall_fork_impl(struct registers* regs) {
     if (!current_process) return -EINVAL;
 
     uintptr_t src_as = hal_cpu_get_address_space() & ~(uintptr_t)0xFFFU;
-    if (current_process->addr_space != src_as) {
-        current_process->addr_space = src_as;
-    }
+    current_process->addr_space = src_as;
 
     uintptr_t child_as = vmm_as_clone_user_cow(src_as);
     if (!child_as) return -ENOMEM;
index aae92f8def6ea06832d30624856e813ee0371c06..a2087d420e42dc2aa01af69865f63b1b8e799c7d 100644 (file)
@@ -276,17 +276,17 @@ typedef struct {
     uint8_t  e_ident[16];
     uint16_t e_type;
     uint16_t e_machine;
-    uint32_t e_version;
-    uint32_t e_entry;
-    uint32_t e_phoff;
-    uint32_t e_shoff;
-    uint32_t e_flags;
-    uint16_t e_ehsize;
+    uint32_t e_version;     // cppcheck-suppress unusedStructMember [needed for sizeof/layout]
+    uint32_t e_entry;       // cppcheck-suppress unusedStructMember
+    uint32_t e_phoff;       // cppcheck-suppress unusedStructMember
+    uint32_t e_shoff;       // cppcheck-suppress unusedStructMember
+    uint32_t e_flags;       // cppcheck-suppress unusedStructMember
+    uint16_t e_ehsize;      // cppcheck-suppress unusedStructMember
     uint16_t e_phentsize;
     uint16_t e_phnum;
-    uint16_t e_shentsize;
-    uint16_t e_shnum;
-    uint16_t e_shstrndx;
+    uint16_t e_shentsize;   // cppcheck-suppress unusedStructMember
+    uint16_t e_shnum;       // cppcheck-suppress unusedStructMember
+    uint16_t e_shstrndx;    // cppcheck-suppress unusedStructMember
 } test_elf32_ehdr_t;
 
 typedef struct {