Skip to content

Commit

Permalink
clean up -Wall
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Morris committed Jun 5, 2019
1 parent 5eb1cb4 commit 5684556
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 60 deletions.
35 changes: 3 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*);
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 0 additions & 4 deletions file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
11 changes: 6 additions & 5 deletions proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -535,27 +534,29 @@ 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;
}
}

// Copy from either a user address, or kernel address,
// 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 changes: 6 additions & 13 deletions trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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,
Expand All @@ -166,19 +159,19 @@ devintr()

if(irq == UART0_IRQ){
uartintr();
} else {
printf("stray interrupt irq=%d\n", irq);
}

plic_complete(irq);
return 1;
} 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);
Expand Down
3 changes: 1 addition & 2 deletions vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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");
}
}
Expand Down

0 comments on commit 5684556

Please sign in to comment.