From: Yu Watanabe Date: Tue, 25 Jun 2019 02:10:07 +0000 (+0900) Subject: ethtool-util: fix returned value when ethtool_cmd_speed() is SPEED_UNKNOWN X-Git-Tag: v243-rc1~238^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d16c272844a81a3de094906698eb6256313b2bb5;p=thirdparty%2Fsystemd.git ethtool-util: fix returned value when ethtool_cmd_speed() is SPEED_UNKNOWN --- diff --git a/src/shared/ethtool-util.c b/src/shared/ethtool-util.c index b2a81e4215c..49a2b3ad3d9 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;