X-Git-Url: https://git.xinqibao.xyz/slstatus.git/blobdiff_plain/e3ccac3298f8d5d15fc63679aaed9646dd82919e..d47d78255ef8ede773c69a97e2cb5de78cee7da9:/components/netspeeds.c diff --git a/components/netspeeds.c b/components/netspeeds.c index cd47dae..b4e6972 100644 --- a/components/netspeeds.c +++ b/components/netspeeds.c @@ -61,12 +61,15 @@ uint64_t oldrxbytes; static uint64_t rxbytes = 0; extern const unsigned int interval; - char if_ok = 0; + int if_ok = 0; + + oldrxbytes = rxbytes; if (getifaddrs(&ifal) == -1) { warn("getifaddrs failed"); return NULL; } + rxbytes = 0; for (ifa = ifal; ifa; ifa = ifa->ifa_next) { if (!strcmp(ifa->ifa_name, interface) && (ifd = (struct if_data *)ifa->ifa_data)) { @@ -91,12 +94,15 @@ uint64_t oldtxbytes; static uint64_t txbytes = 0; extern const unsigned int interval; - char if_ok = 0; + int if_ok = 0; + + oldtxbytes = txbytes; if (getifaddrs(&ifal) == -1) { warn("getifaddrs failed"); return NULL; } + txbytes = 0; for (ifa = ifal; ifa; ifa = ifa->ifa_next) { if (!strcmp(ifa->ifa_name, interface) && (ifd = (struct if_data *)ifa->ifa_data)) {