summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2021-03-14 13:09:18 +0100
committerGustav Sörnäs <gustav@sornas.net>2021-03-14 13:09:18 +0100
commitd82476d59fb1076542a163bb2e6534023be43720 (patch)
treefb8d1dee3a3abc071d9f81060eafec0f1fae696f
parent5683afd1adee798a9288c7d01afc8029c65fe94c (diff)
downloadpintos-d82476d59fb1076542a163bb2e6534023be43720.tar.gz
intr_esp doesn't deref
-rw-r--r--src/userprog/syscall.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/userprog/syscall.c b/src/userprog/syscall.c
index a699784..0e0d97e 100644
--- a/src/userprog/syscall.c
+++ b/src/userprog/syscall.c
@@ -179,8 +179,8 @@ ptr_is_valid (const void *ptr)
return true;
}
-// cast to TYPE and deref argument N from f->esp
-#define INTR_ESP(N, TYPE) *(TYPE *)(f->esp+(4*(N)))
+// cast argument N from f->esp to TYPE without dereferencing
+#define INTR_ESP(N, TYPE) (TYPE *)(f->esp+(4*(N)))
#define CHECK_ESP_AND_MAYBE_EXIT(N) \
do { \
@@ -196,7 +196,7 @@ syscall_handler (struct intr_frame *f UNUSED)
{
// check esp
CHECK_ESP_AND_MAYBE_EXIT (0);
- int syscall_number = INTR_ESP (0, int);
+ int syscall_number = *INTR_ESP (0, int);
switch (syscall_number) {
case 0:
@@ -205,35 +205,35 @@ syscall_handler (struct intr_frame *f UNUSED)
break;
case 1:
// exit
- exit (INTR_ESP (1, int));
+ exit (*INTR_ESP (1, int));
break;
case 2:
// exec
- f->eax = exec (INTR_ESP (1, char *));
+ f->eax = exec (*INTR_ESP (1, char *));
break;
case 3:
// wait
- f->eax = wait (INTR_ESP (1, tid_t));
+ f->eax = wait (*INTR_ESP (1, tid_t));
break;
case 4:
// create
- f->eax = create (INTR_ESP (1, char *), INTR_ESP (2, off_t));
+ f->eax = create (*INTR_ESP (1, char *), *INTR_ESP (2, off_t));
break;
case 6:
// open
- f->eax = open (INTR_ESP (1, char *));
+ f->eax = open (*INTR_ESP (1, char *));
break;
case 8:
// read
- f->eax = read (INTR_ESP (1, int), INTR_ESP (2, void *), INTR_ESP (3, unsigned));
+ f->eax = read (*INTR_ESP (1, int), *INTR_ESP (2, void *), *INTR_ESP (3, unsigned));
break;
case 9:
// write
- f->eax = write (INTR_ESP (1, int), INTR_ESP (2, const void *), INTR_ESP (3, unsigned));
+ f->eax = write (*INTR_ESP (1, int), *INTR_ESP (2, const void *), *INTR_ESP (3, unsigned));
break;
case 12:
// close
- close (INTR_ESP (1, int));
+ close (*INTR_ESP (1, int));
break;
default:
printf ("kernel: unknown syscall '%d'\n", syscall_number);