From b6d9e1f355f23547e4ec15bd3ffe9e97854a4f69 Mon Sep 17 00:00:00 2001 From: Xin LI Date: Mon, 28 Apr 2008 21:08:42 +0000 Subject: [PATCH] ANSIfy function prototypes. While I am there, constify some parameters and make use of C99 sparse initialization for static variables, this makes talk(1) to compile cleanly with WARNS=6. --- usr.bin/talk/ctl.c | 13 ++++++------- usr.bin/talk/ctl_transact.c | 6 +----- usr.bin/talk/display.c | 13 +++---------- usr.bin/talk/get_addrs.c | 3 +-- usr.bin/talk/get_iface.c | 4 +--- usr.bin/talk/get_names.c | 6 ++---- usr.bin/talk/init_disp.c | 13 ++++++------- usr.bin/talk/invite.c | 9 ++++----- usr.bin/talk/io.c | 10 ++++------ usr.bin/talk/look_up.c | 5 ++--- usr.bin/talk/msgs.c | 7 +++---- usr.bin/talk/talk.c | 6 ++---- usr.bin/talk/talk.h | 2 +- 13 files changed, 36 insertions(+), 61 deletions(-) diff --git a/usr.bin/talk/ctl.c b/usr.bin/talk/ctl.c index 717ffb36a540..aaaa477da2d5 100644 --- a/usr.bin/talk/ctl.c +++ b/usr.bin/talk/ctl.c @@ -52,9 +52,9 @@ static const char sccsid[] = "@(#)ctl.c 8.1 (Berkeley) 6/6/93"; #include "talk.h" -struct sockaddr_in daemon_addr = { sizeof(daemon_addr), AF_INET }; -struct sockaddr_in ctl_addr = { sizeof(ctl_addr), AF_INET }; -struct sockaddr_in my_addr = { sizeof(my_addr), AF_INET }; +struct sockaddr_in daemon_addr = { .sin_len = sizeof(daemon_addr), .sin_family = AF_INET }; +struct sockaddr_in ctl_addr = { .sin_len = sizeof(ctl_addr), .sin_family = AF_INET }; +struct sockaddr_in my_addr = { .sin_len = sizeof(my_addr), .sin_family = AF_INET }; /* inet addresses of the two machines */ struct in_addr my_machine_addr; @@ -69,7 +69,7 @@ int invitation_waiting = 0; CTL_MSG msg; void -open_sockt() +open_sockt(void) { socklen_t length; @@ -90,7 +90,7 @@ open_sockt() /* open the ctl socket */ void -open_ctl() +open_ctl(void) { socklen_t length; @@ -113,8 +113,7 @@ open_ctl() /* print_addr is a debug print routine */ void -print_addr(addr) - struct sockaddr_in addr; +print_addr(struct sockaddr_in addr) { int i; diff --git a/usr.bin/talk/ctl_transact.c b/usr.bin/talk/ctl_transact.c index 0871febe7361..9c8665dab0dc 100644 --- a/usr.bin/talk/ctl_transact.c +++ b/usr.bin/talk/ctl_transact.c @@ -55,11 +55,7 @@ static const char sccsid[] = "@(#)ctl_transact.c 8.1 (Berkeley) 6/6/93"; * of time */ void -ctl_transact(target, lmsg, type, rp) - struct in_addr target; - CTL_MSG lmsg; - int type; - CTL_RESPONSE *rp; +ctl_transact(struct in_addr target, CTL_MSG lmsg, int type, CTL_RESPONSE *rp) { fd_set read_mask, ctl_mask; int nready = 0, cc; diff --git a/usr.bin/talk/display.c b/usr.bin/talk/display.c index 24851e45fab1..f565354b3e90 100644 --- a/usr.bin/talk/display.c +++ b/usr.bin/talk/display.c @@ -58,8 +58,7 @@ int curses_initialized = 0; * an argument of the form --foo at least once. */ int -max(a,b) - int a, b; +max(int a, int b) { return (a > b ? a : b); @@ -70,10 +69,7 @@ max(a,b) * characters while we are at it. */ void -display(win, text, size) - xwin_t *win; - char *text; - int size; +display(xwin_t *win, char *text, int size) { int i; char cch; @@ -180,10 +176,7 @@ display(win, text, size) * Read the character at the indicated position in win */ int -readwin(win, line, col) - WINDOW *win; - int line; - int col; +readwin(WINDOW *win, int line, int col) { int oldline, oldcol; int c; diff --git a/usr.bin/talk/get_addrs.c b/usr.bin/talk/get_addrs.c index f212a209a015..2923021aa551 100644 --- a/usr.bin/talk/get_addrs.c +++ b/usr.bin/talk/get_addrs.c @@ -47,8 +47,7 @@ static const char sccsid[] = "@(#)get_addrs.c 8.1 (Berkeley) 6/6/93"; #include "talk_ctl.h" void -get_addrs(my_machine_name, his_machine_name) - char *my_machine_name __unused, *his_machine_name; +get_addrs(const char *my_machine_name __unused, const char *his_machine_name) { struct hostent *hp; struct servent *sp; diff --git a/usr.bin/talk/get_iface.c b/usr.bin/talk/get_iface.c index d7cca18ec0dc..ebf08bd48a17 100644 --- a/usr.bin/talk/get_iface.c +++ b/usr.bin/talk/get_iface.c @@ -47,9 +47,7 @@ __FBSDID("$FreeBSD$"); */ int -get_iface(dst, iface) - struct in_addr *dst; - struct in_addr *iface; +get_iface(struct in_addr *dst, struct in_addr *iface) { static struct sockaddr_in local; struct sockaddr_in remote; diff --git a/usr.bin/talk/get_names.c b/usr.bin/talk/get_names.c index ad6b8235eec1..25f4673b0f83 100644 --- a/usr.bin/talk/get_names.c +++ b/usr.bin/talk/get_names.c @@ -61,13 +61,11 @@ usage(void) * Determine the local and remote user, tty, and machines */ void -get_names(argc, argv) - int argc; - char *argv[]; +get_names(int argc, char *argv[]) { char hostname[MAXHOSTNAMELEN]; char *his_name, *my_name; - char *my_machine_name, *his_machine_name; + const char *my_machine_name, *his_machine_name; const char *his_tty; char *cp; diff --git a/usr.bin/talk/init_disp.c b/usr.bin/talk/init_disp.c index f391b76a5e0b..4d34cf400c67 100644 --- a/usr.bin/talk/init_disp.c +++ b/usr.bin/talk/init_disp.c @@ -60,7 +60,7 @@ extern volatile sig_atomic_t gotwinch; * Make sure the callee can write to the screen */ void -check_writeable() +check_writeable(void) { char *tty; struct stat sb; @@ -78,7 +78,7 @@ check_writeable() * and build the various windows. */ void -init_display() +init_display(void) { struct sigaction sa; @@ -128,7 +128,7 @@ init_display() * connection are the three edit characters. */ void -set_edit_chars() +set_edit_chars(void) { char buf[3]; int cc; @@ -160,8 +160,7 @@ set_edit_chars() /* ARGSUSED */ void -sig_sent(signo) - int signo __unused; +sig_sent(int signo __unused) { message("Connection closing. Exiting"); @@ -169,7 +168,7 @@ sig_sent(signo) } void -sig_winch(int dummy) +sig_winch(int dummy __unused) { gotwinch = 1; @@ -179,7 +178,7 @@ sig_winch(int dummy) * All done talking...hang up the phone and reset terminal thingy's */ void -quit() +quit(void) { if (curses_initialized) { diff --git a/usr.bin/talk/invite.c b/usr.bin/talk/invite.c index a6e98e8900db..99c251435494 100644 --- a/usr.bin/talk/invite.c +++ b/usr.bin/talk/invite.c @@ -67,7 +67,7 @@ int local_id, remote_id; jmp_buf invitebuf; void -invite_remote() +invite_remote(void) { int new_sockt; struct itimerval itimer; @@ -124,8 +124,7 @@ invite_remote() */ /* ARGSUSED */ void -re_invite(signo) - int signo __unused; +re_invite(int signo __unused) { message("Ringing your party again"); @@ -155,7 +154,7 @@ static const char *answers[] = { * Transmit the invitation and process the response */ void -announce_invite() +announce_invite(void) { CTL_RESPONSE response; @@ -177,7 +176,7 @@ announce_invite() * Tell the daemon to remove your invitation */ void -send_delete() +send_delete(void) { msg.type = DELETE; diff --git a/usr.bin/talk/io.c b/usr.bin/talk/io.c index bcbf53580d06..dd6f0670fc09 100644 --- a/usr.bin/talk/io.c +++ b/usr.bin/talk/io.c @@ -65,7 +65,7 @@ volatile sig_atomic_t gotwinch = 0; * The routine to do the actual talking */ void -talk() +talk(void) { struct hostent *hp, *hp2; int nb; @@ -138,7 +138,7 @@ talk() */ int i; ioctl(0, FIONREAD, (void *) &nb); - if (nb > sizeof buf) + if (nb > (ssize_t)(sizeof buf)) nb = sizeof buf; nb = read(STDIN_FILENO, buf, nb); display(&my_win, buf, nb); @@ -156,8 +156,7 @@ talk() * on the screen and then exits. (i.e. a curses version of perror) */ void -p_error(string) - const char *string; +p_error(const char *string) { wmove(my_win.x_win, current_line, 0); wprintw(my_win.x_win, "[%s : %s (%d)]\n", @@ -172,8 +171,7 @@ p_error(string) * Display string in the standard location */ void -message(string) - const char *string; +message(const char *string) { wmove(my_win.x_win, current_line, 0); wprintw(my_win.x_win, "[%s]\n", string); diff --git a/usr.bin/talk/look_up.c b/usr.bin/talk/look_up.c index 1ff1477b22ff..1ccf23c652f0 100644 --- a/usr.bin/talk/look_up.c +++ b/usr.bin/talk/look_up.c @@ -53,7 +53,7 @@ static const char sccsid[] = "@(#)look_up.c 8.1 (Berkeley) 6/6/93"; * See if the local daemon has an invitation for us. */ int -check_local() +check_local(void) { CTL_RESPONSE response; CTL_RESPONSE *rp = &response; @@ -106,8 +106,7 @@ check_local() * Look for an invitation on 'machine' */ int -look_for_invite(rp) - CTL_RESPONSE *rp; +look_for_invite(CTL_RESPONSE *rp) { current_state = "Checking for invitation on caller's machine"; ctl_transact(his_machine_addr, msg, LOOK_UP, rp); diff --git a/usr.bin/talk/msgs.c b/usr.bin/talk/msgs.c index e4a097739671..f4cd41391dbd 100644 --- a/usr.bin/talk/msgs.c +++ b/usr.bin/talk/msgs.c @@ -55,14 +55,13 @@ int current_line = 0; /* ARGSUSED */ void -disp_msg(signo) - int signo __unused; +disp_msg(int signo __unused) { message(current_state); } void -start_msgs() +start_msgs(void) { struct itimerval itimer; @@ -74,7 +73,7 @@ start_msgs() } void -end_msgs() +end_msgs(void) { struct itimerval itimer; diff --git a/usr.bin/talk/talk.c b/usr.bin/talk/talk.c index 8e3f540055bb..5fc8337322d3 100644 --- a/usr.bin/talk/talk.c +++ b/usr.bin/talk/talk.c @@ -65,14 +65,12 @@ static const char copyright[] = */ int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char **argv) { (void) setlocale(LC_CTYPE, ""); get_names(argc, argv); - setproctitle(""); + setproctitle(" "); check_writeable(); init_display(); open_ctl(); diff --git a/usr.bin/talk/talk.h b/usr.bin/talk/talk.h index 2a81a53bca9b..e20c8ecc3700 100644 --- a/usr.bin/talk/talk.h +++ b/usr.bin/talk/talk.h @@ -73,7 +73,7 @@ extern void ctl_transact(struct in_addr,CTL_MSG,int,CTL_RESPONSE *); extern void disp_msg(int); extern void display(xwin_t *, char *, int); extern void end_msgs(void); -extern void get_addrs(char *, char *); +extern void get_addrs(const char *, const char *); extern int get_iface(struct in_addr *, struct in_addr *); extern void get_names(int, char **); extern void init_display(void);