Make argint() and argaddr() of type void (thanks Harry Porter)

This commit is contained in:
Frans Kaashoek 2022-08-22 19:53:09 -04:00
parent 7086197c27
commit 2a391ebc8b
4 changed files with 27 additions and 30 deletions

View file

@ -132,9 +132,9 @@ int strncmp(const char*, const char*, uint);
char* strncpy(char*, const char*, int);
// syscall.c
int argint(int, int*);
void argint(int, int*);
int argstr(int, char*, int);
int argaddr(int, uint64 *);
void argaddr(int, uint64 *);
int fetchstr(uint64, char*, int);
int fetchaddr(uint64, uint64*);
void syscall();

View file

@ -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);
}

View file

@ -24,8 +24,7 @@ argfd(int n, int *pfd, struct file **pf)
int fd;
struct file *f;
if(argint(n, &fd) < 0)
return -1;
argint(n, &fd);
if(fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == 0)
return -1;
if(pfd)
@ -73,7 +72,9 @@ sys_read(void)
int n;
uint64 p;
if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
argaddr(1, &p);
argint(2, &n);
if(argfd(0, 0, &f) < 0)
return -1;
return fileread(f, p, n);
}
@ -85,7 +86,9 @@ sys_write(void)
int n;
uint64 p;
if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argaddr(1, &p) < 0)
argaddr(1, &p);
argint(2, &n);
if(argfd(0, 0, &f) < 0)
return -1;
return filewrite(f, p, n);
@ -110,7 +113,8 @@ sys_fstat(void)
struct file *f;
uint64 st; // user pointer to struct stat
if(argfd(0, 0, &f) < 0 || argaddr(1, &st) < 0)
argaddr(1, &st);
if(argfd(0, 0, &f) < 0)
return -1;
return filestat(f, st);
}
@ -292,7 +296,8 @@ sys_open(void)
struct inode *ip;
int n;
if((n = argstr(0, path, MAXPATH)) < 0 || argint(1, &omode) < 0)
argint(1, &omode);
if((n = argstr(0, path, MAXPATH)) < 0)
return -1;
begin_op();
@ -375,9 +380,9 @@ sys_mknod(void)
int major, minor;
begin_op();
argint(1, &major);
argint(2, &minor);
if((argstr(0, path, MAXPATH)) < 0 ||
argint(1, &major) < 0 ||
argint(2, &minor) < 0 ||
(ip = create(path, T_DEVICE, major, minor)) == 0){
end_op();
return -1;
@ -419,7 +424,8 @@ sys_exec(void)
int i;
uint64 uargv, uarg;
if(argstr(0, path, MAXPATH) < 0 || argaddr(1, &uargv) < 0){
argaddr(1, &uargv);
if(argstr(0, path, MAXPATH) < 0) {
return -1;
}
memset(argv, 0, sizeof(argv));
@ -462,8 +468,7 @@ sys_pipe(void)
int fd0, fd1;
struct proc *p = myproc();
if(argaddr(0, &fdarray) < 0)
return -1;
argaddr(0, &fdarray);
if(pipealloc(&rf, &wf) < 0)
return -1;
fd0 = -1;

View file

@ -10,8 +10,7 @@ uint64
sys_exit(void)
{
int n;
if(argint(0, &n) < 0)
return -1;
argint(0, &n);
exit(n);
return 0; // not reached
}
@ -32,8 +31,7 @@ uint64
sys_wait(void)
{
uint64 p;
if(argaddr(0, &p) < 0)
return -1;
argaddr(0, &p);
return wait(p);
}
@ -43,8 +41,7 @@ sys_sbrk(void)
uint64 addr;
int n;
if(argint(0, &n) < 0)
return -1;
argint(0, &n);
addr = myproc()->sz;
if(growproc(n) < 0)
return -1;
@ -57,8 +54,7 @@ sys_sleep(void)
int n;
uint ticks0;
if(argint(0, &n) < 0)
return -1;
argint(0, &n);
acquire(&tickslock);
ticks0 = ticks;
while(ticks - ticks0 < n){
@ -77,8 +73,7 @@ sys_kill(void)
{
int pid;
if(argint(0, &pid) < 0)
return -1;
argint(0, &pid);
return kill(pid);
}