Arthur Gay
2021-Oct-02 15:24 UTC
[syslinux] [PATCH tftp-hpa] tftp: Fix elapsed transfer time display
Elapsed transfer time is not displayed correctly: $ time tftp -v localhost -c get file Connected to localhost (127.0.0.1), port 69 getting from localhost:file to file [netascii] Received 10485760 bytes in -5.3 seconds [-15838141 bit/s] real 0m0.378s user 0m0.110s sys 0m0.193s Here is a trivial patch. There are 1,000,000 microseconds in a second. --- tftp/tftp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tftp/tftp.c b/tftp/tftp.c index d15da22..d85c28f 100644 --- a/tftp/tftp.c +++ b/tftp/tftp.c @@ -399,8 +399,8 @@ static void printstats(const char *direction, unsigned long amount) { double delta; - delta = (tstop.tv_sec + (tstop.tv_usec / 100000.0)) - - (tstart.tv_sec + (tstart.tv_usec / 100000.0)); + delta = (tstop.tv_sec + (tstop.tv_usec / 1000000.0)) - + (tstart.tv_sec + (tstart.tv_usec / 1000000.0)); if (verbose) { printf("%s %lu bytes in %.1f seconds", direction, amount, delta); printf(" [%.0f bit/s]", (amount * 8.) / delta); -- 2.29.0