summaryrefslogtreecommitdiff
path: root/sbin/ping
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2018-07-18 15:46:50 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2018-07-18 15:46:50 +0000
commit146cb966f7b6b3256a92d69a6553e088a795b099 (patch)
tree073eb20614e1e77696ce7eeef9fc1e2a2de31883 /sbin/ping
parent25cf94e233da2724636c5d85caadc707e2d3dfd4 (diff)
replace manual zero initialization of various fields with memset;
makes the code shorter and easier to read. suggested by & OK claudio
Diffstat (limited to 'sbin/ping')
-rw-r--r--sbin/ping/ping.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c
index 520f3226910..8abf4f61b2b 100644
--- a/sbin/ping/ping.c
+++ b/sbin/ping/ping.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ping.c,v 1.226 2018/07/18 13:55:39 florian Exp $ */
+/* $OpenBSD: ping.c,v 1.227 2018/07/18 15:46:49 florian Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -820,6 +820,7 @@ main(int argc, char *argv[])
if (pinger(s) != 0) {
(void)signal(SIGALRM, onsignal);
timeout = INFTIM;
+ memset(&itimer, 0, sizeof(itimer));
if (nreceived) {
itimer.it_value.tv_sec = 2 * tmax /
1000;
@@ -827,9 +828,6 @@ main(int argc, char *argv[])
itimer.it_value.tv_sec = 1;
} else
itimer.it_value.tv_sec = maxwait;
- itimer.it_interval.tv_sec = 0;
- itimer.it_interval.tv_usec = 0;
- itimer.it_value.tv_usec = 0;
(void)setitimer(ITIMER_REAL, &itimer, NULL);
/* When the alarm goes off we are done. */
@@ -1008,15 +1006,13 @@ retransmit(int s)
* to wait two round-trip times if we've received any packets or
* maxwait seconds if we haven't.
*/
+ memset(&itimer, 0, sizeof(itimer));
if (nreceived) {
itimer.it_value.tv_sec = 2 * tmax / 1000;
if (itimer.it_value.tv_sec == 0)
itimer.it_value.tv_sec = 1;
} else
itimer.it_value.tv_sec = maxwait;
- itimer.it_interval.tv_sec = 0;
- itimer.it_interval.tv_usec = 0;
- itimer.it_value.tv_usec = 0;
(void)setitimer(ITIMER_REAL, &itimer, NULL);
/* When the alarm goes off we are done. */