summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorRuss Cox <[email protected]>2011-01-11 13:01:13 -0500
committerRuss Cox <[email protected]>2011-01-11 13:01:13 -0500
commit1a81e38b17144624415d252a521fd5a06079d681 (patch)
treeea7d895bcf77aa25861c09ee490488b6f729e0f3 /proc.c
parent240679608cd46649d1144408f28f83141f9f3a86 (diff)
downloadxv6-labs-1a81e38b17144624415d252a521fd5a06079d681.tar.gz
xv6-labs-1a81e38b17144624415d252a521fd5a06079d681.tar.bz2
xv6-labs-1a81e38b17144624415d252a521fd5a06079d681.zip
make new code like old code
Variable declarations at top of function, separate from initialization. Use == 0 instead of ! for checking pointers. Consistent spacing around {, *, casts. Declare 0-parameter functions as (void) not (). Integer valued functions return -1 on failure, 0 on success.
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/proc.c b/proc.c
index 2e8a0a4..e6ccd9d 100644
--- a/proc.c
+++ b/proc.c
@@ -120,7 +120,7 @@ userinit(void)
p = allocproc();
initproc = p;
- if(!(p->pgdir = setupkvm()))
+ if((p->pgdir = setupkvm()) == 0)
panic("userinit: out of memory?");
inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size);
p->sz = PGSIZE;
@@ -144,12 +144,14 @@ userinit(void)
int
growproc(int n)
{
- uint sz = proc->sz;
+ uint sz;
+
+ sz = proc->sz;
if(n > 0){
- if(!(sz = allocuvm(proc->pgdir, sz, sz + n)))
+ if((sz = allocuvm(proc->pgdir, sz, sz + n)) == 0)
return -1;
} else if(n < 0){
- if(!(sz = deallocuvm(proc->pgdir, sz, sz + n)))
+ if((sz = deallocuvm(proc->pgdir, sz, sz + n)) == 0)
return -1;
}
proc->sz = sz;
@@ -171,7 +173,7 @@ fork(void)
return -1;
// Copy process state from p.
- if(!(np->pgdir = copyuvm(proc->pgdir, proc->sz))){
+ if((np->pgdir = copyuvm(proc->pgdir, proc->sz)) == 0){
kfree(np->kstack);
np->kstack = 0;
np->state = UNUSED;