netutils/iperf: Fix possible precision loss

Signed-off-by: SunJ <jsun@bouffalolab.com>
This commit is contained in:
SunJ 2023-06-14 20:57:09 +08:00 committed by Xiang Xiao
parent 3e68694bdf
commit b8856479ef

View File

@ -323,8 +323,8 @@ static void iperf_report_task(FAR void *arg)
ts_diff(&last, &start), ts_diff(&last, &start),
ts_diff(&now, &start), ts_diff(&now, &start),
now_len -last_len, now_len -last_len,
((double)((now_len - last_len) * 8) / 1000000) / (((now_len - last_len) * 8) / 1000000.0) /
(double)ts_diff(&now, &last) ts_diff(&now, &last)
); );
if (time != 0 && ts_diff(&now, &start) >= time) if (time != 0 && ts_diff(&now, &start) >= time)
{ {
@ -338,8 +338,8 @@ static void iperf_report_task(FAR void *arg)
ts_diff(&start, &start), ts_diff(&start, &start),
ts_diff(&now, &start), ts_diff(&now, &start),
now_len, now_len,
((double)(now_len * 8) / 1000000) / ((now_len * 8) / 1000000.0) /
(double)ts_diff(&now, &start) ts_diff(&now, &start)
); );
} }