summaryrefslogtreecommitdiff
path: root/src/shared/ethtool-util.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-06-25 11:10:07 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-06-25 11:44:19 +0900
commitd16c272844a81a3de094906698eb6256313b2bb5 (patch)
treea6cafb8ea809b5d861a606f7888059571d773662 /src/shared/ethtool-util.c
parentffba064ae4d178b95733aed7c795ad799ddec2c4 (diff)
downloadsystemd-d16c272844a81a3de094906698eb6256313b2bb5.tar.gz
ethtool-util: fix returned value when ethtool_cmd_speed() is SPEED_UNKNOWN
Diffstat (limited to 'src/shared/ethtool-util.c')
-rw-r--r--src/shared/ethtool-util.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/shared/ethtool-util.c b/src/shared/ethtool-util.c
index b2a81e4215..49a2b3ad3d 100644
--- a/src/shared/ethtool-util.c
+++ b/src/shared/ethtool-util.c
@@ -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;