From: guenther Date: Sun, 20 Jul 2014 05:22:02 +0000 (+0000) Subject: Simplify #includes, start pushing them into the .c files, eliminate X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=58f11bc71f0c2cd02e8fc9296906a4176455a4fc;p=openbsd Simplify #includes, start pushing them into the .c files, eliminate extern declarations from .c files that duplicate those in .h files, start marking functions with __dead --- diff --git a/usr.bin/telnet/commands.c b/usr.bin/telnet/commands.c index 37c6e1eb877..d2eb50bf08e 100644 --- a/usr.bin/telnet/commands.c +++ b/usr.bin/telnet/commands.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commands.c,v 1.58 2014/07/20 04:07:16 guenther Exp $ */ +/* $OpenBSD: commands.c,v 1.59 2014/07/20 05:22:02 guenther Exp $ */ /* $NetBSD: commands.c,v 1.14 1996/03/24 22:03:48 jtk Exp $ */ /* @@ -31,7 +31,14 @@ */ #include "telnet_locl.h" + +#include +#include +#include + #include +#include +#include int tos = -1; @@ -1348,13 +1355,11 @@ bye(argc, argv) return 0; /* NOTREACHED */ } -/*VARARGS*/ - int -quit() +int +quit(void) { (void) call(bye, "bye", "fromquit", 0); Exit(0); - return 0; /*NOTREACHED*/ } /*VARARGS*/ @@ -1889,7 +1894,6 @@ tn(argc, argv) int error; struct sockaddr_in sin; unsigned long temp; - extern char *inet_ntoa(); char *srp = 0; int srlen; char *cmd, *hostp = 0, *portp = 0, *user = 0, *aliasp = 0; @@ -2353,7 +2357,6 @@ sourceroute(arg, cpp, lenp) { static char lsr[44]; char *cp, *cp2, *lsrp, *lsrep; - int tmp; struct in_addr sin_addr; struct hostent *host = 0; char c; @@ -2420,8 +2423,7 @@ sourceroute(arg, cpp, lenp) if (!c) cp2 = 0; - if ((tmp = inet_addr(cp)) != -1) { - sin_addr.s_addr = tmp; + if ((sin_addr.s_addr = inet_addr(cp)) != INADDR_NONE) { } else if ((host = gethostbyname(cp))) { memmove((caddr_t)&sin_addr, host->h_addr_list[0], diff --git a/usr.bin/telnet/externs.h b/usr.bin/telnet/externs.h index 097d757078e..4eb29ca0173 100644 --- a/usr.bin/telnet/externs.h +++ b/usr.bin/telnet/externs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: externs.h,v 1.19 2014/07/20 03:00:31 deraadt Exp $ */ +/* $OpenBSD: externs.h,v 1.20 2014/07/20 05:22:02 guenther Exp $ */ /* $KTH: externs.h,v 1.16 1997/11/29 02:28:35 joda Exp $ */ /* @@ -289,7 +289,7 @@ int dosynch (void); cc_t *tcval (int); -int quit (void); +__dead int quit(void); /* genget.c */ @@ -312,7 +312,7 @@ void optionstatus(void); void printsub(int direction, unsigned char *pointer, int length); void EmptyTerminal(void); void SetForExit(void); -void Exit(int returnCode); +__dead void Exit(int returnCode); void ExitString(char *string, int returnCode); extern struct termios new_tc; diff --git a/usr.bin/telnet/main.c b/usr.bin/telnet/main.c index d1ba1145b24..9a22875c641 100644 --- a/usr.bin/telnet/main.c +++ b/usr.bin/telnet/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.23 2014/07/19 23:50:38 guenther Exp $ */ +/* $OpenBSD: main.c,v 1.24 2014/07/20 05:22:02 guenther Exp $ */ /* $NetBSD: main.c,v 1.5 1996/02/28 21:04:05 thorpej Exp $ */ /* @@ -78,8 +78,6 @@ main(argc, argv) int argc; char *argv[]; { - extern char *optarg; - extern int optind; int ch; char *user, *alias; const char *errstr; diff --git a/usr.bin/telnet/network.c b/usr.bin/telnet/network.c index 8bd1b8b7235..07ea7d8f748 100644 --- a/usr.bin/telnet/network.c +++ b/usr.bin/telnet/network.c @@ -1,4 +1,4 @@ -/* $OpenBSD: network.c,v 1.10 2014/07/19 23:50:38 guenther Exp $ */ +/* $OpenBSD: network.c,v 1.11 2014/07/20 05:22:02 guenther Exp $ */ /* $NetBSD: network.c,v 1.5 1996/02/28 21:04:06 thorpej Exp $ */ /* @@ -31,7 +31,7 @@ */ #include "telnet_locl.h" -#include +#include Ring netoring, netiring; unsigned char netobuf[2*BUFSIZ], netibuf[BUFSIZ]; @@ -72,8 +72,7 @@ stilloob() if (value < 0) { perror("poll"); - (void) quit(); - /* NOTREACHED */ + quit(); } if (pfd[0].revents & POLLRDBAND) return 1; diff --git a/usr.bin/telnet/sys_bsd.c b/usr.bin/telnet/sys_bsd.c index 7e53460d067..034e7c3acfe 100644 --- a/usr.bin/telnet/sys_bsd.c +++ b/usr.bin/telnet/sys_bsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_bsd.c,v 1.16 2014/07/19 23:50:38 guenther Exp $ */ +/* $OpenBSD: sys_bsd.c,v 1.17 2014/07/20 05:22:02 guenther Exp $ */ /* $NetBSD: sys_bsd.c,v 1.11 1996/02/28 21:04:10 thorpej Exp $ */ /* @@ -31,7 +31,8 @@ */ #include "telnet_locl.h" -#include +#include +#include /* * The following routines try to encapsulate what is system dependent @@ -109,8 +110,6 @@ extern int kludgelinemode; * 1 Do add this character */ -extern void xmitAO(), xmitEL(), xmitEC(), intp(), sendbrk(); - int TerminalSpecialChars(c) int c; diff --git a/usr.bin/telnet/telnet_locl.h b/usr.bin/telnet/telnet_locl.h index cb8649d4cff..cc74ca215e7 100644 --- a/usr.bin/telnet/telnet_locl.h +++ b/usr.bin/telnet/telnet_locl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: telnet_locl.h,v 1.5 2014/07/19 23:50:38 guenther Exp $ */ +/* $OpenBSD: telnet_locl.h,v 1.6 2014/07/20 05:22:02 guenther Exp $ */ /* $KTH: telnet_locl.h,v 1.13 1997/11/03 21:37:55 assar Exp $ */ /* @@ -39,36 +39,21 @@ * SUCH DAMAGE. */ +#include +#include -#include -#include -#include -#include #include -#include #include -#include -#include -#include - -/* termios.h *must* be included before curses.h */ -#include #include #include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include #include @@ -76,5 +61,3 @@ #include "externs.h" #include "defines.h" -/* prototypes */ - diff --git a/usr.bin/telnet/utilities.c b/usr.bin/telnet/utilities.c index c6d42be20ab..2879031226b 100644 --- a/usr.bin/telnet/utilities.c +++ b/usr.bin/telnet/utilities.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utilities.c,v 1.12 2014/07/19 23:50:38 guenther Exp $ */ +/* $OpenBSD: utilities.c,v 1.13 2014/07/20 05:22:02 guenther Exp $ */ /* $NetBSD: utilities.c,v 1.5 1996/02/28 21:04:21 thorpej Exp $ */ /* @@ -30,11 +30,13 @@ * SUCH DAMAGE. */ +/* these three defines affect the behavior of */ #define TELOPTS #define TELCMDS #define SLC_NAMES #include "telnet_locl.h" +#include FILE *NetTrace = 0; /* Not in bss, since needs to stay */ int prettydump;