diff --git a/vm.c b/vm.c
index 181b3763aae6ca6165970159b013697016d67f79..9a099bfbbbb20bc798eaf6397ba806b643058322 100644
--- a/vm.c
+++ b/vm.c
@@ -77,8 +77,7 @@ mappages(pde_t *pgdir, void *va, uint size, uint pa,
   a = (char *) PGROUNDDOWN((uint) va);
   last = (char *) PGROUNDDOWN(((uint) va) + size - 1);
   for(;;){
-    pte = walkpgdir(pgdir, a, alloc);
-    if(pte == 0)
+    if((pte = walkpgdir(pgdir, a, alloc) == 0)
       return -1;
     if(*pte & PTE_P)
       panic("remap");