aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-06-14 07:47:52 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-06-14 07:47:52 +0000
commit1adf681e87f5cd81841f8a3d84a8d9bdf83c7406 (patch)
tree57a5fe616110791c62485bcdac6eb66978e5edb9 /networking
parent26017b1b048900fa994029d492987fbef2eb3b43 (diff)
downloadbusybox-1adf681e87f5cd81841f8a3d84a8d9bdf83c7406.tar.gz
traceroute: stop using floating point needlessly; nuke useless assignment.
.rodata 129308 129312 +4 freehostinfo 35 29 -6 traceroute_main 4308 4300 -8
Diffstat (limited to 'networking')
-rw-r--r--networking/traceroute.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/networking/traceroute.c b/networking/traceroute.c
index 5d39ae3cf..40533a82d 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -710,16 +710,6 @@ send_probe(int seq, int ttl, struct timeval *tp)
}
}
-static inline double
-deltaT(struct timeval *t1p, struct timeval *t2p)
-{
- double dt;
-
- dt = (double)(t2p->tv_sec - t1p->tv_sec) * 1000.0 +
- (double)(t2p->tv_usec - t1p->tv_usec) / 1000.0;
- return dt;
-}
-
#if ENABLE_FEATURE_TRACEROUTE_VERBOSE
/*
* Convert an ICMP "type" field to a printable string.
@@ -901,9 +891,8 @@ static void
freehostinfo(struct hostinfo *hi)
{
free(hi->name);
- hi->name = NULL;
- free((char *)hi->addrs);
- free((char *)hi);
+ free(hi->addrs);
+ free(hi);
}
#if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE
@@ -918,6 +907,12 @@ getaddr(uint32_t *ap, const char *host)
}
#endif
+static void
+print_delta_ms(struct timeval *t1p, struct timeval *t2p)
+{
+ unsigned tt = (t2p->tv_sec - t1p->tv_sec) * 1000000 + (t2p->tv_usec - t1p->tv_usec);
+ printf(" %u.%03u ms", tt/1000, tt%1000);
+}
int traceroute_main(int argc, char **argv);
int traceroute_main(int argc, char **argv)
@@ -1256,7 +1251,7 @@ int traceroute_main(int argc, char **argv)
lastaddr = from->sin_addr.s_addr;
++gotlastaddr;
}
- printf(" %.3f ms", deltaT(&t1, &t2));
+ print_delta_ms(&t1, &t2);
ip = (struct ip *)packet;
if (op & OPT_TTL_FLAG)
printf(" (%d)", ip->ip_ttl);