From: David van Moolenbroek Date: Tue, 30 Sep 2014 20:08:54 +0000 (+0000) Subject: libsys: resolve clang warnings X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/Bv9ARM.ch08.html?a=commitdiff_plain;h=refs%2Fchanges%2F53%2F2853%2F1;p=minix.git libsys: resolve clang warnings Change-Id: Ic954ba8667b4d039172b8e0d2ec57674a479b8aa --- diff --git a/minix/include/env.h b/minix/include/env.h index 7f9c6fd75..2f60f42f0 100644 --- a/minix/include/env.h +++ b/minix/include/env.h @@ -1,4 +1,4 @@ int env_parse(const char *env, const char *fmt, int field, long *param, long min, long max); -void env_panic(const char *env); +void __dead env_panic(const char *env); int env_prefix(char *env, char *prefix); diff --git a/minix/include/minix/sef.h b/minix/include/minix/sef.h index 25434410d..6fb69fad9 100644 --- a/minix/include/minix/sef.h +++ b/minix/include/minix/sef.h @@ -10,7 +10,7 @@ void sef_startup(void); int sef_receive_status(endpoint_t src, message *m_ptr, int *status_ptr); endpoint_t sef_self(void); void sef_cancel(void); -void sef_exit(int status); +void __dead sef_exit(int status); #define sef_receive(src, m_ptr) sef_receive_status(src, m_ptr, NULL) /* SEF Debug. */ diff --git a/minix/lib/libsys/Makefile b/minix/lib/libsys/Makefile index 39535b912..a73c58c89 100644 --- a/minix/lib/libsys/Makefile +++ b/minix/lib/libsys/Makefile @@ -1,9 +1,8 @@ -NOGCCERROR=yes -NOCLANGERROR=yes - # Makefile for libsys .include +NOGCCERROR=yes + CPPFLAGS+= -D_MINIX_SYSTEM -D_SYSTEM LIB= sys diff --git a/minix/lib/libsys/arch/i386/Makefile.inc b/minix/lib/libsys/arch/i386/Makefile.inc index e35b04bd5..9b9aa2d38 100644 --- a/minix/lib/libsys/arch/i386/Makefile.inc +++ b/minix/lib/libsys/arch/i386/Makefile.inc @@ -22,7 +22,6 @@ SRCS+= \ sys_voutb.c \ sys_voutl.c \ sys_voutw.c \ - timing.c \ tsc_util.c \ vbox.c diff --git a/minix/lib/libsys/arch/i386/sys_readbios.c b/minix/lib/libsys/arch/i386/sys_readbios.c index 497f3c4bf..49350acec 100644 --- a/minix/lib/libsys/arch/i386/sys_readbios.c +++ b/minix/lib/libsys/arch/i386/sys_readbios.c @@ -10,6 +10,6 @@ size_t size; /* Amount of data to read */ m.m_lsys_krn_readbios.size = size; m.m_lsys_krn_readbios.addr = address; - m.m_lsys_krn_readbios.buf = buf; + m.m_lsys_krn_readbios.buf = (vir_bytes)buf; return(_kernel_call(SYS_READBIOS, &m)); } diff --git a/minix/lib/libsys/arch/i386/sys_sdevio.c b/minix/lib/libsys/arch/i386/sys_sdevio.c index 8516fb8dd..c589f63f5 100644 --- a/minix/lib/libsys/arch/i386/sys_sdevio.c +++ b/minix/lib/libsys/arch/i386/sys_sdevio.c @@ -16,7 +16,7 @@ vir_bytes offset; /* offset from grant */ m_io.m_lsys_krn_sys_sdevio.request = req; m_io.m_lsys_krn_sys_sdevio.port = port; m_io.m_lsys_krn_sys_sdevio.vec_endpt = proc_nr; - m_io.m_lsys_krn_sys_sdevio.vec_addr = buffer; + m_io.m_lsys_krn_sys_sdevio.vec_addr = (vir_bytes)buffer; m_io.m_lsys_krn_sys_sdevio.vec_size = count; m_io.m_lsys_krn_sys_sdevio.offset = offset; diff --git a/minix/lib/libsys/arch/i386/timing.c b/minix/lib/libsys/arch/i386/timing.c deleted file mode 100644 index 51acc7b08..000000000 --- a/minix/lib/libsys/arch/i386/timing.c +++ /dev/null @@ -1,83 +0,0 @@ - -#include -#include -#include -#include -#include - -#define HIGHCOUNT 0 -#define LOWCOUNT 1 - -#define START 0 -#define END 1 - -void util_timer_start(util_timingdata_t *timingdata, char *name) -{ - size_t i; - - if(timingdata->names[0] == '\0') { - for(i = 0; i < sizeof(timingdata->names) && *name; i++) - timingdata->names[i] = *name++; - timingdata->names[sizeof(timingdata->names)-1] = '\0'; - } - - if (timingdata->starttimes[HIGHCOUNT]) { - panic("restart timer?"); - return; - } - - read_tsc((u32_t *) &timingdata->starttimes[HIGHCOUNT], - (u32_t *) &timingdata->starttimes[LOWCOUNT]); -} - -void util_timer_end(util_timingdata_t *timingdata) -{ - unsigned long h, l, d = 0; - int bin; - - read_tsc((u32_t *) &h, (u32_t *) &l); - if (!timingdata->starttimes[HIGHCOUNT]) { - panic("timer stopped but not started"); - return; - } - if (timingdata->starttimes[HIGHCOUNT] == h) { - d = (l - timingdata->starttimes[LOWCOUNT]); - } else if (timingdata->starttimes[HIGHCOUNT] == h-1 && - timingdata->starttimes[LOWCOUNT] > l) { - d = ((ULONG_MAX - timingdata->starttimes[LOWCOUNT]) + l); - } else { - timingdata->misses++; - return; - } - timingdata->starttimes[HIGHCOUNT] = 0; - if (!timingdata->lock_timings_range[START] || - d < timingdata->lock_timings_range[START] || - d > timingdata->lock_timings_range[END]) { - int t; - if (!timingdata->lock_timings_range[START] || - d < timingdata->lock_timings_range[START]) - timingdata->lock_timings_range[START] = d; - if (!timingdata->lock_timings_range[END] || - d > timingdata->lock_timings_range[END]) - timingdata->lock_timings_range[END] = d; - for(t = 0; t < TIMING_POINTS; t++) - timingdata->lock_timings[t] = 0; - timingdata->binsize = - (timingdata->lock_timings_range[END] - - timingdata->lock_timings_range[START])/(TIMING_POINTS+1); - if (timingdata->binsize < 1) - timingdata->binsize = 1; - timingdata->resets++; - } - bin = (d-timingdata->lock_timings_range[START]) / - timingdata->binsize; - if (bin < 0 || bin >= TIMING_POINTS) { - /* not serious, but can't happen, so shouldn't */ - panic("bin out of range: %d", bin); - } else { - timingdata->lock_timings[bin]++; - timingdata->measurements++; - } - - return; -} diff --git a/minix/lib/libsys/env_get_prm.c b/minix/lib/libsys/env_get_prm.c index 590c6888a..de6d556b1 100644 --- a/minix/lib/libsys/env_get_prm.c +++ b/minix/lib/libsys/env_get_prm.c @@ -50,7 +50,7 @@ int env_get_param(const char *key, char *value, int max_len) m.m_lsys_krn_sys_getinfo.request = GET_MONPARAMS; m.m_lsys_krn_sys_getinfo.endpt = SELF; m.m_lsys_krn_sys_getinfo.val_len = sizeof(mon_params); - m.m_lsys_krn_sys_getinfo.val_ptr = mon_params; + m.m_lsys_krn_sys_getinfo.val_ptr = (vir_bytes)mon_params; if ((s=_kernel_call(SYS_GETINFO, &m)) != OK) { printf("SYS_GETINFO: %d (size %u)\n", s, sizeof(mon_params)); return(s); diff --git a/minix/lib/libsys/env_panic.c b/minix/lib/libsys/env_panic.c index 4ca0dcd42..6e0c9357f 100644 --- a/minix/lib/libsys/env_panic.c +++ b/minix/lib/libsys/env_panic.c @@ -1,5 +1,6 @@ #include "sysutil.h" #include +#include /*=========================================================================* * env_panic * diff --git a/minix/lib/libsys/getsysinfo.c b/minix/lib/libsys/getsysinfo.c index 7154b5852..8bdc1ec26 100644 --- a/minix/lib/libsys/getsysinfo.c +++ b/minix/lib/libsys/getsysinfo.c @@ -26,7 +26,7 @@ int getsysinfo( memset(&m, 0, sizeof(m)); m.m_lsys_getsysinfo.what = what; - m.m_lsys_getsysinfo.where = where; + m.m_lsys_getsysinfo.where = (vir_bytes)where; m.m_lsys_getsysinfo.size = size; return _taskcall(who, call_nr, &m); } diff --git a/minix/lib/libsys/sched_start.c b/minix/lib/libsys/sched_start.c index 1cd2e510e..6cce480f4 100644 --- a/minix/lib/libsys/sched_start.c +++ b/minix/lib/libsys/sched_start.c @@ -2,13 +2,9 @@ #include #include #include +#include #include -#include "kernel/config.h" -#include "kernel/const.h" -#include "kernel/type.h" -#include "kernel/proc.h" - /*===========================================================================* * sched_inherit * *===========================================================================*/ diff --git a/minix/lib/libsys/sched_stop.c b/minix/lib/libsys/sched_stop.c index 889a03bcc..d6ad73cdc 100644 --- a/minix/lib/libsys/sched_stop.c +++ b/minix/lib/libsys/sched_stop.c @@ -1,6 +1,7 @@ #include "syslib.h" #include #include +#include /*===========================================================================* * sched_stop * diff --git a/minix/lib/libsys/sef.c b/minix/lib/libsys/sef.c index 389118719..c9bdd49d8 100644 --- a/minix/lib/libsys/sef.c +++ b/minix/lib/libsys/sef.c @@ -17,6 +17,7 @@ int sef_self_receiving; /* Debug. */ #if SEF_INIT_DEBUG || SEF_LU_DEBUG || SEF_PING_DEBUG || SEF_SIGNAL_DEBUG #define SEF_DEBUG_HEADER_MAXLEN 32 +static int sef_debug_init = 0; static time_t sef_debug_boottime = 0; static u32_t sef_debug_system_hz = 0; static time_t sef_debug_time_sec = 0; @@ -239,7 +240,6 @@ void sef_exit(int status) /* System services use a special version of exit() that generates a * self-termination signal. */ - message m; /* Ask the kernel to exit. */ sys_exit(); @@ -262,40 +262,26 @@ static void sef_debug_refresh_params(void) { /* Refresh SEF debug params. */ clock_t uptime; - int r; - /* Get boottime the first time. */ - if(!sef_debug_boottime) { - r = sys_times(NONE, NULL, NULL, NULL, &sef_debug_boottime); - if ( r != OK) { - sef_debug_boottime = -1; - } - } - - /* Get system hz the first time. */ - if(!sef_debug_system_hz) { - r = sys_getinfo(GET_HZ, &sef_debug_system_hz, - sizeof(sef_debug_system_hz), 0, 0); - if ( r != OK) { - sef_debug_system_hz = -1; - } + /* Get boottime and system hz the first time. */ + if(!sef_debug_init) { + if (sys_times(NONE, NULL, NULL, NULL, &sef_debug_boottime) != OK) + sef_debug_init = -1; + else if (sys_getinfo(GET_HZ, &sef_debug_system_hz, + sizeof(sef_debug_system_hz), 0, 0) != OK) + sef_debug_init = -1; + else + sef_debug_init = 1; } /* Get uptime. */ uptime = -1; - if(sef_debug_boottime!=-1 && sef_debug_system_hz!=-1) { - r = sys_times(NONE, NULL, NULL, &uptime, NULL); - if ( r != OK) { - uptime = -1; - } - } - - /* Compute current time. */ - if(sef_debug_boottime==-1 || sef_debug_system_hz==-1 || uptime==-1) { + if (sef_debug_init < 1 || sys_times(NONE, NULL, NULL, &uptime, NULL) != OK) { sef_debug_time_sec = 0; sef_debug_time_us = 0; } else { + /* Compute current time. */ sef_debug_time_sec = (time_t) (sef_debug_boottime + (uptime/sef_debug_system_hz)); sef_debug_time_us = (uptime%sef_debug_system_hz) diff --git a/minix/lib/libsys/sef_fi.c b/minix/lib/libsys/sef_fi.c index 36ae8d6f1..9f5265969 100644 --- a/minix/lib/libsys/sef_fi.c +++ b/minix/lib/libsys/sef_fi.c @@ -5,6 +5,8 @@ EXTERN __attribute__((weak)) int edfi_ctl_process_request(void *ctl_request); +EXTERN int do_sef_fi_request(message *m_ptr); + /*===========================================================================* * do_sef_fi_request * *===========================================================================*/ diff --git a/minix/lib/libsys/stacktrace.c b/minix/lib/libsys/stacktrace.c index 8185956a9..d7e87eb9c 100644 --- a/minix/lib/libsys/stacktrace.c +++ b/minix/lib/libsys/stacktrace.c @@ -8,6 +8,7 @@ Copyright 1995 Philip Homburg #include #include +#include typedef unsigned int reg_t; diff --git a/minix/lib/libsys/sys_getinfo.c b/minix/lib/libsys/sys_getinfo.c index a9a463d1e..1b1076bdf 100644 --- a/minix/lib/libsys/sys_getinfo.c +++ b/minix/lib/libsys/sys_getinfo.c @@ -17,9 +17,9 @@ int len2; /* length or process nr */ m.m_lsys_krn_sys_getinfo.request = request; m.m_lsys_krn_sys_getinfo.endpt = SELF; /* always store values at caller */ - m.m_lsys_krn_sys_getinfo.val_ptr = ptr; + m.m_lsys_krn_sys_getinfo.val_ptr = (vir_bytes)ptr; m.m_lsys_krn_sys_getinfo.val_len = len; - m.m_lsys_krn_sys_getinfo.val_ptr2 = ptr2; + m.m_lsys_krn_sys_getinfo.val_ptr2 = (vir_bytes)ptr2; m.m_lsys_krn_sys_getinfo.val_len2_e = len2; return(_kernel_call(SYS_GETINFO, &m)); diff --git a/minix/lib/libsys/sys_safecopy.c b/minix/lib/libsys/sys_safecopy.c index 2db46f9a8..1b097b24d 100644 --- a/minix/lib/libsys/sys_safecopy.c +++ b/minix/lib/libsys/sys_safecopy.c @@ -16,7 +16,7 @@ int sys_safecopyfrom(endpoint_t src_e, copy_mess.m_lsys_kern_safecopy.from_to = src_e; copy_mess.m_lsys_kern_safecopy.gid = gr_id; copy_mess.m_lsys_kern_safecopy.offset = offset; - copy_mess.m_lsys_kern_safecopy.address = address; + copy_mess.m_lsys_kern_safecopy.address = (void *)address; copy_mess.m_lsys_kern_safecopy.bytes = bytes; return(_kernel_call(SYS_SAFECOPYFROM, ©_mess)); @@ -36,7 +36,7 @@ int sys_safecopyto(endpoint_t dst_e, copy_mess.m_lsys_kern_safecopy.from_to = dst_e; copy_mess.m_lsys_kern_safecopy.gid = gr_id; copy_mess.m_lsys_kern_safecopy.offset = offset; - copy_mess.m_lsys_kern_safecopy.address = address; + copy_mess.m_lsys_kern_safecopy.address = (void *)address; copy_mess.m_lsys_kern_safecopy.bytes = bytes; return(_kernel_call(SYS_SAFECOPYTO, ©_mess)); diff --git a/minix/lib/libsys/sys_vircopy.c b/minix/lib/libsys/sys_vircopy.c index 28492950a..4ee5033ad 100644 --- a/minix/lib/libsys/sys_vircopy.c +++ b/minix/lib/libsys/sys_vircopy.c @@ -1,4 +1,5 @@ #include "syslib.h" +#include int sys_vircopy(src_proc, src_vir, dst_proc, dst_vir, bytes, flags) diff --git a/minix/lib/libsys/sysutil.h b/minix/lib/libsys/sysutil.h index 497f755f9..88be29f59 100644 --- a/minix/lib/libsys/sysutil.h +++ b/minix/lib/libsys/sysutil.h @@ -1,7 +1,5 @@ /* sysutil.h - System library utilities. */ -#define _SYSTEM - #include /* common to all libraries */ #include /* need task numbers + message types */ #include /* need ipc_sendrec, _taskcall, etc */ diff --git a/minix/lib/libsys/vm_cache.c b/minix/lib/libsys/vm_cache.c index 75a193be7..c94c1e2f8 100644 --- a/minix/lib/libsys/vm_cache.c +++ b/minix/lib/libsys/vm_cache.c @@ -12,8 +12,9 @@ #include #include -int vm_cachecall(message *m, int call, void *addr, dev_t dev, off_t dev_offset, - ino_t ino, off_t ino_offset, u32_t *flags, int blocksize) +static int vm_cachecall(message *m, int call, void *addr, dev_t dev, + off_t dev_offset, ino_t ino, off_t ino_offset, u32_t *flags, + int blocksize) { if(blocksize % PAGE_SIZE) panic("blocksize %d should be a multiple of pagesize %d\n", diff --git a/minix/lib/libsys/vm_map_phys.c b/minix/lib/libsys/vm_map_phys.c index 1635c0e6e..40b59f858 100644 --- a/minix/lib/libsys/vm_map_phys.c +++ b/minix/lib/libsys/vm_map_phys.c @@ -13,7 +13,7 @@ vm_map_phys(endpoint_t who, void *phaddr, size_t len) memset(&m, 0, sizeof(m)); m.m_lsys_vm_map_phys.ep = who; - m.m_lsys_vm_map_phys.phaddr = phaddr; + m.m_lsys_vm_map_phys.phaddr = (phys_bytes)phaddr; m.m_lsys_vm_map_phys.len = len; r = _taskcall(VM_PROC_NR, VM_MAP_PHYS, &m);