clean up -Wall

This commit is contained in:
Robert Morris 2019-06-05 14:31:13 -04:00
parent 5eb1cb4972
commit 5684556c19
7 changed files with 19 additions and 60 deletions

View file

@ -25,36 +25,6 @@ OBJS = \
kernelvec.o \ kernelvec.o \
plic.o plic.o
XXXOBJS = \
bio.o\
console.o\
exec.o\
file.o\
fs.o\
ide.o\
ioapic.o\
kalloc.o\
kbd.o\
lapic.o\
log.o\
main.o\
mp.o\
picirq.o\
pipe.o\
proc.o\
sleeplock.o\
spinlock.o\
string.o\
swtch.o\
syscall.o\
sysfile.o\
sysproc.o\
trapasm.o\
trap.o\
uart.o\
vectors.o\
vm.o\
# riscv64-unknown-elf- or riscv64-linux-gnu- # riscv64-unknown-elf- or riscv64-linux-gnu-
# perhaps in /opt/riscv/bin # perhaps in /opt/riscv/bin
#TOOLPREFIX = #TOOLPREFIX =
@ -79,8 +49,9 @@ LD = $(TOOLPREFIX)ld
OBJCOPY = $(TOOLPREFIX)objcopy OBJCOPY = $(TOOLPREFIX)objcopy
OBJDUMP = $(TOOLPREFIX)objdump OBJDUMP = $(TOOLPREFIX)objdump
CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -MD -ggdb -Werror -fno-omit-frame-pointer -O # CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -MD -ggdb -Werror -fno-omit-frame-pointer -O
CFLAGS = -mcmodel=medany CFLAGS = -Wall -Werror
CFLAGS += -mcmodel=medany
CFLAGS += -ffreestanding -fno-common -nostdlib -mno-relax CFLAGS += -ffreestanding -fno-common -nostdlib -mno-relax
CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector) CFLAGS += $(shell $(CC) -fno-stack-protector -E -x c /dev/null >/dev/null 2>&1 && echo -fno-stack-protector)

6
defs.h
View file

@ -122,8 +122,8 @@ void userinit(void);
int wait(void); int wait(void);
void wakeup(void*); void wakeup(void*);
void yield(void); void yield(void);
int either_copyout(int user_dst, uint64 dst, char *src, uint64 len); int either_copyout(int user_dst, uint64 dst, void *src, uint64 len);
int either_copyin(char *dst, int user_src, uint64 src, uint64 len); int either_copyin(void *dst, int user_src, uint64 src, uint64 len);
// swtch.S // swtch.S
void swtch(struct context*, struct context*); void swtch(struct context*, struct context*);
@ -181,7 +181,7 @@ int uartgetc(void);
void kvminit(void); void kvminit(void);
void kvminithart(void); void kvminithart(void);
pagetable_t uvmcreate(void); pagetable_t uvmcreate(void);
void uvminit(pagetable_t, char *, uint); void uvminit(pagetable_t, uchar *, uint);
uint64 uvmalloc(pagetable_t, uint64, uint64); uint64 uvmalloc(pagetable_t, uint64, uint64);
uint64 uvmdealloc(pagetable_t, uint64, uint64); uint64 uvmdealloc(pagetable_t, uint64, uint64);
void uvmcopy(pagetable_t, pagetable_t, uint64); void uvmcopy(pagetable_t, pagetable_t, uint64);

1
exec.c
View file

