From 31ea2158052d99bec16aea64bf650ab38cf18a84 Mon Sep 17 00:00:00 2001 From: sBubshait Date: Wed, 13 Nov 2024 18:30:24 +0000 Subject: [PATCH] Refactor validate_user_string to remove unnecessary variable to track length of str --- src/userprog/syscall.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/userprog/syscall.c b/src/userprog/syscall.c index 0c352f5..a85fc2b 100644 --- a/src/userprog/syscall.c +++ b/src/userprog/syscall.c @@ -446,13 +446,12 @@ validate_user_string (const char *str) if (str == NULL || !is_user_vaddr (str)) syscall_exit (EXIT_FAILURE); - size_t length = 0; size_t offset = (uintptr_t) str % PGSIZE; /* We move page by page, checking if the page is mapped to physical memory. */ for (;;) { - void *page = pg_round_down (str + length); + void *page = pg_round_down (str); if (!is_user_vaddr(page) || pagedir_get_page (thread_current ()->pagedir, page) == NULL)