sbm

simple bandwidth monitor
git clone git://git.2f30.org/sbm.git
Log | Files | Refs | LICENSE

commit 92c848c446c20bd86b2e4e4d15cb8adefd46420d
parent 10167540de9c4ccf1dd22f63259274a6f06a3554
Author: sin <sin@2f30.org>
Date:   Fri Jul 29 12:14:43 +0100

Save two levels of indentation and merge some conditionals

Diffstat:
sbm.c | 26++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/sbm.c b/sbm.c @@ -118,20 +118,18 @@ sample(char *ifname, uint64_t *rxbytes, uint64_t *txbytes, errx(1, "sysctl failed"); for (next = buf; next < buf + size; next += ifm->ifm_msglen) { ifm = (struct if_msghdr *)next; - if (ifm->ifm_type != RTM_NEWADDR) { - if (ifm->ifm_flags & IFF_UP) { - sdl = (struct sockaddr_dl *)(ifm + 1); - if (sdl->sdl_family != AF_LINK) - continue; - if (strncmp(sdl->sdl_data, ifname, sdl->sdl_nlen)) - continue; - *rxbytes = ifm->ifm_data.ifi_ibytes; - *txbytes = ifm->ifm_data.ifi_obytes; - *rxpps = ifm->ifm_data.ifi_ipackets; - *txpps = ifm->ifm_data.ifi_opackets; - break; - } - } + if (ifm->ifm_type == RTM_NEWADDR || + !(ifm->ifm_flags & IFF_UP)) + continue; + sdl = (struct sockaddr_dl *)(ifm + 1); + if (sdl->sdl_family != AF_LINK || + strncmp(sdl->sdl_data, ifname, sdl->sdl_nlen)) + continue; + *rxbytes = ifm->ifm_data.ifi_ibytes; + *txbytes = ifm->ifm_data.ifi_obytes; + *rxpps = ifm->ifm_data.ifi_ipackets; + *txpps = ifm->ifm_data.ifi_opackets; + break; } free(buf); if (!sdl)