From af7f2ba873e482ea210ca737e5b79da204f1d4ab Mon Sep 17 00:00:00 2001 From: EDiasAlberto Date: Tue, 26 Nov 2024 04:54:00 +0000 Subject: [PATCH] Fix: Magic number in stackgrowth.c --- src/vm/stackgrowth.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/vm/stackgrowth.c b/src/vm/stackgrowth.c index 164eb9d..7d5470d 100644 --- a/src/vm/stackgrowth.c +++ b/src/vm/stackgrowth.c @@ -5,14 +5,16 @@ #include "threads/vaddr.h" #include "userprog/pagedir.h" +#define MAX_STACK_ACCESS_DIST 32 + /* Validates a given address for being <=32 bytes away from the stack pointer or above the stack */ bool needs_new_page (void *addr, void *esp) { return (is_user_vaddr (addr) && - (uint32_t*)addr >= ((uint32_t*)esp - 32) && - ((PHYS_BASE - pg_round_down (addr)) - <= MAX_STACK_SIZE)); + (uint32_t*)addr >= ((uint32_t*)esp - MAX_STACK_ACCESS_DIST) && + ((PHYS_BASE - pg_round_down (addr)) + <= MAX_STACK_SIZE)); } /* Extends the stack by the necessary number of pages */