From 7a6d57235c41df877b3fb2322cf770e65e864058 Mon Sep 17 00:00:00 2001 From: Frans Kaashoek Date: Fri, 12 Aug 2022 14:59:30 -0400 Subject: Costmestic change (thanks Harry Porter) --- kernel/syscall.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'kernel/syscall.c') diff --git a/kernel/syscall.c b/kernel/syscall.c index 95b9f70..dd7a33e 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -12,7 +12,7 @@ int fetchaddr(uint64 addr, uint64 *ip) { struct proc *p = myproc(); - if(addr >= p->sz || addr+sizeof(uint64) > p->sz) + if(addr >= p->sz || addr+sizeof(uint64) > p->sz) // both tests needed, in case of overflow return -1; if(copyin(p->pagetable, (char *)ip, addr, sizeof(*ip)) != 0) return -1; @@ -25,9 +25,8 @@ int fetchstr(uint64 addr, char *buf, int max) { struct proc *p = myproc(); - int err = copyinstr(p->pagetable, buf, addr, max); - if(err < 0) - return err; + if(copyinstr(p->pagetable, buf, addr, max) < 0) + return -1; return strlen(buf); } -- cgit v1.2.3 From 2a391ebc8ba1fd0e6f0899277218d531fd5c7396 Mon Sep 17 00:00:00 2001 From: Frans Kaashoek Date: Mon, 22 Aug 2022 19:53:09 -0400 Subject: Make argint() and argaddr() of type void (thanks Harry Porter) --- kernel/syscall.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'kernel/syscall.c') diff --git a/kernel/syscall.c b/kernel/syscall.c index dd7a33e..ee94696 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -53,21 +53,19 @@ argraw(int n) } // Fetch the nth 32-bit system call argument. -int +void argint(int n, int *ip) { *ip = argraw(n); - return 0; } // Retrieve an argument as a pointer. // Doesn't check for legality, since // copyin/copyout will do that. -int +void argaddr(int n, uint64 *ip) { *ip = argraw(n); - return 0; } // Fetch the nth word-sized system call argument as a null-terminated string. @@ -77,8 +75,7 @@ int argstr(int n, char *buf, int max) { uint64 addr; - if(argaddr(n, &addr) < 0) - return -1; + argaddr(n, &addr); return fetchstr(addr, buf, max); } -- cgit v1.2.3