Cleanup: convert K&R-style function definitions to ANSI-style in drivers

This task is stated at Minix TODO page. No feature changes are intended.
This commit is contained in:
Santurysim 2021-06-22 20:57:07 +03:00
parent 8ce8639b04
commit 61b7efb091
9 changed files with 129 additions and 166 deletions

View File

@ -36,7 +36,7 @@ int mixer_ioctl(unsigned long request, void *val, int *UNUSED(len)) {
/*=========================================================================*
* mixer_init
*=========================================================================*/
int mixer_init() {
int mixer_init(void) {
/* Try to detect the mixer by writing to MIXER_DAC_LEVEL if the
* value written can be read back the mixer is there
*/

View File

@ -67,7 +67,7 @@ int main(void)
/*===========================================================================*
* sef_local_startup *
*===========================================================================*/
static void sef_local_startup()
static void sef_local_startup(void)
{
/* Register init callbacks. */
sef_setcb_init_fresh(sef_cb_init_fresh);

View File

@ -34,7 +34,7 @@ static void add_sample(int source, unsigned long sample);
static void data_block(rd_keyinstance *keyp, void *data);
static void reseed(void);
void random_init()
void random_init(void)
{
int i, j;
@ -54,17 +54,14 @@ void random_init()
reseed_count= 0;
}
int random_isseeded()
int random_isseeded(void)
{
if (got_seeded)
return 1;
return 0;
}
void random_update(source, buf, count)
int source;
rand_t *buf;
int count;
void random_update(int source, rand_t *buf, int count)
{
int i;
@ -78,9 +75,7 @@ int count;
reseed();
}
void random_getbytes(buf, size)
void *buf;
size_t size;
void random_getbytes(void *buf, size_t size)
{
int n, r;
u8_t *cp;
@ -112,9 +107,7 @@ size_t size;
data_block(&key, random_key+AES_BLOCKSIZE);
}
void random_putbytes(buf, size)
void *buf;
size_t size;
void random_putbytes(void *buf, size_t size)
{
/* Add bits to pool zero */
SHA256_Update(&pool_ctx[0], buf, size);
@ -127,9 +120,7 @@ size_t size;
reseed();
}
static void add_sample(source, sample)
int source;
unsigned long sample;
static void add_sample(int source, unsigned long sample)
{
int i, pool_nr;
unsigned long d, v, di, min;
@ -178,9 +169,7 @@ unsigned long sample;
pool_ind[source]= pool_nr;
}
static void data_block(keyp, data)
rd_keyinstance *keyp;
void *data;
static void data_block(rd_keyinstance *keyp, void *data)
{
int r;
u8_t input[AES_BLOCKSIZE];
@ -203,7 +192,7 @@ void *data;
count_hi++;
}
static void reseed()
static void reseed(void)
{
int i;
SHA256_CTX ctx;

View File

@ -633,9 +633,9 @@ static int do_select(devminor_t minor, unsigned int ops, endpoint_t endpt)
/*===========================================================================*
* handle_events *
* tp: TTY to check for events *
*===========================================================================*/
void handle_events(tp)
tty_t *tp; /* TTY to check for events. */
void handle_events(tty_t *tp)
{
/* Handle any events pending on a TTY. */
@ -669,10 +669,10 @@ tty_t *tp; /* TTY to check for events. */
}
/*===========================================================================*
* in_transfer *
* in_transfer *
* tp: pointer to terminal to read from *
*===========================================================================*/
static void in_transfer(tp)
register tty_t *tp; /* pointer to terminal to read from */
static void in_transfer(register tty_t *tp)
{
/* Transfer bytes from the input queue to a process reading from a terminal. */
@ -732,12 +732,12 @@ register tty_t *tp; /* pointer to terminal to read from */
}
/*===========================================================================*
* in_process *
* in_process *
* tp: terminal on which character has arrived *
* buf: buffer with input characters *
* count: number of input characters *
*===========================================================================*/
int in_process(tp, buf, count)
register tty_t *tp; /* terminal on which character has arrived */
char *buf; /* buffer with input characters */
int count; /* number of input characters */
int in_process(register tty_t *tp, char *buf, int count)
{
/* Characters have just been typed in. Process, save, and echo them. Return
* the number of characters processed.
@ -897,11 +897,11 @@ int count; /* number of input characters */
}
/*===========================================================================*
* echo *
* echo *
* tp: terminal on which to echo *
* ch: pointer to character to echo *
*===========================================================================*/
static int tty_echo(tp, ch)
register tty_t *tp; /* terminal on which to echo */
register int ch; /* pointer to character to echo */
static int tty_echo(register tty_t *tp, register int ch)
{
/* Echo the character if echoing is on. Some control characters are echoed
* with their normal effect, other control characters are echoed as "^X",
@ -960,9 +960,7 @@ register int ch; /* pointer to character to echo */
/*===========================================================================*
* rawecho *
*===========================================================================*/
static void rawecho(tp, ch)
register tty_t *tp;
int ch;
static void rawecho(register tty_t *tp, int ch)
{
/* Echo without interpretation if ECHO is set. */
int rp = tp->tty_reprint;
@ -973,8 +971,7 @@ int ch;
/*===========================================================================*
* back_over *
*===========================================================================*/
static int back_over(tp)
register tty_t *tp;
static int back_over(register tty_t *tp)
{
/* Backspace to previous character on screen and erase it. */
u16_t *head;
@ -1001,9 +998,9 @@ register tty_t *tp;
/*===========================================================================*
* reprint *
* tp: pointer to tty struct *
*===========================================================================*/
static void reprint(tp)
register tty_t *tp; /* pointer to tty struct */
static void reprint(register tty_t *tp)
{
/* Restore what has been echoed to screen before if the user input has been
* messed up by output, or if REPRINT (^R) is typed.
@ -1039,13 +1036,13 @@ register tty_t *tp; /* pointer to tty struct */
}
/*===========================================================================*
* out_process *
* out_process *
* bstart/bpos/bend: start/pos/end of circular buffer *
* icount: # input chars / input chars used *
* ocount: max output chars / output chars used *
*===========================================================================*/
void out_process(tp, bstart, bpos, bend, icount, ocount)
tty_t *tp;
char *bstart, *bpos, *bend; /* start/pos/end of circular buffer */
int *icount; /* # input chars / input chars used */
int *ocount; /* max output chars / output chars used */
void out_process(tty_t *tp, char *bstart, char *bpos, char *bend, int *icount,
int *ocount)
{
/* Perform output processing on a circular buffer. *icount is the number of
* bytes to process, and the number of bytes actually processed on return.
@ -1126,8 +1123,7 @@ out_done:
/*===========================================================================*
* dev_ioctl *
*===========================================================================*/
static void dev_ioctl(tp)
tty_t *tp;
static void dev_ioctl(tty_t *tp)
{
/* The ioctl's TCSETSW, TCSETSF and TIOCDRAIN wait for output to finish to make
* sure that an attribute change doesn't affect the processing of current
@ -1152,8 +1148,7 @@ tty_t *tp;
/*===========================================================================*
* setattr *
*===========================================================================*/
static void setattr(tp)
tty_t *tp;
static void setattr(tty_t *tp)
{
/* Apply the new line attributes (raw/canonical, line speed, etc.) */
u16_t *inp;
@ -1201,11 +1196,9 @@ tty_t *tp;
/*===========================================================================*
* sigchar *
* sig: SIGINT, SIGQUIT, SIGKILL or SIGHUP *
*===========================================================================*/
void sigchar(tp, sig, mayflush)
register tty_t *tp;
int sig; /* SIGINT, SIGQUIT, SIGKILL or SIGHUP */
int mayflush;
void sigchar(tty_t *tp, int sig, int mayflush)
{
/* Process a SIGINT, SIGQUIT or SIGKILL char from the keyboard or SIGHUP from
* a tty close, "stty 0", or a real RS-232 hangup. PM will send the signal to
@ -1232,8 +1225,7 @@ int mayflush;
/*===========================================================================*
* tty_icancel *
*===========================================================================*/
static void tty_icancel(tp)
register tty_t *tp;
static void tty_icancel(register tty_t *tp)
{
/* Discard all pending input, tty buffer or device. */
@ -1300,11 +1292,11 @@ static void tty_timed_out(int arg)
}
/*===========================================================================*
* settimer *
* settimer *
* tty_ptr: line to set or unset a timer on *
* enable: set timer if true, otherwise unset *
*===========================================================================*/
static void settimer(tty_ptr, enable)
tty_t *tty_ptr; /* line to set or unset a timer on */
int enable; /* set timer if true, otherwise unset */
static void settimer(tty_t *tty_ptr, int enable)
{
clock_t ticks;

View File

@ -155,10 +155,9 @@ static struct chardriver video_tab = {
/*===========================================================================*
* cons_write *
* tp tells which terminal is to be used *
*===========================================================================*/
static int cons_write(tp, try)
register struct tty *tp; /* tells which terminal is to be used */
int try;
static int cons_write(register struct tty *tp, int try)
{
/* Copy as much data as possible to the output queue, then start I/O. On
* memory-mapped terminals, such as the IBM console, the I/O will also be
@ -236,10 +235,10 @@ int try;
/*===========================================================================*
* cons_echo *
* tp pointer to tty struct
* c character to be echoed
*===========================================================================*/
static void cons_echo(tp, c)
register tty_t *tp; /* pointer to tty struct */
int c; /* character to be echoed */
static void cons_echo(register tty_t *tp, int c)
{
/* Echo keyboard input (print & flush). */
console_t *cons = tp->tty_priv;
@ -250,10 +249,10 @@ int c; /* character to be echoed */
/*===========================================================================*
* out_char *
* cons - pointer to console struct
* c - character to output
*===========================================================================*/
static void out_char(cons, c)
register console_t *cons; /* pointer to console struct */
int c; /* character to be output */
static void out_char(register console_t *cons, int c)
{
/* Output a character on the console. Check for escape sequences first. */
if (cons->c_esc_state > 0) {
@ -345,10 +344,10 @@ int c; /* character to be output */
/*===========================================================================*
* scroll_screen *
* cons - pointer to console struct
* dir - SCROLL_UP or SCROLL_DOWN
*===========================================================================*/
static void scroll_screen(cons, dir)
register console_t *cons; /* pointer to console struct */
int dir; /* SCROLL_UP or SCROLL_DOWN */
static void scroll_screen(register console_t *cons, int dir)
{
unsigned new_line, new_org, chars;
@ -397,9 +396,9 @@ int dir; /* SCROLL_UP or SCROLL_DOWN */
/*===========================================================================*
* flush *
* cons - pointer to console struct
*===========================================================================*/
static void flush(cons)
register console_t *cons; /* pointer to console struct */
static void flush(register console_t *cons)
{
/* Send characters buffered in 'ramqueue' to screen memory, check the new
* cursor position, compute the new hardware cursor position and set it.
@ -429,10 +428,10 @@ register console_t *cons; /* pointer to console struct */
/*===========================================================================*
* parse_escape *
* cons pointer to console struct
* c next character in escape sequence
*===========================================================================*/
static void parse_escape(cons, c)
register console_t *cons; /* pointer to console struct */
char c; /* next character in escape sequence */
static void parse_escape(register console_t *cons, int c)
{
/* The following ANSI escape sequences are currently supported.
* If n and/or m are omitted, they default to 1.
@ -487,11 +486,11 @@ char c; /* next character in escape sequence */
}
/*===========================================================================*
* do_escape *
* do_escape *
* cons: pointer to console struct *
* c: next character in escape sequence *
*===========================================================================*/
static void do_escape(cons, c)
register console_t *cons; /* pointer to console struct */
char c; /* next character in escape sequence */
static void do_escape(register console_t *cons, int c)
{
int value, n;
unsigned src, dst, count;
@ -729,11 +728,11 @@ char c; /* next character in escape sequence */
}
/*===========================================================================*
* set_6845 *
* set_6845 *
* reg: which register pair to set *
* val: 16-bit value to set it to *
*===========================================================================*/
static void set_6845(reg, val)
int reg; /* which register pair to set */
unsigned val; /* 16-bit value to set it to */
static void set_6845(int reg, unsigned val)
{
/* Set a register pair inside the 6845.
* Registers 12-13 tell the 6845 where in video ram to start
@ -751,9 +750,9 @@ unsigned val; /* 16-bit value to set it to */
/*===========================================================================*
* get_6845 *
*===========================================================================*/
static void get_6845(reg, val)
int reg; /* which register pair to set */
unsigned *val; /* 16-bit value to set it to */
static void get_6845(int reg, unsigned *val)
/* int reg; /* which register pair to set */
/* unsigned *val; /* 16-bit value to set it to */
{
char v1, v2;
u32_t v;
@ -789,7 +788,7 @@ static long beep_disabled(void)
/*===========================================================================*
* beep *
*===========================================================================*/
static void beep()
static void beep(void)
{
/* Making a beeping sound on the speaker (output for CRTL-G).
* This routine works by turning on the bits 0 and 1 in port B of the 8255
@ -858,9 +857,7 @@ void do_video(message *m, int ipc_status)
/*===========================================================================*
* beep_x *
*===========================================================================*/
void beep_x(freq, dur)
unsigned freq;
clock_t dur;
void beep_x(unsigned freq, clock_t dur)
{
/* Making a beeping sound on the speaker.
* This routine works by turning on the bits 0 and 1 in port B of the 8255
@ -907,8 +904,7 @@ static void stop_beep(int arg __unused)
/*===========================================================================*
* scr_init *
*===========================================================================*/
void scr_init(tp)
tty_t *tp;
void scr_init(tty_t *tp)
{
/* Initialize the screen driver. */
console_t *cons;
@ -1009,7 +1005,7 @@ tty_t *tp;
/*===========================================================================*
* toggle_scroll *
*===========================================================================*/
void toggle_scroll()
void toggle_scroll(void)
{
/* Toggle between hardware and software scroll. */
@ -1021,7 +1017,7 @@ void toggle_scroll()
/*===========================================================================*
* cons_stop *
*===========================================================================*/
void cons_stop()
void cons_stop(void)
{
/* Prepare for halt or reboot. */
cons_org0();
@ -1034,7 +1030,7 @@ void cons_stop()
/*===========================================================================*
* cons_org0 *
*===========================================================================*/
static void cons_org0()
static void cons_org0(void)
{
/* Scroll video memory back to put the origin at 0. */
int cons_line;
@ -1058,7 +1054,7 @@ static void cons_org0()
/*===========================================================================*
* disable_console *
*===========================================================================*/
static void disable_console()
static void disable_console(void)
{
if (disabled_vc != -1)
return;
@ -1076,7 +1072,7 @@ static void disable_console()
/*===========================================================================*
* reenable_console *
*===========================================================================*/
static void reenable_console()
static void reenable_console(void)
{
if (disabled_vc == -1)
return;
@ -1146,8 +1142,7 @@ int con_loadfont(endpoint_t endpt, cp_grant_id_t grant)
/*===========================================================================*
* ga_program *
*===========================================================================*/
static int ga_program(seq)
struct sequence *seq;
static int ga_program(struct sequence *seq)
{
pvb_pair_t char_out[14];
int i;

View File

@ -86,8 +86,7 @@ static unsigned map_key(int scode);
/*===========================================================================*
* map_key *
*===========================================================================*/
static unsigned map_key(scode)
int scode;
static unsigned map_key(int scode)
{
/* Map a scan code to an ASCII code. */
@ -181,9 +180,7 @@ void do_input(message *msg)
/*===========================================================================*
* kb_read *
*===========================================================================*/
static int kb_read(tp, try)
tty_t *tp;
int try;
static int kb_read(tty_t *tp, int try)
{
/* Process characters from the circular keyboard buffer. */
char buf[7], *p, suffix;
@ -387,8 +384,7 @@ static void set_leds(void)
/*===========================================================================*
* kb_init *
*===========================================================================*/
void kb_init(tp)
tty_t *tp;
void kb_init(tty_t *tp)
{
/* Initialize the keyboard driver. */
@ -425,9 +421,9 @@ int kbd_loadmap(endpoint_t endpt, cp_grant_id_t grant)
/*===========================================================================*
* do_fkey_ctl *
* m_ptr pointer to request message
*===========================================================================*/
void do_fkey_ctl(m_ptr)
message *m_ptr; /* pointer to the request message */
void do_fkey_ctl(message *m_ptr)
{
/* This procedure allows processes to register a function key to receive
* notifications if it is pressed. At most one binding per key can exist.
@ -527,10 +523,10 @@ message *m_ptr; /* pointer to the request message */
}
/*===========================================================================*
* func_key *
* func_key *
* scode: scan code for a function key *
*===========================================================================*/
static int func_key(scode)
int scode; /* scan code for a function key */
static int func_key(int scode)
{
/* This procedure traps function keys for debugging purposes. Observers of
* function keys are kept in a global array. If a subject (a key) is pressed
@ -574,7 +570,7 @@ int scode; /* scan code for a function key */
/*===========================================================================*
* show_key_mappings *
*===========================================================================*/
static void show_key_mappings()
static void show_key_mappings(void)
{
int i,s;

View File

@ -312,11 +312,11 @@ static int rs_write(register tty_t *tp, int try)
}
/*===========================================================================*
* rs_echo *
* rs_echo *
* tp: which TTY *
* c: character to echo *
*===========================================================================*/
static void rs_echo(tp, c)
tty_t *tp; /* which TTY */
int c; /* character to echo */
static void rs_echo(tty_t *tp, int c)
{
/* Echo one character. (Like rs_write, but only one character, optionally.) */

View File

@ -290,7 +290,7 @@ line2tty(devminor_t line)
/*===========================================================================*
* sef_local_startup *
*===========================================================================*/
static void sef_local_startup()
static void sef_local_startup(void)
{
/* Register init callbacks. */
sef_setcb_init_fresh(sef_cb_init_fresh);
@ -896,10 +896,10 @@ static int do_select(devminor_t minor, unsigned int ops, endpoint_t endpt)
}
/*===========================================================================*
* handle_events *
* handle_events *
* tp: TTY to check for events *
*===========================================================================*/
void handle_events(tp)
tty_t *tp; /* TTY to check for events. */
void handle_events(tty_t *tp)
{
/* Handle any events pending on a TTY. These events are usually device
* interrupts.
@ -946,8 +946,7 @@ tty_t *tp; /* TTY to check for events. */
/*===========================================================================*
* in_transfer *
*===========================================================================*/
static void in_transfer(tp)
register tty_t *tp; /* pointer to terminal to read from */
static void in_transfer(register tty_t *tp)
{
/* Transfer bytes from the input queue to a process reading from a terminal. */
@ -1007,12 +1006,12 @@ register tty_t *tp; /* pointer to terminal to read from */
}
/*===========================================================================*
* in_process *
* in_process *
* terminal: on which character has arrived *
* buf: buffer with input character *
* count: number of input characters *
*===========================================================================*/
int in_process(tp, buf, count)
register tty_t *tp; /* terminal on which character has arrived */
char *buf; /* buffer with input characters */
int count; /* number of input characters */
int in_process(tty_t *tp, char *buf, int count)
{
/* Characters have just been typed in. Process, save, and echo them. Return
* the number of characters processed.
@ -1172,11 +1171,11 @@ int count; /* number of input characters */
}
/*===========================================================================*
* echo *
* echo *
* tp: terminal on which to echo *
* ch: character to echo *
*===========================================================================*/
static int tty_echo(tp, ch)
register tty_t *tp; /* terminal on which to echo */
register int ch; /* pointer to character to echo */
static int tty_echo(register tty_t *tp, register int ch)
{
/* Echo the character if echoing is on. Some control characters are echoed
* with their normal effect, other control characters are echoed as "^X",
@ -1235,9 +1234,7 @@ register int ch; /* pointer to character to echo */
/*===========================================================================*
* rawecho *
*===========================================================================*/
static void rawecho(tp, ch)
register tty_t *tp;
int ch;
static void rawecho(tty_t *tp, int ch)
{
/* Echo without interpretation if ECHO is set. */
int rp = tp->tty_reprint;
@ -1248,8 +1245,7 @@ int ch;
/*===========================================================================*
* back_over *
*===========================================================================*/
static int back_over(tp)
register tty_t *tp;
static int back_over(register tty_t *tp)
{
/* Backspace to previous character on screen and erase it. */
u16_t *head;
@ -1275,10 +1271,10 @@ register tty_t *tp;
}
/*===========================================================================*
* reprint *
* reprint *
* tp: pointer to tty struct *
*===========================================================================*/
static void reprint(tp)
register tty_t *tp; /* pointer to tty struct */
static void reprint(register tty_t *tp)
{
/* Restore what has been echoed to screen before if the user input has been
* messed up by output, or if REPRINT (^R) is typed.
@ -1314,13 +1310,13 @@ register tty_t *tp; /* pointer to tty struct */
}
/*===========================================================================*
* out_process *
* out_process *
* bstart/bpos/bend: start/pos/end of circular buffer *
* icount: #input chars / input chars used *
* ocount: max output chars / output chars used *
*===========================================================================*/
void out_process(tp, bstart, bpos, bend, icount, ocount)
tty_t *tp;
char *bstart, *bpos, *bend; /* start/pos/end of circular buffer */
int *icount; /* # input chars / input chars used */
int *ocount; /* max output chars / output chars used */
void out_process(tty_t *tp, char *bstart, char *bpos, char *bend, int *icount,
int *ocount)
{
/* Perform output processing on a circular buffer. *icount is the number of
* bytes to process, and the number of bytes actually processed on return.
@ -1401,8 +1397,7 @@ out_done:
/*===========================================================================*
* dev_ioctl *
*===========================================================================*/
static void dev_ioctl(tp)
tty_t *tp;
static void dev_ioctl(tty_t *tp)
{
/* The ioctl's TCSETSW, TCSETSF and TIOCDRAIN wait for output to finish to make
* sure that an attribute change doesn't affect the processing of current
@ -1427,8 +1422,7 @@ tty_t *tp;
/*===========================================================================*
* setattr *
*===========================================================================*/
static void setattr(tp)
tty_t *tp;
static void setattr(tty_t *tp)
{
/* Apply the new line attributes (raw/canonical, line speed, etc.) */
u16_t *inp;
@ -1478,12 +1472,10 @@ tty_t *tp;
}
/*===========================================================================*
* sigchar *
* sigchar *
* sig: SIGINT, SIGQUIT, SIGKILL or SIGHUP *
*===========================================================================*/
void sigchar(tp, sig, mayflush)
register tty_t *tp;
int sig; /* SIGINT, SIGQUIT, SIGKILL or SIGHUP */
int mayflush;
void sigchar(register tty_t *tp, int sig, int mayflush)
{
/* Process a SIGINT, SIGQUIT or SIGKILL char from the keyboard or SIGHUP from
* a tty close, "stty 0", or a real RS-232 hangup. PM will send the signal to
@ -1510,8 +1502,7 @@ int mayflush;
/*===========================================================================*
* tty_icancel *
*===========================================================================*/
static void tty_icancel(tp)
register tty_t *tp;
static void tty_icancel(register tty_t *tp)
{
/* Discard all pending input, tty buffer or device. */
@ -1532,7 +1523,7 @@ static int tty_devnop(tty_t *UNUSED(tp), int UNUSED(try))
/*===========================================================================*
* tty_init *
*===========================================================================*/
static void tty_init()
static void tty_init(void)
{
/* Initialize tty structure and call device initialization routines. */
@ -1583,11 +1574,11 @@ static void tty_timed_out(int arg)
}
/*===========================================================================*
* settimer *
* settimer *
* tty_ptr: line to set or unset a timer on *
* enable: set timer if true, otherwise unset *
*===========================================================================*/
static void settimer(tty_ptr, enable)
tty_t *tty_ptr; /* line to set or unset a timer on */
int enable; /* set timer if true, otherwise unset */
static void settimer(tty_t *tty_ptr, int enable)
{
clock_t ticks;

View File

@ -316,7 +316,7 @@ main(int argc, char *argv[])
}
static int
keep_displaying_restarted()
keep_displaying_restarted(void)
{
u64_t delta;
u32_t micro_delta;