From 00c616df1fcdefe33be74ec3f41f39b0c3852e5c Mon Sep 17 00:00:00 2001 From: lukem Date: Sat, 11 Oct 1997 08:13:40 +0000 Subject: use err/warn instead of perror --- hunt/hunt/connect.c | 10 ++++---- hunt/hunt/hunt.c | 70 +++++++++++++++++++++------------------------------ hunt/hunt/playit.c | 11 ++++---- hunt/huntd/driver.c | 22 ++++++++-------- hunt/huntd/faketalk.c | 12 ++++----- hunt/huntd/shots.c | 8 +++--- hunt/huntd/talk_ctl.h | 2 +- 7 files changed, 61 insertions(+), 74 deletions(-) (limited to 'hunt') diff --git a/hunt/hunt/connect.c b/hunt/hunt/connect.c index ae91c2ab..b3fcd7bd 100644 --- a/hunt/hunt/connect.c +++ b/hunt/hunt/connect.c @@ -1,4 +1,4 @@ -/* $NetBSD: connect.c,v 1.2 1997/10/10 16:32:23 lukem Exp $ */ +/* $NetBSD: connect.c,v 1.3 1997/10/11 08:13:40 lukem Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold @@ -7,7 +7,7 @@ #include #ifndef lint -__RCSID("$NetBSD: connect.c,v 1.2 1997/10/10 16:32:23 lukem Exp $"); +__RCSID("$NetBSD: connect.c,v 1.3 1997/10/11 08:13:40 lukem Exp $"); #endif /* not lint */ # include "hunt.h" @@ -16,9 +16,9 @@ __RCSID("$NetBSD: connect.c,v 1.2 1997/10/10 16:32:23 lukem Exp $"); void do_connect(name, team, enter_status) -char *name; -char team; -long enter_status; + char *name; + char team; + long enter_status; { static long uid; static long mode; diff --git a/hunt/hunt/hunt.c b/hunt/hunt/hunt.c index f92f6bf5..b7470590 100644 --- a/hunt/hunt/hunt.c +++ b/hunt/hunt/hunt.c @@ -1,4 +1,4 @@ -/* $NetBSD: hunt.c,v 1.2 1997/10/10 16:32:34 lukem Exp $ */ +/* $NetBSD: hunt.c,v 1.3 1997/10/11 08:13:41 lukem Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold @@ -7,12 +7,13 @@ #include #ifndef lint -__RCSID("$NetBSD: hunt.c,v 1.2 1997/10/10 16:32:34 lukem Exp $"); +__RCSID("$NetBSD: hunt.c,v 1.3 1997/10/11 08:13:41 lukem Exp $"); #endif /* not lint */ # include # include # include +# include # include # include # include @@ -119,14 +120,13 @@ main(ac, av) case 't': team = *optarg; if (!isdigit(team)) { - fprintf(stderr, "Team names must be numeric\n"); + warnx("Team names must be numeric"); team = ' '; } break; case 'o': # ifndef OTTO - fputs("The -o flag is reserved for future use.\n", - stderr); + warnx("The -o flag is reserved for future use."); goto usage; # else Otto_mode = TRUE; @@ -136,7 +136,7 @@ main(ac, av) # ifdef MONITOR Am_monitor = TRUE; # else - fputs("The monitor was not compiled in.\n", stderr); + warnx("The monitor was not compiled in."); # endif break; # ifdef INTERNET @@ -162,8 +162,7 @@ main(ac, av) case 'w': case 'h': case 'p': - fputs("Need TCP/IP for S, q, w, h, and p options.\n", - stderr); + wanrx("Need TCP/IP for S, q, w, h, and p options."); break; # endif case 'c': @@ -173,7 +172,7 @@ main(ac, av) # ifdef FLY enter_status = Q_FLY; # else - fputs("The flying code was not compiled in.\n", stderr); + warnx("The flying code was not compiled in."); # endif break; case 's': @@ -234,10 +233,8 @@ main(ac, av) fill_in_blanks(); (void) fflush(stdout); - if (!isatty(0) || (term = getenv("TERM")) == NULL) { - fprintf(stderr, "no terminal type\n"); - exit(1); - } + if (!isatty(0) || (term = getenv("TERM")) == NULL) + errx(1, "no terminal type"); # ifdef USE_CURSES initscr(); (void) noecho(); @@ -280,19 +277,17 @@ main(ac, av) int option; Socket = socket(SOCK_FAMILY, SOCK_STREAM, 0); - if (Socket < 0) { - perror("socket"); - exit(1); - } + if (Socket < 0) + err(1, "socket"); option = 1; if (setsockopt(Socket, SOL_SOCKET, SO_USELOOPBACK, &option, sizeof option) < 0) - perror("setsockopt loopback"); + warn("setsockopt loopback"); errno = 0; if (connect(Socket, (struct sockaddr *) &Daemon, DAEMON_SIZE) < 0) { if (errno != ECONNREFUSED) { - perror("connect"); + warn("connect"); leave(1, "connect"); } } @@ -305,10 +300,8 @@ main(ac, av) * set up a socket */ - if ((Socket = socket(SOCK_FAMILY, SOCK_STREAM, 0)) < 0) { - perror("socket"); - exit(1); - } + if ((Socket = socket(SOCK_FAMILY, SOCK_STREAM, 0)) < 0) + err(1, "socket"); /* * attempt to connect the socket to a name; if it fails that @@ -320,17 +313,16 @@ main(ac, av) (void) strcpy(Daemon.sun_path, Sock_name); if (connect(Socket, &Daemon, DAEMON_SIZE) < 0) { if (errno != ENOENT) { - perror("connect"); + warn("connect"); leave(1, "connect2"); } start_driver(); do { (void) close(Socket); - if ((Socket = socket(SOCK_FAMILY, SOCK_STREAM, 0)) < 0) { - perror("socket"); - exit(1); - } + if ((Socket = socket(SOCK_FAMILY, SOCK_STREAM, + 0)) < 0) + err(1, "socket"); sleep(2); } while (connect(Socket, &Daemon, DAEMON_SIZE) < 0); } @@ -433,7 +425,7 @@ list_drivers() test_socket = socket(SOCK_FAMILY, SOCK_DGRAM, 0); if (test_socket < 0) { - perror("socket"); + warn("socket"); leave(1, "socket system call failed"); /* NOTREACHED */ } @@ -473,7 +465,7 @@ list_drivers() option = 1; if (setsockopt(test_socket, SOL_SOCKET, SO_BROADCAST, &option, sizeof option) < 0) { - perror("setsockopt broadcast"); + warn("setsockopt broadcast"); leave(1, "setsockopt broadcast"); /* NOTREACHED */ } @@ -485,7 +477,7 @@ list_drivers() test.sin_addr = brdv[i].sin_addr; if (sendto(test_socket, (char *) &msg, sizeof msg, 0, (struct sockaddr *) &test, DAEMON_SIZE) < 0) { - perror("sendto"); + warn("sendto"); leave(1, "sendto"); /* NOTREACHED */ } @@ -535,7 +527,7 @@ get_response: } if (errno != 0 && errno != EINTR) { - perror("select/recvfrom"); + warn("select/recvfrom"); leave(1, "select/recvfrom"); /* NOTREACHED */ } @@ -640,14 +632,10 @@ dump_scores(host) fflush(stdout); s = socket(SOCK_FAMILY, SOCK_STREAM, 0); - if (s < 0) { - perror("socket"); - exit(1); - } - if (connect(s, (struct sockaddr *) &host, sizeof host) < 0) { - perror("connect"); - exit(1); - } + if (s < 0) + err(1, "socket"); + if (connect(s, (struct sockaddr *) &host, sizeof host) < 0) + err(1, "connect"); while ((cnt = read(s, buf, BUFSIZ)) > 0) write(fileno(stdout), buf, cnt); (void) close(s); @@ -685,7 +673,7 @@ start_driver() refresh(); procid = fork(); if (procid == -1) { - perror("fork"); + warn("fork"); leave(1, "fork failed."); } if (procid == 0) { diff --git a/hunt/hunt/playit.c b/hunt/hunt/playit.c index e6776673..5d558aa2 100644 --- a/hunt/hunt/playit.c +++ b/hunt/hunt/playit.c @@ -1,4 +1,4 @@ -/* $NetBSD: playit.c,v 1.2 1997/10/10 16:32:43 lukem Exp $ */ +/* $NetBSD: playit.c,v 1.3 1997/10/11 08:13:44 lukem Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold @@ -7,10 +7,11 @@ #include #ifndef lint -__RCSID("$NetBSD: playit.c,v 1.2 1997/10/10 16:32:43 lukem Exp $"); +__RCSID("$NetBSD: playit.c,v 1.3 1997/10/11 08:13:44 lukem Exp $"); #endif /* not lint */ # include +# include # include # include # include @@ -572,10 +573,8 @@ redraw_screen() if (first) { curscr = newwin(SCREEN_HEIGHT, SCREEN_WIDTH, 0, 0); - if (curscr == NULL) { - fprintf(stderr, "Can't create curscr\n"); - exit(1); - } + if (curscr == NULL) + errx(1, "Can't create curscr"); # if !defined(BSD_RELEASE) || BSD_RELEASE < 44 for (i = 0; i < SCREEN_HEIGHT; i++) curscr->_y[i] = screen[i]; diff --git a/hunt/huntd/driver.c b/hunt/huntd/driver.c index 1f3b47a3..2f8bdff2 100644 --- a/hunt/huntd/driver.c +++ b/hunt/huntd/driver.c @@ -1,4 +1,4 @@ -/* $NetBSD: driver.c,v 1.2 1997/10/10 16:33:08 lukem Exp $ */ +/* $NetBSD: driver.c,v 1.3 1997/10/11 08:13:47 lukem Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold @@ -7,7 +7,7 @@ #include #ifndef lint -__RCSID("$NetBSD: driver.c,v 1.2 1997/10/10 16:33:08 lukem Exp $"); +__RCSID("$NetBSD: driver.c,v 1.3 1997/10/11 08:13:47 lukem Exp $"); #endif /* not lint */ # include @@ -117,7 +117,7 @@ again: # ifdef LOG syslog(LOG_WARNING, "select: %m"); # else - perror("select"); + warn("select"); # endif errno = 0; } @@ -295,7 +295,7 @@ init() # ifdef LOG syslog(LOG_ERR, "bind: %m"); # else - perror("bind"); + warn("bind"); # endif cleanup(1); } @@ -308,7 +308,7 @@ init() # ifdef LOG syslog(LOG_ERR, "getsockname: %m"); # else - perror("getsockname"); + warn("getsockname"); # endif exit(1); } @@ -334,7 +334,7 @@ init() # ifdef LOG syslog(LOG_WARNING, "setsockopt loopback %m"); # else - perror("setsockopt loopback"); + warn("setsockopt loopback"); # endif # endif if (bind(Socket, (struct sockaddr *) &Daemon, DAEMON_SIZE) < 0) { @@ -344,7 +344,7 @@ init() # ifdef LOG syslog(LOG_ERR, "bind: %m"); # else - perror("bind"); + warn("bind"); # endif cleanup(1); } @@ -357,7 +357,7 @@ init() # ifdef LOG syslog(LOG_ERR, "getsockname: %m"); # else - perror("getsockname"); + warn("getsockname"); # endif exit(1); } @@ -391,7 +391,7 @@ init() # ifdef LOG syslog(LOG_ERR, "bind: %m"); # else - perror("bind"); + warn("bind"); # endif exit(1); } @@ -910,7 +910,7 @@ send_stats() # ifdef LOG syslog(LOG_ERR, "accept: %m"); # else - perror("accept"); + warn("accept"); # endif return; } @@ -919,7 +919,7 @@ send_stats() # ifdef LOG syslog(LOG_ERR, "fdopen: %m"); # else - perror("fdopen"); + warn("fdopen"); # endif (void) close(s); return; diff --git a/hunt/huntd/faketalk.c b/hunt/huntd/faketalk.c index e594b12e..2044ce1d 100644 --- a/hunt/huntd/faketalk.c +++ b/hunt/huntd/faketalk.c @@ -1,4 +1,4 @@ -/* $NetBSD: faketalk.c,v 1.3 1997/10/10 16:33:31 lukem Exp $ */ +/* $NetBSD: faketalk.c,v 1.4 1997/10/11 08:13:48 lukem Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold @@ -11,7 +11,7 @@ #include #ifndef lint -__RCSID("$NetBSD: faketalk.c,v 1.3 1997/10/10 16:33:31 lukem Exp $"); +__RCSID("$NetBSD: faketalk.c,v 1.4 1997/10/11 08:13:48 lukem Exp $"); #endif /* not lint */ #include "bsd.h" @@ -107,7 +107,7 @@ faketalk() # ifdef LOG syslog(LOG_ERR, "faketalk: smtp protocol not supported\n"); # else - fprintf(stderr, "faketalk: stmp protocol not supported\n"); + warn("faketalk: stmp protocol not supported"); # endif _exit(1); } @@ -121,7 +121,7 @@ faketalk() # ifdef LOG syslog(LOG_ERR, "falktalk: socket"); # else - perror("falktalk: socket"); + warn("falktalk: socket"); # endif _exit(-1); } @@ -130,7 +130,7 @@ faketalk() # ifdef LOG syslog(LOG_ERR, "faketalk: connect"); # else - perror("faketalk: connect"); + warn("faketalk: connect"); # endif _exit(-1); } @@ -138,7 +138,7 @@ faketalk() # ifdef LOG syslog(LOG_ERR, "fdopen failed\n"); # else - fprintf(stderr, "fdopen failed\n"); + warn("faketalk: fdopen"); # endif _exit(-2); } diff --git a/hunt/huntd/shots.c b/hunt/huntd/shots.c index d0dfcf90..b4080dbd 100644 --- a/hunt/huntd/shots.c +++ b/hunt/huntd/shots.c @@ -1,4 +1,4 @@ -/* $NetBSD: shots.c,v 1.2 1997/10/10 16:33:54 lukem Exp $ */ +/* $NetBSD: shots.c,v 1.3 1997/10/11 08:13:50 lukem Exp $ */ /* * Hunt * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold @@ -7,9 +7,10 @@ #include #ifndef lint -__RCSID("$NetBSD: shots.c,v 1.2 1997/10/10 16:33:54 lukem Exp $"); +__RCSID("$NetBSD: shots.c,v 1.3 1997/10/11 08:13:50 lukem Exp $"); #endif /* not lint */ +# include # include # include # include "hunt.h" @@ -1018,8 +1019,7 @@ play_at(y, x) for (pp = Player; pp < End_player; pp++) if (pp->p_x == x && pp->p_y == y) return pp; - fprintf(stderr, "driver: couldn't find player at (%d,%d)\n", x, y); - abort(); + errx(1, "driver: couldn't find player at (%d,%d)", x, y); /* NOTREACHED */ } diff --git a/hunt/huntd/talk_ctl.h b/hunt/huntd/talk_ctl.h index 59071ec3..f8081b83 100644 --- a/hunt/huntd/talk_ctl.h +++ b/hunt/huntd/talk_ctl.h @@ -74,7 +74,7 @@ extern CTL_MSG msg; #ifdef LOG #define p_error(str) syslog(LOG_WARNING, "faketalk %s: %m", str) #else -#define p_error(str) perror(str) +#define p_error(str) warn(str) #endif void ctl_transact __P((struct in_addr, CTL_MSG, int, CTL_RESPONSE *)); -- cgit v1.2.3-56-ge451