Skip to content
Browse files

fixed the warnings in exec.c and wait.c

  • Loading branch information...
1 parent d3b55a4 commit ba334f6c233879537273053fa39fb3fd69eb7653 @Fleurer committed Apr 5, 2012
Showing with 23 additions and 14 deletions.
  1. +9 −0 src/inc/proto.h
  2. +10 −10 src/kern/exec.c
  3. +4 −4 src/kern/wait.c
View
9 src/inc/proto.h
@@ -11,6 +11,8 @@ struct proc;
struct vm;
struct tty;
struct stat;
+struct jmp_buf;
+struct ahead;
// tty.c
void tty_init();
@@ -23,10 +25,15 @@ void printk(char *fmt, ...);
void wakeup(uint chan);
void sleep(uint chan, int pri);
void swtch();
+void swtch_to(struct proc *to);
void sched_cpu();
void setpri(struct proc *p);
void setrun(struct proc *p);
+// entry.S
+void _do_swtch(struct jmp_buf *old, struct jmp_buf *new);
+void _retu(uint eip, uint esp3);
+
// sysent.c
int syserr(uint err);
uint suser();
@@ -86,8 +93,10 @@ int do_signal(int sig, void (*ufunc)(int));
int do_sigaction(int sig, struct sigaction *sa, struct sigaction *old_sa);
// mm/vm.c
+int vm_verify(uint vaddr, uint size);
int vm_clone(struct vm *to);
int vm_clear(struct vm *vm);
+int vm_renew(struct vm *vm, struct ahead *ah, struct inode *ip);
struct vma* find_vma(uint addr);
int vma_init(struct vma *vp, uint base, uint size, uint flag, struct inode *ip, uint ioff);
View
20 src/kern/exec.c
@@ -53,9 +53,7 @@ int do_exec(char *path, char **argv){
struct buf *bp;
struct sigaction *sa;
struct ahead *ah;
- struct page *pg;
struct vm *vm;
- struct vma *vp;
struct file *fp;
uint bn, fd, fdflag, argc, esp, nr;
char **tmp;
@@ -88,7 +86,7 @@ int do_exec(char *path, char **argv){
argc = upush_argv(&esp, tmp);
if (argc<0)
panic("exec(): bad mem");
- upush(&esp, &argc, sizeof(uint));
+ upush(&esp, (char*)&argc, sizeof(uint));
//
free_argv(tmp);
// close all the file descriptors with FD_CLOEXEC
@@ -126,8 +124,8 @@ int do_exec(char *path, char **argv){
* note: vm_verify() may override proc's address space, take care.
* */
int upush_argv(uint *esp, char **tmp){
- uint arglen, argc, tmp_esp;
- int i,r;
+ uint arglen, argc;
+ int i;
char *str, **uargv;
argc = 0;
@@ -144,15 +142,15 @@ int upush_argv(uint *esp, char **tmp){
return -1;
}
// push to ustack finally
- uargv = *esp - arglen;
+ uargv = (char**)(*esp - arglen);
for (i=argc-1; i>=0; i--){
str = tmp[i];
upush(esp, str, strlen(str)+1);
uargv[i] = (char *) *esp;
}
- *esp = uargv;
+ *esp = (uint)uargv;
// push argv[]
- upush(esp, &uargv, sizeof(uint));
+ upush(esp, (char*)&uargv, sizeof(uint));
return argc;
}
@@ -162,15 +160,15 @@ int upush(uint *esp, char *buf, int len){
if (vm_verify(tmp-=len, len) < 0) {
panic("upush(): bad mem");
}
- memcpy(tmp, buf, len);
+ memcpy((void*)tmp, buf, len);
return (*esp=tmp);
}
/* ---------------------------------------------------- */
/* store the argv into some new-allocated pages temporily */
static char** store_argv(char *path, char **argv){
- char *str, **uargv, **tmp;
+ char **tmp;
int argc, i;
argc = 1;
@@ -197,6 +195,7 @@ static int free_argv(char **tmp){
kfree(tmp[i], PAGE);
}
kfree(tmp, PAGE);
+ return 0;
}
/* ---------------------------------------------------------------*/
@@ -213,4 +212,5 @@ int dump_ahead(struct ahead *ah){
printk("a_entry: %x\n", ah->a_entry);
printk("a_trsize: %x\n", ah->a_trsize);
printk("a_drsize: %x\n", ah->a_drsize);
+ return 0;
}
View
8 src/kern/wait.c
@@ -24,7 +24,7 @@ int do_waitpid(int pid, int *stat, int opt){
struct proc *p;
uint nr;
- if (vm_verify(stat, sizeof(int)) < 0){
+ if (vm_verify((uint)stat, sizeof(int)) < 0){
syserr(EFAULT);
return -1;
}
@@ -61,11 +61,11 @@ int do_waitpid(int pid, int *stat, int opt){
}
}
}
-_not_found:
- // no child has found
+
+ // if no child has found
if (opt & WNOHANG) {
return 0;
}
- sleep(cu, PWAIT);
+ sleep((uint)cu, PWAIT);
goto _repeat;
}

0 comments on commit ba334f6

Please sign in to comment.
Something went wrong with that request. Please try again.