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.
This commit is contained in:
parent
240679608c
commit
1a81e38b17
21 changed files with 227 additions and 199 deletions
12
proc.c
12
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue