]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
networkctl: split out helper function
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 23 Oct 2019 10:24:42 +0000 (12:24 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 23 Oct 2019 10:29:04 +0000 (12:29 +0200)
src/network/networkctl.c

index 7c8f25ffaee544271b0ea10fc19166aaa2f900ea..df09f75c56936ff100143370eeecda2b3c7d5ec2 100644 (file)
@@ -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++;
         }