Lukáš Zaoral
2026-Feb-13 08:49 UTC
[syslinux] [PATCH] tftp: fix transfer statistics with small files
Before this patch, the microseconds difference was computed incorrectly
leading to wrong transfer statistics:
$ ./tftp/tftp localhost -v -c get 10MB
Connected to localhost (::1), port 69
getting from localhost:10MB to 10MB [netascii]
Received 10485760 bytes in -7.5 seconds [-11164298 bit/s]
---
tftp/tftp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tftp/tftp.c b/tftp/tftp.c
index 33a4175..2ba3de2 100644
--- a/tftp/tftp.c
+++ b/tftp/tftp.c
@@ -398,8 +398,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.53.0
Paul Menzel
2026-Feb-13 09:34 UTC
[syslinux] [PATCH] tftp: fix transfer statistics with small files
Dear Luk??, Am 13.02.26 um 09:49 schrieb Luk?? Zaoral via Syslinux:> Before this patch, the microseconds difference was computed incorrectly > leading to wrong transfer statistics: > > $ ./tftp/tftp localhost -v -c get 10MB > Connected to localhost (::1), port 69 > getting from localhost:10MB to 10MB [netascii] > Received 10485760 bytes in -7.5 seconds [-11164298 bit/s]To make spotting the additional 0 in the diff below easier, you could mention this in the commit message. Also, for the summary/title I?d suggest: tftp: Correctly convert ?s to s to fix transfer statistics> --- > tftp/tftp.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/tftp/tftp.c b/tftp/tftp.c > index 33a4175..2ba3de2 100644 > --- a/tftp/tftp.c > +++ b/tftp/tftp.c > @@ -398,8 +398,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);Please feel free to add Reviewed-by: Paul Menzel <pmenzel at molgen.mpg.de> Kind regards, Paul