OSDN Git Service

broadcom: tg3: fix use of SPEED_UNKNOWN ethtool constant
authorMichael Zhivich <mzhivich@akamai.com>
Mon, 8 Apr 2019 14:48:46 +0000 (10:48 -0400)
committerDavid S. Miller <davem@davemloft.net>
Mon, 8 Apr 2019 23:30:43 +0000 (16:30 -0700)
commitcaf2c5205d82ff0d758096a69a7e0466c38d4dbb
tree3637c18af6bfa796964d45c512bcd87ec14606ee
parentafe64245af9f58267e7fa8fb76ad5650ee7ec25f
broadcom: tg3: fix use of SPEED_UNKNOWN ethtool constant

tg3 driver uses u16 to store SPEED_UKNOWN ethtool constant,
which is defined as -1, resulting in value truncation and
thus incorrect test results against SPEED_UNKNOWN.

For example, the following test will print "False":

u16 speed = SPEED_UNKNOWN;

if (speed == SPEED_UNKNOWN)
    printf("True");
else
    printf("False");

Change storage of speed to use u32 to avoid this issue.

Signed-off-by: Michael Zhivich <mzhivich@akamai.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/tg3.c
drivers/net/ethernet/broadcom/tg3.h