plugins: netlink: minor refactor, collapse for-loop

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2021-03-07 12:20:59 +01:00
1 parent 70a1acc210
commit 1abd43384b
1 file changed
+4 -5
+4 -5
View File
@@ -131,8 +131,10 @@ static void nl_link(struct nlmsghdr *nlmsg, ssize_t len)
return; return;
} }
while (RTA_OK(a, la)) { for (; RTA_OK(a, la); a = RTA_NEXT(a, la)) {
if (a->rta_type == IFLA_IFNAME) { if (a->rta_type != IFLA_IFNAME)
continue;
strlcpy(ifname, RTA_DATA(a), sizeof(ifname)); strlcpy(ifname, RTA_DATA(a), sizeof(ifname));
switch (nlmsg->nlmsg_type) { switch (nlmsg->nlmsg_type) {
case RTM_NEWLINK: case RTM_NEWLINK:
@@ -167,9 +169,6 @@ static void nl_link(struct nlmsghdr *nlmsg, ssize_t len)
break; break;
} }
} }
a = RTA_NEXT(a, la);
}
} }
static void nl_callback(void *arg, int sd, int events) static void nl_callback(void *arg, int sd, int events)