From 5df6b800935349af42ff9f4dea713d2d8dfb4c60 Mon Sep 17 00:00:00 2001 From: Kees van Reeuwijk Date: Wed, 10 Mar 2010 13:19:27 +0000 Subject: [PATCH] Clean up code in preparation for using gcc warnings. --- lib/libc/other/hypot.c | 3 +-- lib/libsys/alloc_util.c | 1 - lib/libsys/ds.c | 4 ++-- lib/libsys/env_get_prm.c | 7 ++++--- lib/libsys/env_parse.c | 2 +- lib/libsys/getidle.c | 2 +- lib/libsys/kernel_call.c | 2 -- lib/libsys/kputc.c | 4 +--- lib/libsys/panic.c | 1 - lib/libsys/pci_reserve.c | 4 +--- lib/libsys/profile.c | 17 ++++++----------- lib/libsys/safecopies.c | 5 +---- lib/libsys/sef.c | 3 +-- lib/libsys/sys_getinfo.c | 2 +- lib/libsys/sys_sdevio.c | 1 - lib/libsys/sys_vmctl.c | 1 - lib/libsys/timing.c | 5 ++--- lib/libsys/vm_brk.c | 1 - lib/libsys/vm_map_phys.c | 1 - 19 files changed, 22 insertions(+), 44 deletions(-) diff --git a/lib/libc/other/hypot.c b/lib/libc/other/hypot.c index 8fa1a6cb7..8682e885f 100644 --- a/lib/libc/other/hypot.c +++ b/lib/libc/other/hypot.c @@ -17,8 +17,7 @@ _PROTOTYPE(double cabs, (struct complex p_compl )); /* $Header$ */ double -hypot(x, y) -double x, y; +hypot(double x, double y) { /* Computes sqrt(x*x+y*y), avoiding overflow */ diff --git a/lib/libsys/alloc_util.c b/lib/libsys/alloc_util.c index d3c01234e..df4ffd77b 100644 --- a/lib/libsys/alloc_util.c +++ b/lib/libsys/alloc_util.c @@ -23,7 +23,6 @@ int sys_umap_data_fb(endpoint_t ep, vir_bytes buf, vir_bytes len, phys_bytes *ph void *alloc_contig(size_t len, int flags, phys_bytes *phys) { - int r; vir_bytes buf; int mmapflags = MAP_PREALLOC|MAP_CONTIG|MAP_ANON; diff --git a/lib/libsys/ds.c b/lib/libsys/ds.c index ec82595ca..491a61785 100644 --- a/lib/libsys/ds.c +++ b/lib/libsys/ds.c @@ -181,8 +181,8 @@ int ds_retrieve_map(const char *ds_name, char *vaddr, size_t *length, return r; /* Do the safemap. */ - if(*length > m.DS_VAL_LEN) - *length = m.DS_VAL_LEN; + if(*length > (size_t) m.DS_VAL_LEN) + *length = (size_t) m.DS_VAL_LEN; *length = (size_t) CLICK_FLOOR(*length); r = sys_safemap(DS_PROC_NR, m.DS_VAL, 0, (vir_bytes)vaddr, *length, D, 0); diff --git a/lib/libsys/env_get_prm.c b/lib/libsys/env_get_prm.c index 07ff1fe8b..5e277293a 100644 --- a/lib/libsys/env_get_prm.c +++ b/lib/libsys/env_get_prm.c @@ -28,7 +28,8 @@ int max_len; /* maximum length of value */ message m; static char mon_params[128*sizeof(char *)]; /* copy parameters here */ char *key_value; - int i, s, keylen; + int i, s; + size_t keylen; if (key == NULL) return EINVAL; @@ -43,7 +44,7 @@ int max_len; /* maximum length of value */ if (env_argv[i][keylen] != '=') continue; key_value= env_argv[i]+keylen+1; - if (strlen(key_value)+1 > max_len) + if (strlen(key_value)+1 > (size_t) max_len) return(E2BIG); strcpy(value, key_value); return OK; @@ -67,7 +68,7 @@ int max_len; /* maximum length of value */ /* Value found, see if it fits in the client's buffer. Callers assume that * their buffer is unchanged on error, so don't make a partial copy. */ - if ((strlen(key_value)+1) > max_len) return(E2BIG); + if ((strlen(key_value)+1) > (size_t) max_len) return(E2BIG); /* Make the actual copy. */ strcpy(value, key_value); diff --git a/lib/libsys/env_parse.c b/lib/libsys/env_parse.c index a6c767a9e..fbe6d4222 100644 --- a/lib/libsys/env_parse.c +++ b/lib/libsys/env_parse.c @@ -118,7 +118,7 @@ int maxchunks; /* how many were found */ return -1; s = memstr; for (i = 0; i < maxchunks && !done; i++) { - phys_bytes base = 0, size = 0, limit; + phys_bytes base = 0, size = 0; memp = &mem_chunks[i]; /* next mem chunk is stored here */ if (*s != 0) { /* get fresh data, unless at end */ diff --git a/lib/libsys/getidle.c b/lib/libsys/getidle.c index fdd662225..90893fbfe 100644 --- a/lib/libsys/getidle.c +++ b/lib/libsys/getidle.c @@ -33,7 +33,7 @@ static double make_double(u64_t d) * This whole thing should be replaced by something better eventually. */ double value; - int i; + size_t i; value = (double) ex64hi(d); for (i = 0; i < sizeof(unsigned long); i += 2) diff --git a/lib/libsys/kernel_call.c b/lib/libsys/kernel_call.c index 04f2b0f86..c26a01350 100644 --- a/lib/libsys/kernel_call.c +++ b/lib/libsys/kernel_call.c @@ -3,8 +3,6 @@ PUBLIC int _kernel_call(int syscallnr, message *msgptr) { - int status; - msgptr->m_type = syscallnr; _do_kernel_call(msgptr); return(msgptr->m_type); diff --git a/lib/libsys/kputc.c b/lib/libsys/kputc.c index 1895f26a2..2f6d7135a 100644 --- a/lib/libsys/kputc.c +++ b/lib/libsys/kputc.c @@ -14,12 +14,10 @@ static char print_buf[DIAG_BUFSIZE]; /* output is buffered here */ /*===========================================================================* * kputc * *===========================================================================*/ -void kputc(c) -int c; +void kputc(int c) { /* Accumulate another character. If 0 or buffer full, print it. */ static int buf_count; /* # characters in the buffer */ - message m; if ((c == 0 && buf_count > 0) || buf_count == sizeof(print_buf)) { sys_sysctl(SYSCTL_CODE_DIAG, print_buf, buf_count); diff --git a/lib/libsys/panic.c b/lib/libsys/panic.c index c2694c5de..464101d81 100644 --- a/lib/libsys/panic.c +++ b/lib/libsys/panic.c @@ -15,7 +15,6 @@ PUBLIC void panic(const char *fmt, ...) * inconsistency is detected, e.g., a programming error or illegal * value of a defined constant. */ - message m; endpoint_t me = NONE; char name[20]; void (*suicide)(void); diff --git a/lib/libsys/pci_reserve.c b/lib/libsys/pci_reserve.c index 60e570297..493b918a7 100644 --- a/lib/libsys/pci_reserve.c +++ b/lib/libsys/pci_reserve.c @@ -29,10 +29,8 @@ int devind; /*===========================================================================* * pci_reserve_ok * *===========================================================================*/ -PUBLIC int pci_reserve_ok(devind) -int devind; +PUBLIC int pci_reserve_ok(int devind) { - int r; message m; m.m1_i1= devind; diff --git a/lib/libsys/profile.c b/lib/libsys/profile.c index beb16b269..f814d78ac 100644 --- a/lib/libsys/profile.c +++ b/lib/libsys/profile.c @@ -39,20 +39,16 @@ PRIVATE int cprof_announce; /* announce on n-th execution * of procentry */ PRIVATE int cprof_locked; /* for reentrancy */ -_PROTOTYPE(void procentry, (char *name) ); -_PROTOTYPE(void procexit, (char *name) ); - FORWARD _PROTOTYPE(void cprof_init, (void) ); FORWARD _PROTOTYPE(void reset, (void) ); FORWARD _PROTOTYPE(void clear_tbl, (void) ); -PUBLIC void procentry (name) -char *name; +PUBLIC void procentry (char *name) { static int init = 0; - unsigned hash = 0, i = 0, x = 0; - unsigned long hi, lo; + unsigned hash = 0, x = 0; + int i = 0; struct cprof_tbl_s *last; char c; u64_t start; @@ -171,8 +167,7 @@ char *name; } -PUBLIC void procexit (name) -char *name; +PUBLIC void procexit (char *name) { u64_t stop, spent; @@ -227,8 +222,8 @@ char *name; } -PRIVATE void cprof_init() { - message m; +PRIVATE void cprof_init() +{ int i; cpath[0] = '\0'; diff --git a/lib/libsys/safecopies.c b/lib/libsys/safecopies.c index 91dae250e..06c79f3da 100644 --- a/lib/libsys/safecopies.c +++ b/lib/libsys/safecopies.c @@ -249,11 +249,8 @@ cpf_lookup(cp_grant_id_t g, endpoint_t *granter, endpoint_t *grantee) } PUBLIC int -cpf_getgrants(grant_ids, n) -cp_grant_id_t *grant_ids; -int n; +cpf_getgrants(cp_grant_id_t *grant_ids, int n) { - cp_grant_id_t g; int i; for(i = 0; i < n; i++) { diff --git a/lib/libsys/sef.c b/lib/libsys/sef.c index 65303c978..50e1eeb48 100644 --- a/lib/libsys/sef.c +++ b/lib/libsys/sef.c @@ -124,7 +124,6 @@ PRIVATE void sef_debug_refresh_params(void) { /* Refresh SEF debug params. */ clock_t uptime; - endpoint_t endpoint; int r; /* Get boottime the first time. */ @@ -174,7 +173,7 @@ PUBLIC char* sef_debug_header(void) /* Build and return a SEF debug header. */ sef_debug_refresh_params(); sprintf(sef_debug_header_buff, "%s: time = %ds %06dus", - sef_self_name, sef_debug_time_sec, sef_debug_time_us); + sef_self_name, (int) sef_debug_time_sec, (int) sef_debug_time_us); return sef_debug_header_buff; } diff --git a/lib/libsys/sys_getinfo.c b/lib/libsys/sys_getinfo.c index 5a87a786d..7bab35547 100644 --- a/lib/libsys/sys_getinfo.c +++ b/lib/libsys/sys_getinfo.c @@ -42,7 +42,7 @@ PUBLIC int sys_whoami(endpoint_t *who_ep, char *who_name, int len) if((r = _kernel_call(SYS_GETINFO, &m)) != OK) return r; - lenmin = MIN(len, sizeof(m.GIWHO_NAME)) - 1; + lenmin = MIN((size_t) len, sizeof(m.GIWHO_NAME)) - 1; strncpy(who_name, m.GIWHO_NAME, lenmin); who_name[lenmin] = '\0'; diff --git a/lib/libsys/sys_sdevio.c b/lib/libsys/sys_sdevio.c index c9066d56b..0e1796a79 100644 --- a/lib/libsys/sys_sdevio.c +++ b/lib/libsys/sys_sdevio.c @@ -12,7 +12,6 @@ int count; /* number of elements */ vir_bytes offset; /* offset from grant */ { message m_io; - int result; m_io.DIO_REQUEST = req; m_io.DIO_PORT = port; diff --git a/lib/libsys/sys_vmctl.c b/lib/libsys/sys_vmctl.c index ea0e256be..2bbe28f5b 100644 --- a/lib/libsys/sys_vmctl.c +++ b/lib/libsys/sys_vmctl.c @@ -97,7 +97,6 @@ PUBLIC int sys_vmctl_get_mapping(int index, PUBLIC int sys_vmctl_reply_mapping(int index, vir_bytes addr) { - int r; message m; m.SVMCTL_WHO = SELF; diff --git a/lib/libsys/timing.c b/lib/libsys/timing.c index 4cf7b27a6..89c036294 100644 --- a/lib/libsys/timing.c +++ b/lib/libsys/timing.c @@ -12,8 +12,7 @@ void util_timer_start(util_timingdata_t *timingdata, char *name) { - unsigned long h, l; - int i; + size_t i; if(timingdata->names[0] == '\0') { for(i = 0; i < sizeof(timingdata->names) && *name; i++) @@ -32,7 +31,7 @@ void util_timer_start(util_timingdata_t *timingdata, char *name) void util_timer_end(util_timingdata_t *timingdata) { - unsigned long h, l, d = 0, binsize; + unsigned long h, l, d = 0; int bin; read_tsc(&h, &l); diff --git a/lib/libsys/vm_brk.c b/lib/libsys/vm_brk.c index f17da63f7..2a94e09b3 100644 --- a/lib/libsys/vm_brk.c +++ b/lib/libsys/vm_brk.c @@ -9,7 +9,6 @@ PUBLIC int vm_brk(endpoint_t ep, char *addr) { message m; - int result; m.VMB_ENDPOINT = ep; m.VMB_ADDR = (void *) addr; diff --git a/lib/libsys/vm_map_phys.c b/lib/libsys/vm_map_phys.c index 5bd19d149..affafa277 100644 --- a/lib/libsys/vm_map_phys.c +++ b/lib/libsys/vm_map_phys.c @@ -26,7 +26,6 @@ PUBLIC void *vm_map_phys(endpoint_t who, void *phaddr, size_t len) PUBLIC int vm_unmap_phys(endpoint_t who, void *vaddr, size_t len) { message m; - int r; m.VMUP_EP = who; m.VMUP_VADDR = vaddr; -- 2.44.0