From 5b25422f8dfdb2de7bcf51cbf123434bf0855123 Mon Sep 17 00:00:00 2001 From: 0x35c <> Date: Sun, 30 Nov 2025 14:14:03 +0100 Subject: [PATCH] fix: memcpy not in the right order --- headers/memory.h | 5 ++++- src/multitasking/fork.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/headers/memory.h b/headers/memory.h index d7f0632..b78158d 100644 --- a/headers/memory.h +++ b/headers/memory.h @@ -32,7 +32,10 @@ ((uint32_t *)(VIRT_PT_BASE + ((uint32_t)pd_index) * 4096 + \ ((uint32_t)pt_index) * 4)) -#define PTE2VA(pd_index, pt_index) ((uint32_t*) ((((((uint32_t)pd_index) * 1024) + ((uint32_t)pt_index)) * 4096))) +#define PTE2VA(pd_index, pt_index) \ + ((uint32_t *)(( \ + ((((uint32_t)pd_index) * 1024) + ((uint32_t)pt_index)) * 4096))) + static inline uint32_t *VA2PTE(uint32_t va) { uint32_t pde = va >> 22; diff --git a/src/multitasking/fork.c b/src/multitasking/fork.c index 8ed8b3a..1e3cd51 100644 --- a/src/multitasking/fork.c +++ b/src/multitasking/fork.c @@ -102,7 +102,7 @@ pid_t fork(void) kfree(e); goto error; } - memcpy(it->content, new_content, sizeof(struct tcb)); + memcpy(new_content, it->content, sizeof(struct tcb)); new_content->process = new_pcb; e->next = NULL; prev = e;