summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmart <>2001-06-27 02:45:08 +0000
committersmart <>2001-06-27 02:45:08 +0000
commitb8a7a3a596dc9dce95703c3f2f81b92144435795 (patch)
tree6c4e18ccb75d42ccaeaf3dc6a4978e818c15fb42
parentba6f70d7550cc513151c4bb719659d4775a9efff (diff)
downloadopenbsd-b8a7a3a596dc9dce95703c3f2f81b92144435795.tar.gz
openbsd-b8a7a3a596dc9dce95703c3f2f81b92144435795.tar.bz2
openbsd-b8a7a3a596dc9dce95703c3f2f81b92144435795.zip
Compile cleanly with -Wall
-rw-r--r--src/usr.bin/nc/Makefile4
-rw-r--r--src/usr.bin/nc/netcat.c36
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
3PROG= nc 3PROG= nc
4SRCS= netcat.c atomicio.c 4SRCS= netcat.c atomicio.c
5 5
6CFLAGS+= -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;
64int family = AF_UNSPEC; 65int family = AF_UNSPEC;
65char *portlist[65535]; 66char *portlist[65535];
66 67
67void atelnet __P((int, unsigned char *, unsigned int)); 68ssize_t atomicio __P((ssize_t (*)(), int, void *, size_t));
68void build_ports __P((char *)); 69
69void help __P((void)); 70void atelnet __P((int, unsigned char *, unsigned int));
70int local_listen __P((char *, char *, struct addrinfo)); 71void build_ports __P((char *));
71void readwrite __P((int)); 72void help __P((void));
72int remote_connect __P((char *, char *, struct addrinfo)); 73int local_listen __P((char *, char *, struct addrinfo));
73int udptest __P((int)); 74void readwrite __P((int));
74void usage __P((int)); 75int remote_connect __P((char *, char *, struct addrinfo));
76int udptest __P((int));
77void usage __P((int));
75 78
76int 79int
77main(argc, argv) 80main(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)