Add errno.h
[oweals/busybox.git] / ping.c
diff --git a/ping.c b/ping.c
index 8276dda4b480919da2dead377cadee447a586363..37ca26f31fc0585a7acfeff97cf06f01d7e989d1 100644 (file)
--- a/ping.c
+++ b/ping.c
@@ -1,6 +1,6 @@
 /* vi: set sw=4 ts=4: */
 /*
- * $Id: ping.c,v 1.31 2001/01/22 22:48:42 andersen Exp $
+ * $Id: ping.c,v 1.34 2001/01/24 18:44:54 andersen Exp $
  * Mini ping implementation for busybox
  *
  * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
  * Original copyright notice is retained at the end of this file.
  */
 
-#warning This applet has moved to netkit-tiny.  After BusyBox 0.49, this
-#warning applet will be removed from BusyBox.  All maintainence efforts
-#warning should be done in the netkit-tiny source tree.
-
 #include "busybox.h"
 #include <sys/param.h>
 #include <sys/socket.h>
@@ -58,7 +54,7 @@
 #if ! defined __GLIBC__ && ! defined __UCLIBC__
 typedef unsigned int socklen_t;
 
-#define        ICMP_MINLEN     8                               /* abs minimum */
+static const int ICMP_MINLEN = 8;                              /* abs minimum */
 
 struct icmp_ra_addr
 {
@@ -134,13 +130,13 @@ struct icmp
 };
 #endif
 
-#define DEFDATALEN      56
-#define        MAXIPLEN        60
-#define        MAXICMPLEN      76
-#define        MAXPACKET       65468
+static const int DEFDATALEN = 56;
+static const int MAXIPLEN = 60;
+static const int MAXICMPLEN = 76;
+static const int MAXPACKET = 65468;
 #define        MAX_DUP_CHK     (8 * 128)
-#define MAXWAIT         10
-#define PINGINTERVAL    1              /* second */
+static const int MAXWAIT = 10;
+static const int PINGINTERVAL = 1;             /* second */
 
 #define O_QUIET         (1 << 0)
 
@@ -262,7 +258,7 @@ extern int ping_main(int argc, char **argv)
 static char *hostname = NULL;
 static struct sockaddr_in pingaddr;
 static int pingsock = -1;
-static int datalen = DEFDATALEN;
+static int datalen; /* intentionally uninitialized to work around gcc bug */
 
 static long ntransmitted = 0, nreceived = 0, nrepeats = 0, pingcount = 0;
 static int myid = 0, options = 0;
@@ -508,6 +504,8 @@ extern int ping_main(int argc, char **argv)
 {
        char *thisarg;
 
+       datalen = DEFDATALEN; /* initialized here rather than in global scope to work around gcc bug */
+
        argc--;
        argv++;
        options = 0;