bonding: comparing a u8 with -1 is always false
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 4 Nov 2011 08:21:38 +0000 (08:21 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 4 Nov 2011 22:37:23 +0000 (18:37 -0400)
slave->duplex is a u8 type so the in bond_info_show_slave() when we
check "if (slave->duplex == -1)", it's always false.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bonding/bond_main.c
drivers/net/bonding/bond_procfs.c
include/linux/ethtool.h

index b2b9109b6712ef63212600811d3b879687dbc215..b0c577256487b4b7c35d690da3a2ca619d2deb4c 100644 (file)
@@ -560,8 +560,8 @@ static int bond_update_speed_duplex(struct slave *slave)
        u32 slave_speed;
        int res;
 
-       slave->speed = -1;
-       slave->duplex = -1;
+       slave->speed = SPEED_UNKNOWN;
+       slave->duplex = DUPLEX_UNKNOWN;
 
        res = __ethtool_get_settings(slave_dev, &ecmd);
        if (res < 0)
index d2ff52e63cbb614ea01c817a1342a6195a4de91d..17206da2fab7a2da03e210732f8ec99f70c6d80e 100644 (file)
@@ -157,12 +157,12 @@ static void bond_info_show_slave(struct seq_file *seq,
        seq_printf(seq, "\nSlave Interface: %s\n", slave->dev->name);
        seq_printf(seq, "MII Status: %s\n",
                   (slave->link == BOND_LINK_UP) ?  "up" : "down");
-       if (slave->speed == -1)
+       if (slave->speed == SPEED_UNKNOWN)
                seq_printf(seq, "Speed: %s\n", "Unknown");
        else
                seq_printf(seq, "Speed: %d Mbps\n", slave->speed);
 
-       if (slave->duplex == -1)
+       if (slave->duplex == DUPLEX_UNKNOWN)
                seq_printf(seq, "Duplex: %s\n", "Unknown");
        else
                seq_printf(seq, "Duplex: %s\n", slave->duplex ? "full" : "half");
index 45f00b61c096ec025dfac142c7aaef501bd449dc..de33de1e205295150efb604dbcf6a56f9b4e91e5 100644 (file)
@@ -1097,10 +1097,12 @@ struct ethtool_ops {
 #define SPEED_1000             1000
 #define SPEED_2500             2500
 #define SPEED_10000            10000
+#define SPEED_UNKNOWN          -1
 
 /* Duplex, half or full. */
 #define DUPLEX_HALF            0x00
 #define DUPLEX_FULL            0x01
+#define DUPLEX_UNKNOWN         0xff
 
 /* Which connector port. */
 #define PORT_TP                        0x00