diff options
author | smart <> | 2001-06-27 02:45:08 +0000 |
---|---|---|
committer | smart <> | 2001-06-27 02:45:08 +0000 |
commit | b8a7a3a596dc9dce95703c3f2f81b92144435795 (patch) | |
tree | 6c4e18ccb75d42ccaeaf3dc6a4978e818c15fb42 | |
parent | ba6f70d7550cc513151c4bb719659d4775a9efff (diff) | |
download | openbsd-b8a7a3a596dc9dce95703c3f2f81b92144435795.tar.gz openbsd-b8a7a3a596dc9dce95703c3f2f81b92144435795.tar.bz2 openbsd-b8a7a3a596dc9dce95703c3f2f81b92144435795.zip |
Compile cleanly with -Wall
-rw-r--r-- | src/usr.bin/nc/Makefile | 4 | ||||
-rw-r--r-- | src/usr.bin/nc/netcat.c | 36 |
2 files changed, 26 insertions, 14 deletions
diff --git a/src/usr.bin/nc/Makefile b/src/usr.bin/nc/Makefile index 7ae9233f93..85d883d2ae 100644 --- a/src/usr.bin/nc/Makefile +++ b/src/usr.bin/nc/Makefile | |||
@@ -1,6 +1,8 @@ | |||
1 | # $OpenBSD: Makefile,v 1.3 2001/06/25 22:17:33 ericj Exp $ | 1 | # $OpenBSD: Makefile,v 1.4 2001/06/27 02:45:08 smart Exp $ |
2 | 2 | ||
3 | PROG= nc | 3 | PROG= nc |
4 | SRCS= netcat.c atomicio.c | 4 | SRCS= netcat.c atomicio.c |
5 | 5 | ||
6 | CFLAGS+= -Wall | ||
7 | |||
6 | .include <bsd.prog.mk> | 8 | .include <bsd.prog.mk> |
diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c index 206b3f8b6c..ecf392ceed 100644 --- a/src/usr.bin/nc/netcat.c +++ b/src/usr.bin/nc/netcat.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: netcat.c,v 1.28 2001/06/26 23:25:22 ericj Exp $ */ | 1 | /* $OpenBSD: netcat.c,v 1.29 2001/06/27 02:45:08 smart Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> | 3 | * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> |
4 | * | 4 | * |
@@ -37,6 +37,7 @@ | |||
37 | 37 | ||
38 | #include <netinet/in.h> | 38 | #include <netinet/in.h> |
39 | #include <arpa/telnet.h> | 39 | #include <arpa/telnet.h> |
40 | |||
40 | #include <err.h> | 41 | #include <err.h> |
41 | #include <errno.h> | 42 | #include <errno.h> |
42 | #include <netdb.h> | 43 | #include <netdb.h> |
@@ -64,27 +65,36 @@ int timeout; | |||
64 | int family = AF_UNSPEC; | 65 | int family = AF_UNSPEC; |
65 | char *portlist[65535]; | 66 | char *portlist[65535]; |
66 | 67 | ||
67 | void atelnet __P((int, unsigned char *, unsigned int)); | 68 | ssize_t atomicio __P((ssize_t (*)(), int, void *, size_t)); |
68 | void build_ports __P((char *)); | 69 | |
69 | void help __P((void)); | 70 | void atelnet __P((int, unsigned char *, unsigned int)); |
70 | int local_listen __P((char *, char *, struct addrinfo)); | 71 | void build_ports __P((char *)); |
71 | void readwrite __P((int)); | 72 | void help __P((void)); |
72 | int remote_connect __P((char *, char *, struct addrinfo)); | 73 | int local_listen __P((char *, char *, struct addrinfo)); |
73 | int udptest __P((int)); | 74 | void readwrite __P((int)); |
74 | void usage __P((int)); | 75 | int remote_connect __P((char *, char *, struct addrinfo)); |
76 | int udptest __P((int)); | ||
77 | void usage __P((int)); | ||
75 | 78 | ||
76 | int | 79 | int |
77 | main(argc, argv) | 80 | main(argc, argv) |
78 | int argc; | 81 | int argc; |
79 | char *argv[]; | 82 | char *argv[]; |
80 | { | 83 | { |
81 | int ch, s, ret = 1; | 84 | int ch, s, ret; |
82 | char *host, *uport, *endp; | 85 | char *host, *uport, *endp; |
83 | struct addrinfo hints; | 86 | struct addrinfo hints; |
84 | struct servent *sv = 0; | 87 | struct servent *sv; |
85 | socklen_t len; | 88 | socklen_t len; |
86 | struct sockaddr *cliaddr; | 89 | struct sockaddr *cliaddr; |
87 | 90 | ||
91 | ret = 1; | ||
92 | s = 0; | ||
93 | host = NULL; | ||
94 | uport = NULL; | ||
95 | endp = NULL; | ||
96 | sv = NULL; | ||
97 | |||
88 | while ((ch = getopt(argc, argv, "46hi:klnp:rs:tuvw:z")) != -1) { | 98 | while ((ch = getopt(argc, argv, "46hi:klnp:rs:tuvw:z")) != -1) { |
89 | switch (ch) { | 99 | switch (ch) { |
90 | case '4': | 100 | case '4': |
@@ -179,7 +189,7 @@ main(argc, argv) | |||
179 | /* Allow only one connection at a time, but stay alive */ | 189 | /* Allow only one connection at a time, but stay alive */ |
180 | for (;;) { | 190 | for (;;) { |
181 | if ((s = local_listen(host, uport, hints)) < 0) | 191 | if ((s = local_listen(host, uport, hints)) < 0) |
182 | errx(1, NULL); | 192 | exit(1); |
183 | /* | 193 | /* |
184 | * For UDP, we will use recvfrom() initially | 194 | * For UDP, we will use recvfrom() initially |
185 | * to wait for a caller, then use the regular | 195 | * to wait for a caller, then use the regular |
@@ -360,7 +370,7 @@ local_listen(host, port, hints) | |||
360 | 370 | ||
361 | ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x)); | 371 | ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x)); |
362 | if (ret == -1) | 372 | if (ret == -1) |
363 | errx(1, NULL); | 373 | exit(1); |
364 | 374 | ||
365 | if (bind(s, (struct sockaddr *)res0->ai_addr, | 375 | if (bind(s, (struct sockaddr *)res0->ai_addr, |
366 | res0->ai_addrlen) == 0) | 376 | res0->ai_addrlen) == 0) |