From: Kees van Reeuwijk Date: Wed, 27 Jan 2010 10:19:13 +0000 (+0000) Subject: Rewrite some functions to ANSI style. X-Git-Tag: v3.1.6~20 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=c6eb51d66a9ac8a00c5909b6e1b39d7e6e7379ec;p=minix.git Rewrite some functions to ANSI style. --- diff --git a/drivers/filter/inc.h b/drivers/filter/inc.h index f3b95fdad..454df114b 100644 --- a/drivers/filter/inc.h +++ b/drivers/filter/inc.h @@ -20,18 +20,18 @@ #define SECTOR_SIZE 512 -enum { +typedef enum { ST_NIL, /* Zero checksums */ ST_XOR, /* XOR-based checksums */ ST_CRC, /* CRC32-based checksums */ ST_MD5 /* MD5-based checksums */ -}; +} checksum_type; -enum { +typedef enum { FLT_WRITE, /* write to up to two disks */ FLT_READ, /* read from one disk */ FLT_READ2 /* read from both disks */ -}; +} disk_operation; /* Something was wrong and the disk driver has been restarted/refreshed, * so the request needs to be redone. @@ -43,13 +43,13 @@ enum { * BD_PROTO: a protocol error has occurred. Refresh it. * BD_DATA: a data error has occurred. Refresh it. */ -enum { +typedef enum { BD_NONE, BD_DEAD, BD_PROTO, BD_DATA, BD_LAST -}; +} driver_state; #define DRIVER_MAIN 0 #define DRIVER_BACKUP 1 diff --git a/drivers/filter/optset.h b/drivers/filter/optset.h index 87ea4ce9f..411d80452 100644 --- a/drivers/filter/optset.h +++ b/drivers/filter/optset.h @@ -1,11 +1,11 @@ #ifndef _OPTSET_H #define _OPTSET_H -enum { +typedef enum { OPT_BOOL, OPT_STRING, OPT_INT -}; +} opt_type; /* An entry for the parser of an options set. The 'os_name' field must point * to a string, which is treated case-insensitively; the last entry of a table @@ -20,7 +20,7 @@ enum { */ struct optset { char *os_name; - int os_type; + opt_type os_type; void *os_ptr; int os_val; }; diff --git a/drivers/floppy/floppy.c b/drivers/floppy/floppy.c index 263e19754..86cd7a882 100644 --- a/drivers/floppy/floppy.c +++ b/drivers/floppy/floppy.c @@ -24,7 +24,6 @@ #include "floppy.h" #include -#include #include #include #include diff --git a/drivers/lance/lance.c b/drivers/lance/lance.c index c2a1c85ff..55d349a58 100644 --- a/drivers/lance/lance.c +++ b/drivers/lance/lance.c @@ -42,7 +42,6 @@ #include "../drivers.h" -#include #include #include #include diff --git a/drivers/memory/memory.c b/drivers/memory/memory.c index 231a74161..736fe4ba7 100644 --- a/drivers/memory/memory.c +++ b/drivers/memory/memory.c @@ -18,7 +18,6 @@ #include "../drivers.h" #include "../libdriver/driver.h" #include -#include #include #include #include @@ -26,11 +25,8 @@ #include "../../kernel/config.h" #include "../../kernel/type.h" -#include #include -#include "assert.h" - #include "local.h" /* ramdisks (/dev/ram*) */ diff --git a/drivers/memory/ramdisk/bintoc.c b/drivers/memory/ramdisk/bintoc.c index 36d6def6a..b4c532026 100644 --- a/drivers/memory/ramdisk/bintoc.c +++ b/drivers/memory/ramdisk/bintoc.c @@ -14,8 +14,8 @@ for initializing a character array in C. #include #include -char *progname; -unsigned char buf[1024]; +static char *progname; +static unsigned char buf[1024]; static void fatal(char *fmt, ...); static void usage(void); diff --git a/drivers/orinoco/hermes.c b/drivers/orinoco/hermes.c index 095553be6..8a65b8a03 100644 --- a/drivers/orinoco/hermes.c +++ b/drivers/orinoco/hermes.c @@ -37,12 +37,8 @@ */ #include "hermes.h" -#include -#include "assert.h" -#include -#include "string.h" -int this_proc; +PRIVATE int this_proc; /***************************************************************************** * milli_delay * diff --git a/drivers/orinoco/orinoco.c b/drivers/orinoco/orinoco.c index 17302cd47..b337292be 100644 --- a/drivers/orinoco/orinoco.c +++ b/drivers/orinoco/orinoco.c @@ -55,13 +55,10 @@ #include "../drivers.h" #include -#include -#include #include #include #include #include -#include #include #include #include @@ -96,7 +93,6 @@ static tmra_ut or_watchdog; #include #include #include -#include #include #include diff --git a/drivers/pci/main.c b/drivers/pci/main.c index 67c7c94fd..982aff1e5 100644 --- a/drivers/pci/main.c +++ b/drivers/pci/main.c @@ -4,7 +4,6 @@ main.c #include "../drivers.h" -#include #include #include diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 72393c568..bc26622a3 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -29,7 +29,6 @@ Created: Jan 2000 by Philip Homburg #include #include -#include #include #define PBT_INTEL_HOST 1 diff --git a/drivers/random/main.c b/drivers/random/main.c index bb1d332e3..188833796 100644 --- a/drivers/random/main.c +++ b/drivers/random/main.c @@ -5,7 +5,6 @@ #include "../drivers.h" #include "../libdriver/driver.h" -#include #include #include "assert.h" diff --git a/drivers/rtl8169/rtl8169.c b/drivers/rtl8169/rtl8169.c index d165eac00..bbdb4bd94 100644 --- a/drivers/rtl8169/rtl8169.c +++ b/drivers/rtl8169/rtl8169.c @@ -11,10 +11,8 @@ #include #include #include -#include #include #include -#include #include #include #include @@ -26,10 +24,8 @@ #include #include -#include #include #include -#include #include "../../kernel/const.h" #include "../../kernel/config.h" #include "../../kernel/type.h" diff --git a/drivers/sb16/sb16_dsp.c b/drivers/sb16/sb16_dsp.c index d4ade9fb0..67e7ca935 100644 --- a/drivers/sb16/sb16_dsp.c +++ b/drivers/sb16/sb16_dsp.c @@ -233,8 +233,7 @@ PRIVATE int dsp_close() /*===========================================================================* * dsp_ioctl *===========================================================================*/ -PRIVATE int dsp_ioctl(m_ptr) -message *m_ptr; +PRIVATE int dsp_ioctl(message *m_ptr) { int status; phys_bytes user_phys; @@ -274,8 +273,7 @@ message *m_ptr; /*===========================================================================* * dsp_write *===========================================================================*/ -PRIVATE void dsp_write(m_ptr) -message *m_ptr; +PRIVATE void dsp_write(message *m_ptr) { int s; message mess; @@ -381,8 +379,8 @@ PRIVATE void dsp_hardware_msg() /*===========================================================================* * dsp_status * *===========================================================================*/ -PRIVATE void dsp_status(m_ptr) -message *m_ptr; /* pointer to the newly arrived message */ +PRIVATE void dsp_status(message *m_ptr) +/* m_ptr pointer to the newly arrived message */ { if(revivePending) { m_ptr->m_type = DEV_REVIVE; /* build message */ @@ -404,11 +402,7 @@ message *m_ptr; /* pointer to the newly arrived message */ /*===========================================================================* * reply * *===========================================================================*/ -PRIVATE void reply(code, replyee, process, status) -int code; -int replyee; -int process; -int status; +PRIVATE void reply(int code, int replyee, int process, int status) { message m; @@ -491,8 +485,7 @@ PRIVATE int dsp_reset() /*===========================================================================* * dsp_command *===========================================================================*/ -PRIVATE int dsp_command(value) -int value; +PRIVATE int dsp_command(int value) { int i, status; @@ -511,8 +504,7 @@ int value; /*===========================================================================* * dsp_set_size *===========================================================================*/ -static int dsp_set_size(size) -unsigned int size; +static int dsp_set_size(unsigned int size) { dprint("dsp_set_size(): set fragment size to %u\n", size); @@ -530,8 +522,7 @@ unsigned int size; /*===========================================================================* * dsp_set_speed *===========================================================================*/ -static int dsp_set_speed(speed) -unsigned int speed; +static int dsp_set_speed(unsigned int speed) { dprint("sb16: setting speed to %u, stereo = %d\n", speed, DspStereo); @@ -562,8 +553,7 @@ unsigned int speed; /*===========================================================================* * dsp_set_stereo *===========================================================================*/ -static int dsp_set_stereo(stereo) -unsigned int stereo; +static int dsp_set_stereo(unsigned int stereo) { if(stereo) { DspStereo = 1; @@ -578,8 +568,7 @@ unsigned int stereo; /*===========================================================================* * dsp_set_bits *===========================================================================*/ -static int dsp_set_bits(bits) -unsigned int bits; +static int dsp_set_bits(unsigned int bits) { /* Sanity checks */ if(bits != 8 && bits != 16) { @@ -595,8 +584,7 @@ unsigned int bits; /*===========================================================================* * dsp_set_sign *===========================================================================*/ -static int dsp_set_sign(sign) -unsigned int sign; +static int dsp_set_sign(unsigned int sign) { dprint("sb16: set sign to %u\n", sign); @@ -609,9 +597,7 @@ unsigned int sign; /*===========================================================================* * dsp_dma_setup *===========================================================================*/ -PRIVATE void dsp_dma_setup(address, count) -phys_bytes address; -int count; +PRIVATE void dsp_dma_setup(phys_bytes address, int count) { pvb_pair_t pvb[9]; diff --git a/drivers/sb16/sb16_mixer.c b/drivers/sb16/sb16_mixer.c index 87fbf37e1..74985ad22 100644 --- a/drivers/sb16/sb16_mixer.c +++ b/drivers/sb16/sb16_mixer.c @@ -109,8 +109,7 @@ PRIVATE void sef_local_startup() /*=========================================================================* * mixer_open *=========================================================================*/ -PRIVATE int mixer_open(m_ptr) -message *m_ptr; +PRIVATE int mixer_open(message *m_ptr) { dprint("mixer_open\n"); @@ -124,8 +123,7 @@ message *m_ptr; /*=========================================================================* * mixer_close *=========================================================================*/ -PRIVATE int mixer_close(m_ptr) -message *m_ptr; +PRIVATE int mixer_close(message *m_ptr) { dprint("mixer_close\n"); @@ -136,8 +134,7 @@ message *m_ptr; /*=========================================================================* * mixer_ioctl *=========================================================================*/ -PRIVATE int mixer_ioctl(m_ptr) -message *m_ptr; +PRIVATE int mixer_ioctl(message *m_ptr) { int status; @@ -188,8 +185,7 @@ PRIVATE int mixer_init() /*=========================================================================* * mixer_get *=========================================================================*/ -PRIVATE int mixer_get(reg) -int reg; +PRIVATE int mixer_get(int reg) { int i; @@ -202,9 +198,8 @@ int reg; /*=========================================================================* * get_set_volume * *=========================================================================*/ -PRIVATE int get_set_volume(m_ptr, flag) -message *m_ptr; -int flag; /* 0 = get, 1 = set */ +PRIVATE int get_set_volume(message *m_ptr, int flag) +/* flag 0 = get, 1 = set */ { phys_bytes user_phys; struct volume_level level; @@ -286,10 +281,11 @@ int flag; /* 0 = get, 1 = set */ /*=========================================================================* * get_set_input * *=========================================================================*/ -PRIVATE int get_set_input(m_ptr, flag, channel) -message *m_ptr; -int flag; /* 0 = get, 1 = set */ -int channel; /* 0 = left, 1 = right */ +PRIVATE int get_set_input(message *m_ptr, int flag, int channel) +/* + * flag 0 = get, 1 = set + * channel 0 = left, 1 = right + */ { phys_bytes user_phys; struct inout_ctrl input; @@ -351,9 +347,8 @@ int channel; /* 0 = left, 1 = right */ /*=========================================================================* * get_set_output * *=========================================================================*/ -PRIVATE int get_set_output(m_ptr, flag) -message *m_ptr; -int flag; /* 0 = get, 1 = set */ +PRIVATE int get_set_output(message *m_ptr, int flag) +/* flag 0 = get, 1 = set */ { phys_bytes user_phys; struct inout_ctrl output; diff --git a/drivers/ti1225/ti1225.c b/drivers/ti1225/ti1225.c index 9ada092e6..2cc69a229 100644 --- a/drivers/ti1225/ti1225.c +++ b/drivers/ti1225/ti1225.c @@ -6,7 +6,6 @@ Created: Dec 2005 by Philip Homburg #include "../drivers.h" #include -#include #include #include "ti1225.h" diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index d7949f8c5..3949a7015 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -82,9 +82,7 @@ FORWARD _PROTOTYPE( int pty_select, (tty_t *tp, message *m) ); /*===========================================================================* * do_pty * *===========================================================================*/ -PUBLIC void do_pty(tp, m_ptr) -tty_t *tp; -message *m_ptr; +PUBLIC void do_pty(tty_t *tp, message *m_ptr) { /* Perform an open/close/read/write call on a /dev/ptypX device. */ pty_t *pp = tp->tty_priv; @@ -203,9 +201,7 @@ message *m_ptr; /*===========================================================================* * pty_write * *===========================================================================*/ -PRIVATE int pty_write(tp, try) -tty_t *tp; -int try; +PRIVATE int pty_write(tty_t *tp, int try) { /* (*dev_write)() routine for PTYs. Transfer bytes from the writer on * /dev/ttypX to the output buffer. @@ -289,9 +285,7 @@ int try; /*===========================================================================* * pty_echo * *===========================================================================*/ -PRIVATE void pty_echo(tp, c) -tty_t *tp; -int c; +PRIVATE void pty_echo(tty_t *tp, int c) { /* Echo one character. (Like pty_write, but only one character, optionally.) */ @@ -314,8 +308,7 @@ int c; /*===========================================================================* * pty_start * *===========================================================================*/ -PRIVATE void pty_start(pp) -pty_t *pp; +PRIVATE void pty_start(pty_t *pp) { /* Transfer bytes written to the output buffer to the PTY reader. */ int count; @@ -355,8 +348,7 @@ pty_t *pp; /*===========================================================================* * pty_finish * *===========================================================================*/ -PRIVATE void pty_finish(pp) -pty_t *pp; +PRIVATE void pty_finish(pty_t *pp) { /* Finish the read request of a PTY reader if there is at least one byte * transferred. @@ -375,9 +367,7 @@ pty_t *pp; /*===========================================================================* * pty_read * *===========================================================================*/ -PRIVATE int pty_read(tp, try) -tty_t *tp; -int try; +PRIVATE int pty_read(tty_t *tp, int try) { /* Offer bytes from the PTY writer for input on the TTY. (Do it one byte at * a time, 99% of the writes will be for one byte, so no sense in being smart.) @@ -448,9 +438,7 @@ int try; /*===========================================================================* * pty_close * *===========================================================================*/ -PRIVATE int pty_close(tp, try) -tty_t *tp; -int try; +PRIVATE int pty_close(tty_t *tp, int try) { /* The tty side has closed, so shut down the pty side. */ pty_t *pp = tp->tty_priv; @@ -475,9 +463,7 @@ int try; /*===========================================================================* * pty_icancel * *===========================================================================*/ -PRIVATE int pty_icancel(tp, try) -tty_t *tp; -int try; +PRIVATE int pty_icancel(tty_t *tp, int try) { /* Discard waiting input. */ pty_t *pp = tp->tty_priv; @@ -494,9 +480,7 @@ int try; /*===========================================================================* * pty_ocancel * *===========================================================================*/ -PRIVATE int pty_ocancel(tp, try) -tty_t *tp; -int try; +PRIVATE int pty_ocancel(tty_t *tp, int try) { /* Drain the output buffer. */ pty_t *pp = tp->tty_priv; @@ -510,8 +494,7 @@ int try; /*===========================================================================* * pty_init * *===========================================================================*/ -PUBLIC void pty_init(tp) -tty_t *tp; +PUBLIC void pty_init(tty_t *tp) { pty_t *pp; int line; diff --git a/drivers/tty/rs232.c b/drivers/tty/rs232.c index 306624042..0959eb90f 100644 --- a/drivers/tty/rs232.c +++ b/drivers/tty/rs232.c @@ -212,9 +212,7 @@ PRIVATE int my_inb(port_t port) /*===========================================================================* * rs_write * *===========================================================================*/ -PRIVATE int rs_write(tp, try) -register tty_t *tp; -int try; +PRIVATE int rs_write(register tty_t *tp, int try) { /* (*devwrite)() routine for RS232. */ @@ -335,9 +333,8 @@ int c; /* character to echo */ /*===========================================================================* * rs_ioctl * *===========================================================================*/ -PRIVATE int rs_ioctl(tp, dummy) -tty_t *tp; /* which TTY */ -int dummy; +PRIVATE int rs_ioctl(tty_t *tp, int dummy) +/* tp; which TTY */ { /* Reconfigure the line as soon as the output has drained. */ rs232_t *rs = tp->tty_priv; @@ -349,8 +346,8 @@ int dummy; /*===========================================================================* * rs_config * *===========================================================================*/ -PRIVATE void rs_config(rs) -rs232_t *rs; /* which line */ +PRIVATE void rs_config(rs232_t *rs) +/* rs which line */ { /* Set various line control parameters for RS232 I/O. * If DataBits == 5 and StopBits == 2, 8250 will generate 1.5 stop bits. @@ -435,8 +432,8 @@ rs232_t *rs; /* which line */ /*===========================================================================* * rs_init * *===========================================================================*/ -PUBLIC void rs_init(tp) -tty_t *tp; /* which TTY */ +PUBLIC void rs_init(tty_t *tp) +/* tp which TTY */ { unsigned long dummy; /* Initialize RS232 for one line. */ @@ -539,8 +536,7 @@ tty_t *tp; /* which TTY */ /*===========================================================================* * rs_interrupt * *===========================================================================*/ -PUBLIC void rs_interrupt(m) -message *m; /* which TTY */ +PUBLIC void rs_interrupt(message *m) { unsigned long irq_set; int i; @@ -557,9 +553,7 @@ message *m; /* which TTY */ /*===========================================================================* * rs_icancel * *===========================================================================*/ -PRIVATE int rs_icancel(tp, dummy) -tty_t *tp; /* which TTY */ -int dummy; +PRIVATE int rs_icancel(tty_t *tp, int dummy) { /* Cancel waiting input. */ rs232_t *rs = tp->tty_priv; @@ -576,9 +570,7 @@ int dummy; /*===========================================================================* * rs_ocancel * *===========================================================================*/ -PRIVATE int rs_ocancel(tp, dummy) -tty_t *tp; /* which TTY */ -int dummy; +PRIVATE int rs_ocancel(tty_t *tp, int dummy) { /* Cancel pending output. */ rs232_t *rs = tp->tty_priv; @@ -595,9 +587,7 @@ int dummy; /*===========================================================================* * rs_read * *===========================================================================*/ -PRIVATE int rs_read(tp, try) -tty_t *tp; /* which tty */ -int try; +PRIVATE int rs_read(tty_t *tp, int try) { /* Process characters from the circular input buffer. */ @@ -644,8 +634,7 @@ int try; /*===========================================================================* * rs_ostart * *===========================================================================*/ -PRIVATE void rs_ostart(rs) -rs232_t *rs; /* which rs line */ +PRIVATE void rs_ostart(rs232_t *rs) { /* Tell RS232 there is something waiting in the output buffer. */ @@ -656,9 +645,7 @@ rs232_t *rs; /* which rs line */ /*===========================================================================* * rs_break * *===========================================================================*/ -PRIVATE int rs_break(tp, dummy) -tty_t *tp; /* which tty */ -int dummy; +PRIVATE int rs_break(tty_t *tp, int dummy) { /* Generate a break condition by setting the BREAK bit for 0.4 sec. */ rs232_t *rs = tp->tty_priv; @@ -676,9 +663,7 @@ int dummy; /*===========================================================================* * rs_close * *===========================================================================*/ -PRIVATE int rs_close(tp, dummy) -tty_t *tp; /* which tty */ -int dummy; +PRIVATE int rs_close(tty_t *tp, int dummy) { /* The line is closed; optionally hang up. */ rs232_t *rs = tp->tty_priv; @@ -694,8 +679,7 @@ int dummy; /*===========================================================================* * rs232_handler * *===========================================================================*/ -PRIVATE void rs232_handler(rs) -struct rs232 *rs; +PRIVATE void rs232_handler(struct rs232 *rs) { /* Interrupt hander for RS232. */ @@ -728,8 +712,8 @@ struct rs232 *rs; /*===========================================================================* * in_int * *===========================================================================*/ -PRIVATE void in_int(rs) -register rs232_t *rs; /* line with input interrupt */ +PRIVATE void in_int(register rs232_t *rs) +/* rs line with input interrupt */ { /* Read the data which just arrived. * If it is the oxoff char, clear OSWREADY, else if OSWREADY was clear, set @@ -776,12 +760,12 @@ register rs232_t *rs; /* line with input interrupt */ /*===========================================================================* * line_int * *===========================================================================*/ -PRIVATE void line_int(rs) -register rs232_t *rs; /* line with line status interrupt */ +PRIVATE void line_int(register rs232_t *rs) +/* rs line with line status interrupt */ { /* Check for and record errors. */ - unsigned long s; + unsigned long s; sys_inb(rs->line_status_port, &s); rs->lstatus = s; if (rs->lstatus & LS_FRAMING_ERR) ++rs->framing_errors; @@ -793,8 +777,8 @@ register rs232_t *rs; /* line with line status interrupt */ /*===========================================================================* * modem_int * *===========================================================================*/ -PRIVATE void modem_int(rs) -register rs232_t *rs; /* line with modem interrupt */ +PRIVATE void modem_int(register rs232_t *rs) +/* rs line with modem interrupt */ { /* Get possibly new device-ready status, and clear ODEVREADY if necessary. * If the device just became ready, restart output. @@ -817,8 +801,8 @@ register rs232_t *rs; /* line with modem interrupt */ /*===========================================================================* * out_int * *===========================================================================*/ -PRIVATE void out_int(rs) -register rs232_t *rs; /* line with output interrupt */ +PRIVATE void out_int(register rs232_t *rs) +/* rs; line with output interrupt */ { /* If there is output to do and everything is ready, do it (local device is * known ready).