提交 0a4a4230 创建 作者: Robert Morris's avatar Robert Morris

shell nits

fix Regehr complaint
上级 50edfe14
...@@ -147,7 +147,7 @@ main(void) ...@@ -147,7 +147,7 @@ main(void)
static char buf[100]; static char buf[100];
int fd; int fd;
// Assumes three file descriptors open. // Ensure that three file descriptors are open.
while((fd = open("console", O_RDWR)) >= 0){ while((fd = open("console", O_RDWR)) >= 0){
if(fd >= 3){ if(fd >= 3){
close(fd); close(fd);
...@@ -158,8 +158,7 @@ main(void) ...@@ -158,8 +158,7 @@ main(void)
// Read and run input commands. // Read and run input commands.
while(getcmd(buf, sizeof(buf)) >= 0){ while(getcmd(buf, sizeof(buf)) >= 0){
if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){ if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){
// Clumsy but will have to do for now. // Chdir must be called by the parent, not the child.
// Chdir has no effect on the parent if run in the child.
buf[strlen(buf)-1] = 0; // chop \n buf[strlen(buf)-1] = 0; // chop \n
if(chdir(buf+3) < 0) if(chdir(buf+3) < 0)
printf(2, "cannot cd %s\n", buf+3); printf(2, "cannot cd %s\n", buf+3);
......
...@@ -237,7 +237,12 @@ allocuvm(pde_t *pgdir, uint oldsz, uint newsz) ...@@ -237,7 +237,12 @@ allocuvm(pde_t *pgdir, uint oldsz, uint newsz)
return 0; return 0;
} }
memset(mem, 0, PGSIZE); memset(mem, 0, PGSIZE);
mappages(pgdir, (char*)a, PGSIZE, v2p(mem), PTE_W|PTE_U); if(mappages(pgdir, (char*)a, PGSIZE, v2p(mem), PTE_W|PTE_U) < 0){
cprintf("allocuvm out of memory (2)\n");
deallocuvm(pgdir, newsz, oldsz);
kfree(mem);
return 0;
}
} }
return newsz; return newsz;
} }
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论