From fda3d1026187387b71ff056828c5a22156cdc8da Mon Sep 17 00:00:00 2001 From: Explorer09 Date: Thu, 2 Nov 2023 03:29:39 +0800 Subject: Cache NetworkIOMeter values in 'double' type Signed-off-by: Kang-Che Sung --- NetworkIOMeter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'NetworkIOMeter.c') diff --git a/NetworkIOMeter.c b/NetworkIOMeter.c index dd7db422..ac453d89 100644 --- a/NetworkIOMeter.c +++ b/NetworkIOMeter.c @@ -27,10 +27,10 @@ static const int NetworkIOMeter_attributes[] = { }; static MeterRateStatus status = RATESTATUS_INIT; -static uint32_t cached_rxb_diff; +static double cached_rxb_diff; static char cached_rxb_diff_str[6]; static uint32_t cached_rxp_diff; -static uint32_t cached_txb_diff; +static double cached_txb_diff; static char cached_txb_diff_str[6]; static uint32_t cached_txp_diff; @@ -71,7 +71,7 @@ static void NetworkIOMeter_updateValues(Meter* this) { diff = data.bytesReceived - cached_rxb_total; diff = (1000 * diff) / passedTimeInMs; /* convert to B/s */ diff /= ONE_K; /* convert to KiB/s */ - cached_rxb_diff = (uint32_t)diff; + cached_rxb_diff = diff; } else { cached_rxb_diff = 0; } @@ -89,7 +89,7 @@ static void NetworkIOMeter_updateValues(Meter* this) { diff = data.bytesTransmitted - cached_txb_total; diff = (1000 * diff) / passedTimeInMs; /* convert to B/s */ diff /= ONE_K; /* convert to KiB/s */ - cached_txb_diff = (uint32_t)diff; + cached_txb_diff = diff; } else { cached_txb_diff = 0; } -- cgit v1.2.3