From 1a81e38b17144624415d252a521fd5a06079d681 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 11 Jan 2011 13:01:13 -0500 Subject: 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. --- proc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'proc.c') 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; -- cgit v1.2.3