summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmart <smart@cvs.openbsd.org>2001-06-27 02:45:09 +0000
committersmart <smart@cvs.openbsd.org>2001-06-27 02:45:09 +0000
commitbad1a43bd974049eae3bda25666595f846c21d6b (patch)
tree300e28c6f542d54f6b7752f737396126e75f92be
parentbecd36d40ce5e22cb5bb409e0313ca07ad2e3ae7 (diff)
Compile cleanly with -Wall
-rw-r--r--usr.bin/nc/Makefile4
-rw-r--r--usr.bin/nc/netcat.c36
2 files changed, 26 insertions, 14 deletions
diff --git a/usr.bin/nc/Makefile b/usr.bin/nc/Makefile
index 7ae9233f93c..85d883d2ae5 100644
--- a/usr.bin/nc/Makefile
+++ b/usr.bin/nc/Makefile
@@ -1,6 +1,8 @@
-# $OpenBSD: Makefile,v 1.3 2001/06/25 22:17:33 ericj Exp $
+# $OpenBSD: Makefile,v 1.4 2001/06/27 02:45:08 smart Exp $
PROG= nc
SRCS= netcat.c atomicio.c
+CFLAGS+= -Wall
+
.include <bsd.prog.mk>
diff --git a/usr.bin/nc/netcat.c b/usr.bin/nc/netcat.c
index 206b3f8b6ce..ecf392ceed1 100644
--- a/usr.bin/nc/netcat.c
+++ b/usr.bin/nc/netcat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netcat.c,v 1.28 2001/06/26 23:25:22 ericj Exp $ */
+/* $OpenBSD: netcat.c,v 1.29 2001/06/27 02:45:08 smart Exp $ */
/*
* Copyright (c) 2001 Eric Jackson <ericj@monkey.org>
*
@@ -37,6 +37,7 @@
#include <netinet/in.h>
#include <arpa/telnet.h>
+
#include <err.h>
#include <errno.h>
#include <netdb.h>
@@ -64,27 +65,36 @@ int timeout;
int family = AF_UNSPEC;
char *portlist[65535];
-void atelnet __P((int, unsigned char *, unsigned int));
-void build_ports __P((char *));
-void help __P((void));
-int local_listen __P((char *, char *, struct addrinfo));
-void readwrite __P((int));
-int remote_connect __P((char *, char *, struct addrinfo));
-int udptest __P((int));
-void usage __P((int));
+ssize_t atomicio __P((ssize_t (*)(), int, void *, size_t));
+
+void atelnet __P((int, unsigned char *, unsigned int));
+void build_ports __P((char *));
+void help __P((void));
+int local_listen __P((char *, char *, struct addrinfo));
+void readwrite __P((int));
+int remote_connect __P((char *, char *, struct addrinfo));
+int udptest __P((int));
+void usage __P((int));
int
main(argc, argv)
int argc;
char *argv[];
{
- int ch, s, ret = 1;
+ int ch, s, ret;
char *host, *uport, *endp;
struct addrinfo hints;
- struct servent *sv = 0;
+ struct servent *sv;
socklen_t len;
struct sockaddr *cliaddr;
+ ret = 1;
+ s = 0;
+ host = NULL;
+ uport = NULL;
+ endp = NULL;
+ sv = NULL;
+
while ((ch = getopt(argc, argv, "46hi:klnp:rs:tuvw:z")) != -1) {
switch (ch) {
case '4':
@@ -179,7 +189,7 @@ main(argc, argv)
/* Allow only one connection at a time, but stay alive */
for (;;) {
if ((s = local_listen(host, uport, hints)) < 0)
- errx(1, NULL);
+ exit(1);
/*
* For UDP, we will use recvfrom() initially
* to wait for a caller, then use the regular
@@ -360,7 +370,7 @@ local_listen(host, port, hints)
ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x));
if (ret == -1)
- errx(1, NULL);
+ exit(1);
if (bind(s, (struct sockaddr *)res0->ai_addr,
res0->ai_addrlen) == 0)