]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ethtool-util: fix returned value when ethtool_cmd_speed() is SPEED_UNKNOWN
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 25 Jun 2019 02:10:07 +0000 (11:10 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 25 Jun 2019 02:44:19 +0000 (11:44 +0900)
src/shared/ethtool-util.c

index b2a81e4215cd1c5f0a914a86dfed4521ee6e538d..49a2b3ad3d9371a53ad4588b90e9df2d381d1c95 100644 (file)
@@ -186,8 +186,13 @@ int ethtool_get_link_info(int *fd, const char *ifname,
         if (ret_autonegotiation)
                 *ret_autonegotiation = ecmd.autoneg;
 
-        if (ret_speed)
-                *ret_speed = ethtool_cmd_speed(&ecmd) * 1000 * 1000;
+        if (ret_speed) {
+                uint32_t speed;
+
+                speed = ethtool_cmd_speed(&ecmd);
+                *ret_speed = speed == (uint32_t) SPEED_UNKNOWN ?
+                        SIZE_MAX : (size_t) speed * 1000 * 1000;
+        }
 
         if (ret_duplex)
                 *ret_duplex = ecmd.duplex;