From: Zbigniew Jędrzejewski-Szmek Date: Wed, 23 Oct 2019 10:24:42 +0000 (+0200) Subject: networkctl: split out helper function X-Git-Tag: v244-rc1~166^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=516e9c802ff60816e58e5cbd8c05be036199d09c;p=thirdparty%2Fsystemd.git networkctl: split out helper function --- diff --git a/src/network/networkctl.c b/src/network/networkctl.c index 7c8f25ffaee..df09f75c569 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -349,6 +349,15 @@ static int acquire_link_bitrates(sd_bus *bus, LinkInfo *link) { return 0; } +static void acquire_ether_link_info(int *fd, LinkInfo *link) { + if (ethtool_get_link_info(fd, link->name, + &link->autonegotiation, + &link->speed, + &link->duplex, + &link->port) >= 0) + link->has_ethtool_link_info = true; +} + static int acquire_link_info(sd_bus *bus, sd_netlink *rtnl, char **patterns, LinkInfo **ret) { _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL, *reply = NULL; _cleanup_free_ LinkInfo *links = NULL; @@ -382,11 +391,7 @@ static int acquire_link_info(sd_bus *bus, sd_netlink *rtnl, char **patterns, Lin if (r == 0) continue; - r = ethtool_get_link_info(&fd, links[c].name, - &links[c].autonegotiation, &links[c].speed, - &links[c].duplex, &links[c].port); - if (r >= 0) - links[c].has_ethtool_link_info = true; + acquire_ether_link_info(&fd, &links[c]); c++; }