@ -129,7 +129,6 @@ loadseg(pagetable_t pagetable, uint64 va, struct inode *ip, uint offset, uint sz
{ {
uint i, n; uint i, n;
uint64 pa; uint64 pa;
pte_t *pte;
if((va % PGSIZE) != 0) if((va % PGSIZE) != 0)
panic("loadseg: va must be page aligned"); panic("loadseg: va must be page aligned");

4
file.c
View file

@ -106,9 +106,7 @@ filestat(struct file *f, uint64 addr)
int int
fileread(struct file *f, uint64 addr, int n) fileread(struct file *f, uint64 addr, int n)
{ {
struct proc *p = myproc();
int r = 0; int r = 0;
char *buf;
if(f->readable == 0) if(f->readable == 0)
return -1; return -1;
@ -133,9 +131,7 @@ fileread(struct file *f, uint64 addr, int n)
int int
filewrite(struct file *f, uint64 addr, int n) filewrite(struct file *f, uint64 addr, int n)
{ {
struct proc *p = myproc();
int r, ret = 0; int r, ret = 0;
char *buf;
if(f->writable == 0) if(f->writable == 0)
return -1; return -1;

11
proc.c
View file

@ -150,7 +150,7 @@ proc_freepagetable(pagetable_t pagetable, uint64 sz)
// a user program that calls exec("/init") // a user program that calls exec("/init")
// od -t xC initcode // od -t xC initcode
unsigned char initcode[] = { uchar initcode[] = {
0x17, 0x05, 0x00, 0x00, 0x13, 0x05, 0x05, 0x02, 0x97, 0x05, 0x00, 0x00, 0x93, 0x85, 0x05, 0x02, 0x17, 0x05, 0x00, 0x00, 0x13, 0x05, 0x05, 0x02, 0x97, 0x05, 0x00, 0x00, 0x93, 0x85, 0x05, 0x02,
0x9d, 0x48, 0x73, 0x00, 0x00, 0x00, 0x89, 0x48, 0x73, 0x00, 0x00, 0x00, 0xef, 0xf0, 0xbf, 0xff, 0x9d, 0x48, 0x73, 0x00, 0x00, 0x00, 0x89, 0x48, 0x73, 0x00, 0x00, 0x00, 0xef, 0xf0, 0xbf, 0xff,
0x2f, 0x69, 0x6e, 0x69, 0x74, 0x00, 0x00, 0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2f, 0x69, 0x6e, 0x69, 0x74, 0x00, 0x00, 0x01, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@ -429,9 +429,8 @@ yield(void)
void void
forkret(void) forkret(void)
{ {
struct proc *p = myproc();
static int first = 1; static int first = 1;
// Still holding ptable.lock from scheduler. // Still holding ptable.lock from scheduler.
release(&ptable.lock); release(&ptable.lock);
@ -535,13 +534,14 @@ kill(int pid)
// depending on usr_dst. // depending on usr_dst.
// Returns 0 on success, -1 on error. // Returns 0 on success, -1 on error.
int int
either_copyout(int user_dst, uint64 dst, char *src, uint64 len) either_copyout(int user_dst, uint64 dst, void *src, uint64 len)
{ {
struct proc *p = myproc(); struct proc *p = myproc();
if(user_dst){ if(user_dst){
return copyout(p->pagetable, dst, src, len); return copyout(p->pagetable, dst, src, len);
} else { } else {
memmove((char *)dst, src, len); memmove((char *)dst, src, len);
return 0;
} }
} }
@ -549,13 +549,14 @@ either_copyout(int user_dst, uint64 dst, char *src, uint64 len)
// depending on usr_src. // depending on usr_src.
// Returns 0 on success, -1 on error. // Returns 0 on success, -1 on error.
int int
either_copyin(char *dst, int user_src, uint64 src, uint64 len) either_copyin(void *dst, int user_src, uint64 src, uint64 len)
{ {
struct proc *p = myproc(); struct proc *p = myproc();
if(user_src){ if(user_src){
return copyin(p->pagetable, dst, src, len); return copyin(p->pagetable, dst, src, len);
} else { } else {
memmove(dst, (char*)src, len); memmove(dst, (char*)src, len);
return 0;
} }
} }

19
trap.c
View file

@ -129,7 +129,6 @@ kerneltrap()
{ {
uint64 sstatus = r_sstatus(); uint64 sstatus = r_sstatus();
uint64 scause = r_scause(); uint64 scause = r_scause();
uint64 sepc = r_sepc(); // XXX needed only for check at end?
if((sstatus & SSTATUS_SPP) == 0) if((sstatus & SSTATUS_SPP) == 0)
panic("kerneltrap: not from supervisor mode"); panic("kerneltrap: not from supervisor mode");
@ -141,12 +140,6 @@ kerneltrap()
printf("sepc=%p stval=%p\n", r_sepc(), r_stval()); printf("sepc=%p stval=%p\n", r_sepc(), r_stval());
panic("kerneltrap"); panic("kerneltrap");
} }
// XXX assert that we don't have to save/restore sstatus or sepc.
if(r_sstatus() != sstatus)
panic("kerneltrap sstatus");
if(r_sepc() != sepc)
panic("kerneltrap sepc");
} }
// check if it's an external interrupt or software interrupt, // check if it's an external interrupt or software interrupt,
@ -166,8 +159,6 @@ devintr()
if(irq == UART0_IRQ){ if(irq == UART0_IRQ){
uartintr(); uartintr();
} else {
printf("stray interrupt irq=%d\n", irq);
} }
plic_complete(irq); plic_complete(irq);
@ -175,10 +166,12 @@ devintr()
} else if(scause == 0x8000000000000001){ } else if(scause == 0x8000000000000001){
// software interrupt from a machine-mode timer interrupt. // software interrupt from a machine-mode timer interrupt.
acquire(&tickslock); if(cpuid() == 0){
ticks++; acquire(&tickslock);
wakeup(&ticks); ticks++;
release(&tickslock); wakeup(&ticks);
release(&tickslock);
}
// acknowledge. // acknowledge.
w_sip(r_sip() & ~2); w_sip(r_sip() & ~2);

3
vm.c
View file

@ -190,7 +190,7 @@ uvmcreate()
// for the very first process. // for the very first process.
// sz must be less than a page. // sz must be less than a page.
void void
uvminit(pagetable_t pagetable, char *src, uint sz) uvminit(pagetable_t pagetable, uchar *src, uint sz)
{ {
char *mem; char *mem;
@ -254,7 +254,6 @@ freewalk(pagetable_t pagetable)
freewalk((pagetable_t)child); freewalk((pagetable_t)child);
pagetable[i] = 0; pagetable[i] = 0;
} else if(pte & PTE_V){ } else if(pte & PTE_V){
// XXX trampoline pages...
panic("freewalk: leaf"); panic("freewalk: leaf");
} }
} }