[2/6] batctl: Don't print uninitialised traceroute times
Commit Message
The time_delta array is only initialised when no error occurs or only
the select fails. This means that we may print uninitialised or output
from previous ttl levels.
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
batctl/traceroute.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
@@ -135,6 +135,7 @@ int traceroute(char *mesh_iface, int argc, char **argv)
for (i = 0; i < NUM_PACKETS; i++) {
icmp_packet_out.seqno = htons(++seq_counter);
+ time_delta[i] = 0.0;
if (write(trace_fd, (char *)&icmp_packet_out, sizeof(icmp_packet_out)) < 0) {
printf("Error - can't write to batman adv kernel file '%s': %s\n", icmp_socket, strerror(errno));
@@ -151,10 +152,8 @@ int traceroute(char *mesh_iface, int argc, char **argv)
res = select(trace_fd + 1, &read_socket, NULL, NULL, &tv);
- if (res <= 0) {
- time_delta[i] = 0.0;
+ if (res <= 0)
continue;
- }
read_len = read(trace_fd, (char *)&icmp_packet_in, sizeof(icmp_packet_in));