From: Kees van Reeuwijk Date: Mon, 22 Mar 2010 20:43:06 +0000 (+0000) Subject: Miscellaneous code cleanup. X-Git-Tag: v3.1.7~215 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/rndc.html?a=commitdiff_plain;h=c33102ea6be514b25ab343b3d482add240b56c21;p=minix.git Miscellaneous code cleanup. --- diff --git a/commands/simple/at.c b/commands/simple/at.c index d9fb88b21..506a744d2 100644 --- a/commands/simple/at.c +++ b/commands/simple/at.c @@ -13,9 +13,9 @@ #include #define STARTDAY 0 /* see ctime(3) */ -#define LEAPDAY STARTDAY+59 -#define MAXDAYNR STARTDAY+365 -#define NODAY -2 +#define LEAPDAY (STARTDAY+59) +#define MAXDAYNR (STARTDAY+365) +#define NODAY (-2) char CRONPID[] = "/usr/run/cron.pid"; _PROTOTYPE(int main, (int argc, char **argv, char **envp)); diff --git a/commands/simple/cat.c b/commands/simple/cat.c index 65824dbfc..2931be2fc 100644 --- a/commands/simple/cat.c +++ b/commands/simple/cat.c @@ -20,11 +20,10 @@ static char ibuf[CHUNK_SIZE]; static char obuf[CHUNK_SIZE]; static char *op = obuf; -int main(int argc, char **argv); static void copyout(char *file, int fd); static void output(char *buf, size_t count); -static void report(char *label); -static void fatal(char *label); +static void report(const char *label); +static void fatal(const char *label); static char STDIN[] = "standard input"; static char STDOUT[] = "standard output"; @@ -76,7 +75,7 @@ int main(int argc, char *argv[]) return(excode); } -static void copyout(char *file, int fd) +static void copyout(const char *file, int fd) { int n; @@ -120,7 +119,7 @@ static void output(char *buf, size_t count) } } -static void report(char *label) +static void report(const char *label) { int e = errno; std_err("cat: "); @@ -131,7 +130,7 @@ static void report(char *label) excode = 1; } -static void fatal(char *label) +static void fatal(const char *label) { report(label); exit(1); diff --git a/drivers/orinoco/orinoco.c b/drivers/orinoco/orinoco.c index 79638899e..ef5f24625 100644 --- a/drivers/orinoco/orinoco.c +++ b/drivers/orinoco/orinoco.c @@ -211,10 +211,10 @@ _PROTOTYPE (static void or_reset, (void)); _PROTOTYPE (static void or_watchdog_f, (timer_t *tp) ); _PROTOTYPE (static void setup_wepkey, (t_or *orp, char *wepkey0) ); _PROTOTYPE (static void or_getstat, (message *m)); -_PROTOTYPE (static int do_hard_int, (void)); +_PROTOTYPE (static void do_hard_int, (void)); _PROTOTYPE (static void check_int_events, (void)); _PROTOTYPE (static void or_getname, (message *m)); -_PROTOTYPE (static int or_handler, (t_or *orp)); +_PROTOTYPE (static void or_handler, (t_or *orp)); _PROTOTYPE (static void or_dump, (message *m)); /* The message used in the main loop is made global, so that rl_watchdog_f() @@ -425,7 +425,8 @@ static void or_getname(message *mp) { * * * Process the interrupts which the card generated * *****************************************************************************/ -static int do_hard_int(void) { +static void do_hard_int(void) +{ u16_t evstat; hermes_t *hw; int i,s; @@ -1108,7 +1109,8 @@ static void or_rec_mode (t_or * orp) { * like EV_INFO and EV_RX have to be handled before an acknowledgement for * * the event is returned to the card. See also the documentation * *****************************************************************************/ -static int or_handler (t_or *orp) { +static void or_handler (t_or *orp) +{ int i, err, length, nr = 0; u16_t evstat, events, fid; hermes_t *hw; diff --git a/drivers/rtl8139/rtl8139.c b/drivers/rtl8139/rtl8139.c index fe3f87fab..23c05c0f9 100644 --- a/drivers/rtl8139/rtl8139.c +++ b/drivers/rtl8139/rtl8139.c @@ -172,7 +172,7 @@ _PROTOTYPE( static void rl_getname, (message *mp) ); _PROTOTYPE( static void reply, (re_t *rep, int err, int may_block) ); _PROTOTYPE( static void mess_reply, (message *req, message *reply) ); _PROTOTYPE( static void check_int_events, (void) ); -_PROTOTYPE( static int do_hard_int, (void) ); +_PROTOTYPE( static void do_hard_int, (void) ); _PROTOTYPE( static void rtl8139_dump, (message *m) ); #if 0 _PROTOTYPE( static void dump_phy, (re_t *rep) ); @@ -2402,7 +2402,7 @@ re_t *rep; } #endif -static int do_hard_int(void) +static void do_hard_int(void) { int i,s; diff --git a/drivers/sb16/sb16_mixer.c b/drivers/sb16/sb16_mixer.c index 74985ad22..c3724c828 100644 --- a/drivers/sb16/sb16_mixer.c +++ b/drivers/sb16/sb16_mixer.c @@ -330,8 +330,8 @@ PRIVATE int get_set_input(message *m_ptr, int flag, int channel) mixer_set(input_cmd, mask); } else { /* Get input */ if (shift > 0) { - input.left = ((mask >> (shift+1)) & 1 == 1 ? ON : OFF); - input.right = ((mask >> shift) & 1 == 1 ? ON : OFF); + input.left = (((mask >> (shift+1)) & 1) == 1 ? ON : OFF); + input.right = (((mask >> shift) & 1) == 1 ? ON : OFF); } else { input.left = ((mask & 1) == 1 ? ON : OFF); } @@ -387,8 +387,8 @@ PRIVATE int get_set_output(message *m_ptr, int flag) mixer_set(MIXER_OUTPUT_CTRL, mask); } else { /* Get input */ if (shift > 0) { - output.left = ((mask >> (shift+1)) & 1 == 1 ? ON : OFF); - output.right = ((mask >> shift) & 1 == 1 ? ON : OFF); + output.left = (((mask >> (shift+1)) & 1) == 1 ? ON : OFF); + output.right = (((mask >> shift) & 1) == 1 ? ON : OFF); } else { output.left = ((mask & 1) == 1 ? ON : OFF); } diff --git a/kernel/arch/i386/apic.c b/kernel/arch/i386/apic.c index dc9933841..32b6d8bb7 100644 --- a/kernel/arch/i386/apic.c +++ b/kernel/arch/i386/apic.c @@ -49,7 +49,7 @@ PUBLIC int reboot_type; PUBLIC int ioapic_enabled; PUBLIC u32_t ioapic_id_mask[8], lapic_id_mask[8]; PUBLIC u32_t lapic_addr_vaddr; -PUBLIC u32_t lapic_addr; +PUBLIC vir_bytes lapic_addr; PUBLIC u32_t lapic_eoi_addr; PUBLIC u32_t lapic_taskpri_addr; PUBLIC int bsp_lapic_id; diff --git a/kernel/arch/i386/apic.h b/kernel/arch/i386/apic.h index 8b7587c0a..4167390ac 100644 --- a/kernel/arch/i386/apic.h +++ b/kernel/arch/i386/apic.h @@ -93,7 +93,7 @@ #include "../../kernel.h" EXTERN int ioapic_enabled; -EXTERN u32_t lapic_addr; +EXTERN vir_bytes lapic_addr; EXTERN u32_t lapic_eoi_addr; EXTERN u32_t lapic_taskpri_addr; EXTERN int bsp_lapic_id; diff --git a/kernel/arch/i386/do_sdevio.c b/kernel/arch/i386/do_sdevio.c index df4a1b441..517d0651a 100644 --- a/kernel/arch/i386/do_sdevio.c +++ b/kernel/arch/i386/do_sdevio.c @@ -25,8 +25,9 @@ PUBLIC int do_sdevio(struct proc * caller, message *m_ptr) { vir_bytes newoffset; endpoint_t newep; - int proc_nr, proc_nr_e = m_ptr->DIO_VEC_ENDPT; - int count = m_ptr->DIO_VEC_SIZE; + int proc_nr; + endpoint_t proc_nr_e = m_ptr->DIO_VEC_ENDPT; + vir_bytes count = m_ptr->DIO_VEC_SIZE; long port = m_ptr->DIO_PORT; phys_bytes phys_buf; int i, req_type, req_dir, size, nr_io_range; diff --git a/kernel/arch/i386/exception.c b/kernel/arch/i386/exception.c index 23031c17c..334938df8 100644 --- a/kernel/arch/i386/exception.c +++ b/kernel/arch/i386/exception.c @@ -11,8 +11,7 @@ #include "../../proc.h" #include "../../proto.h" -extern int vm_copy_in_progress, catch_pagefaults; -extern struct proc *vm_copy_from, *vm_copy_to; +extern int catch_pagefaults; void pagefault( struct proc *pr, struct exception_frame * frame, diff --git a/kernel/arch/i386/memory.c b/kernel/arch/i386/memory.c index 99745da74..4eaa6d82d 100644 --- a/kernel/arch/i386/memory.c +++ b/kernel/arch/i386/memory.c @@ -142,7 +142,7 @@ PRIVATE int lin_lin_copy(struct proc *srcproc, vir_bytes srclinaddr, struct proc *dstproc, vir_bytes dstlinaddr, vir_bytes bytes) { u32_t addr; - int procslot; + proc_nr_t procslot; NOREC_ENTER(linlincopy); diff --git a/kernel/system.c b/kernel/system.c index 2137559ee..28ab09cd1 100644 --- a/kernel/system.c +++ b/kernel/system.c @@ -85,7 +85,6 @@ PRIVATE void kernel_call_finish(struct proc * caller, message *msg, int result) caller->p_delivermsg_vir, caller->p_name, caller->p_endpoint); - result = EBADREQUEST; } } } diff --git a/kernel/type.h b/kernel/type.h index dfd29788f..706a068d9 100644 --- a/kernel/type.h +++ b/kernel/type.h @@ -32,7 +32,7 @@ typedef struct irq_hook { int (*handler)(struct irq_hook *); /* interrupt handler */ int irq; /* IRQ vector number */ int id; /* id of this hook */ - int proc_nr_e; /* (endpoint) NONE if not in use */ + endpoint_t proc_nr_e; /* (endpoint) NONE if not in use */ irq_id_t notify_id; /* id to return on interrupt */ irq_policy_t policy; /* bit mask for policy */ } irq_hook_t; diff --git a/servers/inet/generic/udp.c b/servers/inet/generic/udp.c index fa8085ab2..7b511ea10 100644 --- a/servers/inet/generic/udp.c +++ b/servers/inet/generic/udp.c @@ -806,11 +806,9 @@ udp_fd_t *udp_fd; return NW_SUSPEND; } -PRIVATE int udp_sel_read (udp_fd) -udp_fd_t *udp_fd; +PRIVATE int udp_sel_read (udp_fd_t *udp_fd) { - acc_t *pack, *tmp_acc, *next_acc; - int result; + acc_t *tmp_acc, *next_acc; if (!(udp_fd->uf_flags & UFF_OPTSET)) return 1; /* Read will not block */ diff --git a/servers/ipc/sem.c b/servers/ipc/sem.c index f4f3cbc63..a6a9c2330 100644 --- a/servers/ipc/sem.c +++ b/servers/ipc/sem.c @@ -287,7 +287,6 @@ PUBLIC int do_semctl(message *m) unsigned short *buf; struct semid_ds *ds, tmp_ds; struct sem_struct *sem; - struct semaphore *semaphore; id = m->SEMCTL_ID; num = m->SEMCTL_NUM; diff --git a/servers/ipc/shm.c b/servers/ipc/shm.c index 7c08c7f11..550cda8be 100644 --- a/servers/ipc/shm.c +++ b/servers/ipc/shm.c @@ -184,10 +184,9 @@ PUBLIC void update_refcount_and_destroy(void) *===========================================================================*/ PUBLIC int do_shmdt(message *m) { - struct shm_struct *shm; vir_bytes addr; phys_bytes paddr; - int n, i; + int i; addr = m->SHMDT_ADDR; diff --git a/servers/is/dmp_rs.c b/servers/is/dmp_rs.c index 96341456c..60e8ec317 100644 --- a/servers/is/dmp_rs.c +++ b/servers/is/dmp_rs.c @@ -26,7 +26,7 @@ PUBLIC void rproc_dmp() { struct rproc *rp; struct rprocpub *rpub; - int i,j, n=0; + int i, n=0; static int prev_i=0; getsysinfo(RS_PROC_NR, SI_PROCPUB_TAB, rprocpub); diff --git a/servers/iso9660fs/const.h b/servers/iso9660fs/const.h index e3808a4c0..adbc9a1c8 100644 --- a/servers/iso9660fs/const.h +++ b/servers/iso9660fs/const.h @@ -13,8 +13,8 @@ * maximum number of ids the filesystem can * handle */ -#define NO_ADDRESS -1 /* Error constants */ -#define NO_FREE_INODES -1 +#define NO_ADDRESS (-1) /* Error constants */ +#define NO_FREE_INODES (-1) #define PATH_PENULTIMATE 001 /* parse_path stops at last but one name */ #define PATH_NONSYMBOLIC 004 /* parse_path scans final name if symbolic */ diff --git a/servers/iso9660fs/device.c b/servers/iso9660fs/device.c index 623eda530..b5c575589 100644 --- a/servers/iso9660fs/device.c +++ b/servers/iso9660fs/device.c @@ -41,7 +41,7 @@ void **buf; int *vec_grants; vir_bytes bytes; { - int access = 0, size; + int size; int j; iovec_t *v; static iovec_t new_iovec[NR_IOREQS]; diff --git a/servers/iso9660fs/mount.c b/servers/iso9660fs/mount.c index 4367b7147..eb5cd4b98 100644 --- a/servers/iso9660fs/mount.c +++ b/servers/iso9660fs/mount.c @@ -1,6 +1,4 @@ #include "inc.h" -#include -#include #include #include #include "const.h" @@ -71,14 +69,14 @@ PUBLIC int fs_readsuper() { /*===========================================================================* * fs_mountpoint * *===========================================================================*/ -PUBLIC int fs_mountpoint() { +PUBLIC int fs_mountpoint() +{ /* This function looks up the mount point, it checks the condition whether * the partition can be mounted on the inode or not. */ register struct dir_record *rip; int r = OK; - mode_t bits; /* Temporarily open the file. */ if ((rip = get_dir_record(fs_m_in.REQ_INODE_NR)) == NULL) diff --git a/servers/vfs/select.c b/servers/vfs/select.c index 550acc40d..e435b43a1 100644 --- a/servers/vfs/select.c +++ b/servers/vfs/select.c @@ -89,7 +89,7 @@ PUBLIC int do_select(void) * timeout and wait for either the file descriptors to become ready or the * timer to go off. If no timeout value was provided, we wait indefinitely. */ - int r, nfds, do_timeout = 0, nonzero_timeout = 0, fd, s; + int r, nfds, do_timeout = 0, fd, s; struct timeval timeout; struct selectentry *se;