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 \
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-
# perhaps in /opt/riscv/bin
#TOOLPREFIX =
@ -79,8 +49,9 @@ LD = $(TOOLPREFIX)ld
OBJCOPY = $(TOOLPREFIX)objcopy
OBJDUMP = $(TOOLPREFIX)objdump
CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -MD -ggdb -Werror -fno-omit-frame-pointer -O
CFLAGS = -mcmodel=medany
# CFLAGS = -fno-pic -static -fno-builtin -fno-strict-aliasing -Wall -MD -ggdb -Werror -fno-omit-frame-pointer -O
CFLAGS = -Wall -Werror
CFLAGS += -mcmodel=medany
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)

6
defs.h
View file

@ -122,8 +122,8 @@ void userinit(void);
int wait(void);
void wakeup(void*);
void yield(void);
int either_copyout(int user_dst, uint64 dst, char *src, uint64 len);
int either_copyin(char *dst, int user_src, uint64 src, uint64 len);
int either_copyout(int user_dst, uint64 dst, void *src, uint64 len);
int either_copyin(void *dst, int user_src, uint64 src, uint64 len);
// swtch.S
void swtch(struct context*, struct context*);
@ -181,7 +181,7 @@ int uartgetc(void);
void kvminit(void);
void kvminithart(void);
pagetable_t uvmcreate(void);
void uvminit(pagetable_t, char *, uint);
void uvminit(pagetable_t, uchar *, uint);
uint64 uvmalloc(pagetable_t, uint64, uint64);
uint64 uvmdealloc(pagetable_t, uint64, 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;
uint64 pa;
pte_t *pte;
if((va % PGSIZE) != 0)
panic("loadseg: va must be page aligned");

4
file.c
View file

@ -106,9 +106,7 @@ filestat(struct file *f, uint64 addr)
int
fileread(struct file *f, uint64 addr, int n)
{
struct proc *p = myproc();
int r = 0;
char *buf;
if(f->readable == 0)
return -1;
@ -133,9 +131,7 @@ fileread(struct file *f, uint64 addr, int n)
int
filewrite(struct file *f, uint64 addr, int n)
{
struct proc *p = myproc();
int r, ret = 0;
char *buf;
if(f->writable == 0)
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")
// 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,
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,
@ -429,9 +429,8 @@ yield(void)
void
forkret(void)
{
struct proc *p = myproc();
static int first = 1;
// Still holding ptable.lock from scheduler.
release(&ptable.lock);
@ -535,13 +534,14 @@ kill(int pid)
// depending on usr_dst.
// Returns 0 on success, -1 on error.
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();
if(user_dst){
return copyout(p->pagetable, dst, src, len);
} else {
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.
// Returns 0 on success, -1 on error.
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();
if(user_src){
return copyin(p->pagetable, dst, src, len);
} else {
memmove(dst, (char*)src, len);
return 0;
}
}

19
trap.c
View file

@ -129,7 +129,6 @@ kerneltrap()
{
uint64 sstatus = r_sstatus();
uint64 scause = r_scause();
uint64 sepc = r_sepc(); // XXX needed only for check at end?
if((sstatus & SSTATUS_SPP) == 0)
panic("kerneltrap: not from supervisor mode");
@ -141,12 +140,6 @@ kerneltrap()
printf("sepc=%p stval=%p\n", r_sepc(), r_stval());
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,
@ -166,8 +159,6 @@ devintr()
if(irq == UART0_IRQ){
uartintr();
} else {
printf("stray interrupt irq=%d\n", irq);
}
plic_complete(irq);
@ -175,10 +166,12 @@ devintr()
} else if(scause == 0x8000000000000001){
// software interrupt from a machine-mode timer interrupt.
acquire(&tickslock);
ticks++;
wakeup(&ticks);
release(&tickslock);
if(cpuid() == 0){
acquire(&tickslock);
ticks++;
wakeup(&ticks);
release(&tickslock);
}
// acknowledge.
w_sip(r_sip() & ~2);

3
vm.c
View file

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