Skip to content

Commit

Permalink
Change fetchint, fetcharg, and putint to return -1 on error, 0 on suc…
Browse files Browse the repository at this point in the history
…cess.

They had been returning 0 on error, 1 on success, but all the callers
were checking for return value < 0.
  • Loading branch information
rsc committed Jul 15, 2006
1 parent 46bbd72 commit 7f419a0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ extern struct spinlock proc_table_lock;

/*
* 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
fetchint(struct proc *p, unsigned addr, int *ip)
{
*ip = 0;

if(addr > p->sz - 4)
return 0;
return -1;
memcpy(ip, p->mem + addr, 4);
return 1;
return 0;
}

int
Expand All @@ -49,9 +49,9 @@ int
putint(struct proc *p, unsigned addr, int ip)
{
if(addr > p->sz - 4)
return 0;
return -1;
memcpy(p->mem + addr, &ip, 4);
return 1;
return 0;
}

int
Expand Down

0 comments on commit 7f419a0

Please sign in to comment.