#54 CVS: bandwidth is printed using wrong printf directive

open
nobody
None
5
2012-05-07
2012-05-07
Miika Karanki
No

In reposrtCVS.c file (iperf v 2.0.5) on function CSV_stats( Transfer_Info *stats ) bandwidth is printed in following way:
max_size_t speed = (max_size_t)(((double)stats->TotalLen * 8.0) / (stats->endTime - stats->startTime)); /* max_size_t speed is uint64_t */
/* ... */
printf( reportCSV_bw_format,
timestamp,
(stats->reserved_delay == NULL ? ",,," : stats->reserved_delay),
stats->transferID,
stats->startTime,
stats->endTime,
stats->TotalLen,
speed);

With my platform reportCSV_bw_format is "%s,%s,%d,%.1f-%.1f,%d,%d" (from Locale.c) , so uint64_t is printed with %d directive. x86 gcc gives a warning about that but everything seem to work ok. However, with arm gcc the result is that printed bandwidth in CSV format is always zero (0).

I think uint64_t should be printed with %lld directive. I attach a patch which fixed the problem for me. Feel free to verify if it is correct.

Discussion

  • Miika Karanki
    Miika Karanki
    2012-05-07

    Looked again the Locale.c source and I can surely say my patch is faulty. But the bug is still valid.