struct if_get_master_data {
int ifindex;
int master_ifindex;
- int pending;
+ bool pending;
};
static void if_get_master_dsa_linkinfo_attr(struct if_get_master_data *data,
continue;
data->master_ifindex = *(__u32 *)RTA_DATA(cur);
+ return;
}
}
continue;
if (cur->rta_type == IFLA_INFO_KIND && strcmp("dsa", (char *)RTA_DATA(cur)))
- break;
+ return;
if (cur->rta_type == IFLA_INFO_DATA)
if_get_master_dsa_linkinfo_attr(data, cur);
rem = nh->nlmsg_len - NLMSG_LENGTH(sizeof(*ifi));
while (RTA_OK(attr, rem)) {
- if (attr->rta_type == IFLA_LINKINFO)
+ if (attr->rta_type == IFLA_LINKINFO) {
if_get_master_linkinfo_attr(data, attr);
+ data->pending = false;
+ break;
+ }
attr = RTA_NEXT(attr, rem);
}
static int cb_if_get_master_ack(struct nl_msg *msg, void *arg)
{
struct if_get_master_data *data = (struct if_get_master_data *)arg;
- data->pending = 0;
+ data->pending = false;
+
return NL_STOP;
}
static int cb_if_get_master_error(struct sockaddr_nl *nla, struct nlmsgerr *err, void *arg)
{
struct if_get_master_data *data = (struct if_get_master_data *)arg;
- data->pending = 0;
+ data->pending = false;
+
return NL_STOP;
}
struct if_get_master_data data = {
.ifindex = if_nametoindex(dev->ifname),
.master_ifindex = -1,
- .pending = 1,
+ .pending = true,
};
int ret = -1;
if (ret < 0)
goto free;
- while (data.pending > 0)
+ while (data.pending)
nl_recvmsgs(sock_rtnl, cb);
if (data.master_ifindex >= 0)