diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-14 07:47:52 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-14 07:47:52 +0000 |
commit | 1adf681e87f5cd81841f8a3d84a8d9bdf83c7406 (patch) | |
tree | 57a5fe616110791c62485bcdac6eb66978e5edb9 /networking/traceroute.c | |
parent | 26017b1b048900fa994029d492987fbef2eb3b43 (diff) | |
download | busybox-w32-1adf681e87f5cd81841f8a3d84a8d9bdf83c7406.tar.gz busybox-w32-1adf681e87f5cd81841f8a3d84a8d9bdf83c7406.tar.bz2 busybox-w32-1adf681e87f5cd81841f8a3d84a8d9bdf83c7406.zip |
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/traceroute.c')
-rw-r--r-- | networking/traceroute.c | 23 |
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) | |||
710 | } | 710 | } |
711 | } | 711 | } |
712 | 712 | ||
713 | static inline double | ||
714 | deltaT(struct timeval *t1p, struct timeval *t2p) | ||
715 | { | ||
716 | double dt; | ||
717 | |||
718 | dt = (double)(t2p->tv_sec - t1p->tv_sec) * 1000.0 + | ||
719 | (double)(t2p->tv_usec - t1p->tv_usec) / 1000.0; | ||
720 | return dt; | ||
721 | } | ||
722 | |||
723 | #if ENABLE_FEATURE_TRACEROUTE_VERBOSE | 713 | #if ENABLE_FEATURE_TRACEROUTE_VERBOSE |
724 | /* | 714 | /* |
725 | * Convert an ICMP "type" field to a printable string. | 715 | * Convert an ICMP "type" field to a printable string. |
@@ -901,9 +891,8 @@ static void | |||
901 | freehostinfo(struct hostinfo *hi) | 891 | freehostinfo(struct hostinfo *hi) |
902 | { | 892 | { |
903 | free(hi->name); | 893 | free(hi->name); |
904 | hi->name = NULL; | 894 | free(hi->addrs); |
905 | free((char *)hi->addrs); | 895 | free(hi); |
906 | free((char *)hi); | ||
907 | } | 896 | } |
908 | 897 | ||
909 | #if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE | 898 | #if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE |
@@ -918,6 +907,12 @@ getaddr(uint32_t *ap, const char *host) | |||
918 | } | 907 | } |
919 | #endif | 908 | #endif |
920 | 909 | ||
910 | static void | ||
911 | print_delta_ms(struct timeval *t1p, struct timeval *t2p) | ||
912 | { | ||
913 | unsigned tt = (t2p->tv_sec - t1p->tv_sec) * 1000000 + (t2p->tv_usec - t1p->tv_usec); | ||
914 | printf(" %u.%03u ms", tt/1000, tt%1000); | ||
915 | } | ||
921 | 916 | ||
922 | int traceroute_main(int argc, char **argv); | 917 | int traceroute_main(int argc, char **argv); |
923 | int traceroute_main(int argc, char **argv) | 918 | int traceroute_main(int argc, char **argv) |
@@ -1256,7 +1251,7 @@ int traceroute_main(int argc, char **argv) | |||
1256 | lastaddr = from->sin_addr.s_addr; | 1251 | lastaddr = from->sin_addr.s_addr; |
1257 | ++gotlastaddr; | 1252 | ++gotlastaddr; |
1258 | } | 1253 | } |
1259 | printf(" %.3f ms", deltaT(&t1, &t2)); | 1254 | print_delta_ms(&t1, &t2); |
1260 | ip = (struct ip *)packet; | 1255 | ip = (struct ip *)packet; |
1261 | if (op & OPT_TTL_FLAG) | 1256 | if (op & OPT_TTL_FLAG) |
1262 | printf(" (%d)", ip->ip_ttl); | 1257 | printf(" (%d)", ip->ip_ttl); |