Fix VM -Wall warnings and enable -Werror

This commit is contained in:
Erik van der Kouwe 2011-06-01 11:30:58 +02:00
parent f7c1307878
commit 0cb22acbda
14 changed files with 52 additions and 68 deletions

View file

@ -16,6 +16,9 @@ INSTALLFLAGS+= -S 128k
CPPFLAGS+= -I${.CURDIR} -I${.CURDIR}/arch/${ARCH}
CPPFLAGS+= -I${MINIXSRCDIR}
.if ${CC} == gcc
CFLAGS+= -Wall -Werror
.endif
.include "arch/${ARCH}/Makefile.inc"
.include <bsd.prog.mk>

View file

@ -57,8 +57,6 @@ struct hole {
int holelist;
};
static int startpages;
#define _NR_HOLES (_NR_PROCS*2) /* No. of memory holes maintained by VM */
@ -169,9 +167,7 @@ PUBLIC phys_clicks alloc_mem(phys_clicks clicks, u32_t memflags)
* always on a click boundary. This procedure is called when memory is
* needed for FORK or EXEC.
*/
register struct hole *hp, *prev_ptr;
phys_clicks old_base, mem = NO_MEM, align_clicks = 0;
int s;
phys_clicks mem = NO_MEM, align_clicks = 0;
if(memflags & PAF_ALIGN64K) {
align_clicks = (64 * 1024) / CLICK_SIZE;
@ -332,7 +328,6 @@ struct memory *chunks; /* list of free memory chunks */
*/
int i, first = 0;
register struct hole *hp;
int nodes, largest;
/* Put all holes on the free list. */
for (hp = &hole[0]; hp < &hole[_NR_HOLES]; hp++) {
@ -383,7 +378,7 @@ PRIVATE void sanitycheck(void)
PUBLIC void memstats(int *nodes, int *pages, int *largest)
{
pagerange_t *p, *prevp = NULL;
pagerange_t *p;
addr_iter iter;
addr_start_iter_least(&addravl, &iter);
*nodes = 0;
@ -681,9 +676,8 @@ PUBLIC int do_adddma(message *msg)
PUBLIC int do_deldma(message *msg)
{
endpoint_t req_proc_e, target_proc_e;
int i, j, proc_n;
int i, j;
phys_bytes base, size;
struct vmproc *vmp;
req_proc_e= msg->VMDD_REQ;
target_proc_e= msg->VMDD_EP;
@ -740,10 +734,7 @@ PUBLIC int do_deldma(message *msg)
*===========================================================================*/
PUBLIC int do_getdma(message *msg)
{
endpoint_t target_proc_e;
int i, proc_n;
phys_bytes base, size;
struct vmproc *vmp;
int i;
/* Find slot to report */
for (i= 0; i<NR_DMA; i++)
@ -774,10 +765,8 @@ PUBLIC int do_getdma(message *msg)
*===========================================================================*/
PUBLIC void release_dma(struct vmproc *vmp)
{
int i, found_one;
panic("release_dma not done");
#if 0
int i, found_one;
found_one= FALSE;
for (i= 0; i<NR_DMA; i++)
@ -796,6 +785,8 @@ PUBLIC void release_dma(struct vmproc *vmp)
free_mem(base, size);
msg->VMRD_FOUND = found_one;
#else
panic("release_dma not done");
#endif
return;

View file

@ -144,7 +144,7 @@ PRIVATE u32_t findhole(pt_t *pt, u32_t vmin, u32_t vmax)
* between page-aligned BYTE offsets vmin and vmax, to fit
* a page in. Return byte offset.
*/
u32_t freefound = 0, curv;
u32_t curv;
int pde = 0, try_restart;
static u32_t lastv = 0;
@ -291,7 +291,6 @@ PUBLIC void *vm_allocpage(phys_bytes *phys, int reason)
assert(level <= 2);
if(level > 1 || !(vmprocess->vm_flags & VMF_HASPT) || !meminit_done) {
int r;
void *s;
s=vm_getsparepage(phys);
level--;
@ -536,8 +535,7 @@ PUBLIC int pt_map_in_range(struct vmproc *src_vmp, struct vmproc *dst_vmp,
* the destination process in the range specified.
*/
int pde, pte;
int r;
vir_bytes viraddr, mapaddr;
vir_bytes viraddr;
pt_t *pt, *dst_pt;
pt = &src_vmp->vm_pt;
@ -652,7 +650,7 @@ PUBLIC int pt_writemap(struct vmproc * vmp,
{
/* Write mapping into page table. Allocate a new page table if necessary. */
/* Page directory and table entries for this virtual address. */
int p, r, pages;
int p, pages;
int verify = 0;
int ret = OK;
@ -778,14 +776,13 @@ resume_exit:
PUBLIC int pt_checkrange(pt_t *pt, vir_bytes v, size_t bytes,
int write)
{
int p, pages, pde;
int p, pages;
assert(!(bytes % I386_PAGE_SIZE));
pages = bytes / I386_PAGE_SIZE;
for(p = 0; p < pages; p++) {
u32_t entry;
int pde = I386_VM_PDE(v);
int pte = I386_VM_PTE(v);
@ -873,7 +870,6 @@ PUBLIC void pt_init(phys_bytes usedlimit)
u32_t moveup = 0;
int global_bit_ok = 0;
int free_pde;
int p;
struct vm_ep_data ep_data;
vir_bytes sparepages_mem;
phys_bytes sparepages_ph;
@ -943,9 +939,6 @@ PUBLIC void pt_init(phys_bytes usedlimit)
/* Set up mappings for VM process. */
for(v = lo; v < hi; v += I386_PAGE_SIZE) {
phys_bytes addr;
u32_t flags;
/* We have to write the new position in the PT,
* so we can move our segments.
*/
@ -1153,7 +1146,7 @@ PUBLIC void pt_init_mem()
*===========================================================================*/
PUBLIC int pt_bind(pt_t *pt, struct vmproc *who)
{
int slot, ispt;
int slot;
u32_t phys;
void *pdes;
@ -1213,7 +1206,7 @@ PUBLIC void pt_free(pt_t *pt)
*===========================================================================*/
PUBLIC int pt_mapkernel(pt_t *pt)
{
int r, i;
int i;
/* Any i386 page table needs to map in the kernel address space. */
assert(vmproc[VMP_SYSTEM].vm_flags & VMF_INUSE);

View file

@ -50,7 +50,6 @@ PUBLIC char *arch_map2str(struct vmproc *vmp, vir_bytes addr)
{
static char bufstr[100];
vir_bytes textstart = CLICK2ABS(vmp->vm_arch.vm_seg[T].mem_phys);
vir_bytes textend = textstart + CLICK2ABS(vmp->vm_arch.vm_seg[T].mem_len);
vir_bytes datastart = CLICK2ABS(vmp->vm_arch.vm_seg[D].mem_phys);
vir_bytes textsegbase = CLICK2ABS(vmp->vm_arch.vm_seg[T].mem_phys -
vmp->vm_arch.vm_seg[T].mem_vir);

View file

@ -7,6 +7,8 @@
** Version: 1.5 Author: Walt Karas
*/
#include <string.h>
#undef L__
#undef L__EST_LONG_BIT
#undef L__SIZE
@ -14,6 +16,7 @@
#undef L__MASK_HIGH_BIT
#undef L__LONG_BIT
#undef L__BIT_ARR_DEFN
#undef L__BIT_ARR_CLEAR
#undef L__BIT_ARR_VAL
#undef L__BIT_ARR_0
#undef L__BIT_ARR_1
@ -98,6 +101,8 @@
#define L__BIT_ARR_DEFN(NAME) unsigned long NAME[L__BIT_ARR_LONGS];
#define L__BIT_ARR_CLEAR(NAME) memset(NAME, 0, sizeof(NAME));
#define L__BIT_ARR_VAL(BIT_ARR, BIT_NUM) \
((BIT_ARR)[(BIT_NUM) / L__LONG_BIT] & (1L << ((BIT_NUM) % L__LONG_BIT)))
@ -114,6 +119,8 @@
#define L__BIT_ARR_DEFN(NAME) unsigned long NAME;
#define L__BIT_ARR_CLEAR(NAME) NAME = 0;
#define L__BIT_ARR_VAL(BIT_ARR, BIT_NUM) ((BIT_ARR) & (1L << (BIT_NUM)))
#define L__BIT_ARR_0(BIT_ARR, BIT_NUM) (BIT_ARR) &= ~(1L << (BIT_NUM));
@ -340,6 +347,8 @@ L__SC AVL_HANDLE L__(insert)(L__(avl) *L__tree, AVL_HANDLE h)
AVL_HANDLE hh = L__tree->root;
AVL_HANDLE parent = AVL_NULL;
int cmp;
L__BIT_ARR_CLEAR(branch)
do
{
@ -548,12 +557,14 @@ L__SC AVL_HANDLE L__(remove)(L__(avl) *L__tree, AVL_KEY k)
AVL_HANDLE parent = AVL_NULL;
AVL_HANDLE child;
AVL_HANDLE path;
int cmp, cmp_shortened_sub_with_path;
int cmp, cmp_shortened_sub_with_path = 0;
int reduced_depth;
int bf;
AVL_HANDLE rm;
AVL_HANDLE parent_rm;
L__BIT_ARR_CLEAR(branch)
for ( ; ; )
{
if (h == AVL_NULL)
@ -752,7 +763,7 @@ L__SC AVL_HANDLE L__(subst)(L__(avl) *L__tree, AVL_HANDLE new_node)
{
AVL_HANDLE h = L__tree->root;
AVL_HANDLE parent = AVL_NULL;
int cmp, last_cmp;
int cmp, last_cmp = 0;
/* Search for node already in tree with same key. */
for ( ; ; )
@ -833,6 +844,9 @@ L__SC int L__(build)(
return(1);
}
L__BIT_ARR_CLEAR(branch)
L__BIT_ARR_CLEAR(rem)
for ( ; ; )
{
while (num_sub > 2)
@ -1178,6 +1192,7 @@ L__SC void L__(decr_iter)(L__(iter) *iter)
#undef L__MASK_HIGH_BIT
#undef L__LONG_BIT
#undef L__BIT_ARR_DEFN
#undef L__BIT_ARR_CLEAR
#undef L__BIT_ARR_VAL
#undef L__BIT_ARR_0
#undef L__BIT_ARR_1

View file

@ -37,8 +37,6 @@ FORWARD _PROTOTYPE( int new_mem, (struct vmproc *vmp,
vir_bytes stk_bytes, phys_bytes tot_bytes, vir_bytes *stack_top,
int is_elf));
static int failcount;
/*===========================================================================*
* exec_newmem *
*===========================================================================*/
@ -150,8 +148,7 @@ PRIVATE int new_mem(
*/
vir_clicks text_clicks, data_clicks, gap_clicks, stack_clicks, tot_clicks;
phys_bytes bytes, base, bss_offset;
int s, r2, r, hadpt = 0;
int r, hadpt = 0;
struct vmproc *vmpold = &vmproc[VMP_EXECTMP];
int ptok = 1;
@ -298,7 +295,6 @@ PUBLIC int proc_new(struct vmproc *vmp,
{
int s;
vir_bytes hole_bytes;
int prealloc;
struct vir_region *reg;
phys_bytes map_text_addr, map_data_addr, map_stack_addr;

View file

@ -34,7 +34,7 @@
*===========================================================================*/
PUBLIC int do_fork(message *msg)
{
int r, proc, s, childproc, fullvm;
int r, proc, childproc, fullvm;
struct vmproc *vmp, *vmc;
pt_t origpt;
vir_bytes msgaddr;

View file

@ -75,7 +75,6 @@ PUBLIC int main(void)
{
message msg;
int result, who_e, rcv_sts;
sigset_t sigset;
int caller_slot;
struct vmproc *vmp_caller;
@ -172,7 +171,6 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
{
/* Initialize the vm server. */
int s, i;
int click, clicksforgotten = 0;
struct memory mem_chunks[NR_MEMS];
struct boot_image image[NR_BOOT_PROCS];
struct boot_image *ip;
@ -271,7 +269,6 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
/* Give these processes their own page table. */
for (ip = &image[0]; ip < &image[NR_BOOT_PROCS]; ip++) {
int s;
struct vmproc *vmp;
vir_bytes old_stacktop, old_stacklen;

View file

@ -52,8 +52,6 @@ PUBLIC int do_mmap(message *m)
return ENXIO;
if(m->VMM_FD == -1 || (m->VMM_FLAGS & MAP_ANON)) {
int s;
vir_bytes v;
u32_t vrflags = VR_ANON | VR_WRITABLE;
size_t len = (vir_bytes) m->VMM_LEN;
@ -221,7 +219,7 @@ PUBLIC int do_remap(message *m)
int dn, sn;
vir_bytes da, sa, startv;
size_t size;
struct vir_region *vr, *region;
struct vir_region *region;
struct vmproc *dvmp, *svmp;
int r;

View file

@ -57,7 +57,7 @@ PUBLIC void do_pagefaults(message *m)
u32_t addr = m->VPF_ADDR;
u32_t err = m->VPF_FLAGS;
struct vmproc *vmp;
int r, s;
int s;
struct vir_region *region;
vir_bytes offset;
@ -76,7 +76,7 @@ PUBLIC void do_pagefaults(message *m)
ep, arch_map2str(vmp, addr), pf_errstr(err));
if((s=sys_kill(vmp->vm_endpoint, SIGSEGV)) != OK)
panic("sys_kill failed: %d", s);
if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, r)) != OK)
if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, 0 /*unused*/)) != OK)
panic("do_pagefaults: sys_vmctl failed: %d", ep);
return;
}
@ -97,7 +97,7 @@ PUBLIC void do_pagefaults(message *m)
ep, arch_map2vir(vmp, addr), pf_errstr(err));
if((s=sys_kill(vmp->vm_endpoint, SIGSEGV)) != OK)
panic("sys_kill failed: %d", s);
if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, r)) != OK)
if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, 0 /*unused*/)) != OK)
panic("do_pagefaults: sys_vmctl failed: %d", ep);
return;
}
@ -106,17 +106,17 @@ PUBLIC void do_pagefaults(message *m)
offset = addr - region->vaddr;
/* Access is allowed; handle it. */
if((r=map_pf(vmp, region, offset, wr)) != OK) {
if((map_pf(vmp, region, offset, wr)) != OK) {
printf("VM: pagefault: SIGSEGV %d pagefault not handled\n", ep);
if((s=sys_kill(vmp->vm_endpoint, SIGSEGV)) != OK)
panic("sys_kill failed: %d", s);
if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, r)) != OK)
if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, 0 /*unused*/)) != OK)
panic("do_pagefaults: sys_vmctl failed: %d", ep);
return;
}
/* Pagefault is handled, so now reactivate the process. */
if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, r)) != OK)
if((s=sys_vmctl(ep, VMCTL_CLEAR_PAGEFAULT, 0 /*unused*/)) != OK)
panic("do_pagefaults: sys_vmctl failed: %d", ep);
}
@ -167,7 +167,6 @@ int handle_memory(struct vmproc *vmp, vir_bytes mem, vir_bytes len, int wrflag)
{
struct vir_region *region;
vir_bytes o;
vir_bytes v;
/* Page-align memory and length. */
o = mem % VM_PAGE_SIZE;

View file

@ -39,7 +39,7 @@ static struct query_exit_struct array[NR_PROCS];
PUBLIC int do_query_exit(message *m)
{
int i, nr;
endpoint_t ep;
endpoint_t ep = NONE;
for (i = 0; i < NR_PROCS; i++) {
if (!array[i].avail) {

View file

@ -405,7 +405,7 @@ PRIVATE vir_bytes region_find_slot_range(struct vmproc *vmp,
vir_bytes minv, vir_bytes maxv, vir_bytes length)
{
struct vir_region *firstregion;
vir_bytes startv;
vir_bytes startv = 0;
int foundflag = 0;
region_iter iter;
@ -522,7 +522,6 @@ int mapflags;
{
struct vir_region *newregion;
vir_bytes startv;
struct phys_region *ph;
physr_avl *phavl;
assert(!(length % VM_PAGE_SIZE));
@ -606,7 +605,6 @@ USE(newregion,
PUBLIC void pb_unreferenced(struct vir_region *region, struct phys_region *pr)
{
struct phys_block *pb;
int remap = 0;
pb = pr->ph;
assert(pb->refcount > 0);
@ -663,7 +661,7 @@ PRIVATE struct phys_region *reset_physr_iter(struct vir_region *region,
PRIVATE int map_subfree(struct vmproc *vmp,
struct vir_region *region, vir_bytes len)
{
struct phys_region *pr, *nextpr;
struct phys_region *pr;
physr_iter iter;
@ -706,7 +704,6 @@ PRIVATE int map_subfree(struct vmproc *vmp,
assert(!(sublen % VM_PAGE_SIZE));
assert(sublen < pr->ph->length);
if(pr->ph->refcount > 1) {
int r;
if(!(pr = map_clone_ph_block(vmp, region,
pr, &iter)))
return ENOMEM;
@ -1189,7 +1186,6 @@ int write;
if((ph = physr_search(region->phys, offset, AVL_LESS_EQUAL)) &&
(ph->offset <= offset && offset < ph->offset + ph->ph->length)) {
phys_bytes blockoffset = ph->offset;
/* Pagefault in existing block. Do copy-on-write. */
assert(write);
assert(region->flags & VR_WRITABLE);
@ -1277,7 +1273,6 @@ int write;
if(r2) { \
end = MIN(end, r2->offset); } \
if(start < end) { \
int r; \
SANITYCHECK(SCL_DETAIL); \
if(map_new_physblock(vmp, region, start, \
end-start, MAP_NONE, PAF_CLEAR, 0) != OK) { \
@ -1675,7 +1670,6 @@ PUBLIC int map_region_extend(struct vmproc *vmp, struct vir_region *vr,
{
vir_bytes end;
struct vir_region *nextvr;
region_iter v_iter;
assert(vr);
assert(vr->flags & VR_ANON);
@ -2187,7 +2181,7 @@ PUBLIC int unmap_memory(endpoint_t sour, endpoint_t dest,
*===========================================================================*/
PRIVATE int split_phys(struct phys_region *pr, vir_bytes point)
{
struct phys_region *newpr, *q, *prev;
struct phys_region *newpr, *q, *prev = NULL;
struct phys_block *newpb;
struct phys_block *pb = pr->ph;
/* Split the phys region into 2 parts by @point. */
@ -2224,6 +2218,7 @@ PRIVATE int split_phys(struct phys_region *pr, vir_bytes point)
prev = newpr;
}
}
assert(prev);
prev->next_ph_list = NULL;
return OK;
@ -2299,7 +2294,6 @@ PUBLIC int map_memory(endpoint_t sour, endpoint_t dest,
*/
struct vmproc *vms, *vmd;
struct vir_region *vrs, *vrd;
physr_iter iterd;
vir_bytes offset_s, offset_d;
int p;
int r;
@ -2416,7 +2410,6 @@ get_clean_phys_region(struct vmproc *vmp, vir_bytes vaddr, vir_bytes length,
/* If it's mapped more than once, make a copy. */
assert(ph->ph->refcount > 0);
if(ph->ph->refcount > 1) {
int r;
if(!(ph = map_clone_ph_block(vmp, region,
ph, NULL))) {
printf("VM: get_clean_phys_region: ph copy failed\n");
@ -2485,7 +2478,7 @@ PRIVATE int yieldblock(struct vmproc *vmp, u64_t id,
vir_bytes vaddr, vir_bytes len, yielded_t **retyb)
{
yielded_t *newyb;
vir_bytes mem_clicks, newmem, clicks;
vir_bytes mem_clicks, clicks;
struct vir_region *region;
struct phys_region *ph;
yielded_avl *avl;
@ -2634,7 +2627,7 @@ PUBLIC int do_forgetblock(message *m)
PUBLIC int do_yieldblockgetblock(message *m)
{
u64_t yieldid, getid;
int n, get = 0;
int n;
endpoint_t caller = m->m_source;
struct vmproc *vmp;
yielded_t *yb = NULL;

View file

@ -64,7 +64,6 @@ PUBLIC int do_rs_update(message *m_ptr)
endpoint_t src_e, dst_e, reply_e;
int src_p, dst_p;
struct vmproc *src_vmp, *dst_vmp;
struct vir_region *vr;
int r;
src_e = m_ptr->VM_RS_SRC_ENDPT;
@ -118,7 +117,7 @@ PUBLIC int do_rs_update(message *m_ptr)
*===========================================================================*/
PRIVATE int rs_memctl_make_vm_instance(struct vmproc *new_vm_vmp)
{
int vm_p, r;
int r;
u32_t flags;
int verify;
struct vmproc *this_vm_vmp;

View file

@ -277,7 +277,9 @@ PUBLIC int slabsane_f(char *file, int line, void *mem, int bytes)
}
#endif
#if SANITYCHECKS
static int nojunkwarning = 0;
#endif
/*===========================================================================*
* void *slaballoc *
@ -332,7 +334,6 @@ PUBLIC void *slaballoc(int bytes)
i = i % ITEMSPERPAGE(bytes);
if(!GETBIT(firstused, i)) {
struct slabdata *f;
char *ret;
SETBIT(firstused, i);
SLABSANITYCHECK(SCL_DETAIL);