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.
This commit is contained in:
Xin LI 2008-04-28 21:08:42 +00:00
parent f81a2a4956
commit b6d9e1f355
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=178642
13 changed files with 36 additions and 61 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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();

View File

@ -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);