diff options
author | drkhsh <me@drkhsh.at> | 2022-10-28 00:51:34 +0200 |
---|---|---|
committer | Rafael Marçalo <raroma09@gmail.com> | 2022-10-28 22:22:55 +0100 |
commit | 3124351099e0be9ba4a00e79083457159f651372 (patch) | |
tree | 27f68849b8aaeece17411835fd303b020cc70ca0 /components/netspeeds.c | |
parent | 35249fb0feb52a7fcaab2d2322c073b042c68453 (diff) |
radical re-formatting 2/3: Fix blocks
Fixes coding style. Formatting commits suck, incoherent coding style
sucks more.
https://suckless.org/coding_style/
Diffstat (limited to 'components/netspeeds.c')
-rw-r--r-- | components/netspeeds.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/components/netspeeds.c b/components/netspeeds.c index e61d982..cde6fa9 100644 --- a/components/netspeeds.c +++ b/components/netspeeds.c @@ -23,12 +23,10 @@ if (esnprintf(path, sizeof(path), NET_RX_BYTES, interface) < 0) return NULL; - if (pscanf(path, "%ju", &rxbytes) != 1) { + if (pscanf(path, "%ju", &rxbytes) != 1) return NULL; - } - if (oldrxbytes == 0) { + if (oldrxbytes == 0) return NULL; - } return fmt_human((rxbytes - oldrxbytes) * 1000 / interval, 1024); @@ -46,12 +44,10 @@ if (esnprintf(path, sizeof(path), NET_TX_BYTES, interface) < 0) return NULL; - if (pscanf(path, "%ju", &txbytes) != 1) { + if (pscanf(path, "%ju", &txbytes) != 1) return NULL; - } - if (oldtxbytes == 0) { + if (oldtxbytes == 0) return NULL; - } return fmt_human((txbytes - oldtxbytes) * 1000 / interval, 1024); @@ -80,20 +76,18 @@ return NULL; } rxbytes = 0; - for (ifa = ifal; ifa; ifa = ifa->ifa_next) { + for (ifa = ifal; ifa; ifa = ifa->ifa_next) if (!strcmp(ifa->ifa_name, interface) && - (ifd = (struct if_data *)ifa->ifa_data)) { + (ifd = (struct if_data *)ifa->ifa_data)) rxbytes += ifd->ifi_ibytes, if_ok = 1; - } - } + freeifaddrs(ifal); if (!if_ok) { warn("reading 'if_data' failed"); return NULL; } - if (oldrxbytes == 0) { + if (oldrxbytes == 0) return NULL; - } return fmt_human((rxbytes - oldrxbytes) * 1000 / interval, 1024); @@ -116,20 +110,18 @@ return NULL; } txbytes = 0; - for (ifa = ifal; ifa; ifa = ifa->ifa_next) { + for (ifa = ifal; ifa; ifa = ifa->ifa_next) if (!strcmp(ifa->ifa_name, interface) && - (ifd = (struct if_data *)ifa->ifa_data)) { + (ifd = (struct if_data *)ifa->ifa_data)) txbytes += ifd->ifi_obytes, if_ok = 1; - } - } + freeifaddrs(ifal); if (!if_ok) { warn("reading 'if_data' failed"); return NULL; } - if (oldtxbytes == 0) { + if (oldtxbytes == 0) return NULL; - } return fmt_human((txbytes - oldtxbytes) * 1000 / interval, 1024); |