Change fetchint, fetcharg, and putint to return -1 on error, 0 on success.
They had been returning 0 on error, 1 on success, but all the callers were checking for return value < 0.
This commit is contained in:
parent
46bbd72f3e
commit
7f419a0d29
10
syscall.c
10
syscall.c
|
@ -23,7 +23,7 @@ extern struct spinlock proc_table_lock;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fetch 32 bits from a user-supplied pointer.
|
* fetch 32 bits from a user-supplied pointer.
|
||||||
* returns 1 if addr was OK, 0 if illegal.
|
* returns 0 if addr was OK, -1 if illegal.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
fetchint(struct proc *p, unsigned addr, int *ip)
|
fetchint(struct proc *p, unsigned addr, int *ip)
|
||||||
|
@ -31,9 +31,9 @@ fetchint(struct proc *p, unsigned addr, int *ip)
|
||||||
*ip = 0;
|
*ip = 0;
|
||||||
|
|
||||||
if(addr > p->sz - 4)
|
if(addr > p->sz - 4)
|
||||||
return 0;
|
return -1;
|
||||||
memcpy(ip, p->mem + addr, 4);
|
memcpy(ip, p->mem + addr, 4);
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -49,9 +49,9 @@ int
|
||||||
putint(struct proc *p, unsigned addr, int ip)
|
putint(struct proc *p, unsigned addr, int ip)
|
||||||
{
|
{
|
||||||
if(addr > p->sz - 4)
|
if(addr > p->sz - 4)
|
||||||
return 0;
|
return -1;
|
||||||
memcpy(p->mem + addr, &ip, 4);
|
memcpy(p->mem + addr, &ip, 4);
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in a new issue