OSDN Git Service

ice: fix signed vs unsigned comparisons
authorJesse Brandeburg <jesse.brandeburg@intel.com>
Sat, 16 May 2020 00:36:38 +0000 (17:36 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Thu, 28 May 2020 00:02:47 +0000 (17:02 -0700)
Fix the remaining signed vs unsigned issues, which appear
when compiling with -Werror=sign-compare.

Many of these are because there is an external interface that is passing
an int to us (which we can't change) but that we (rightfully) store
and compare against as an unsigned in our data structures.

Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Signed-off-by: Bruce Allan <bruce.w.allan@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/ice/ice_base.c
drivers/net/ethernet/intel/ice/ice_main.c
drivers/net/ethernet/intel/ice/ice_txrx.h

index 94d833b..9452c0e 100644 (file)
@@ -13,7 +13,7 @@
  */
 static int __ice_vsi_get_qs_contig(struct ice_qs_cfg *qs_cfg)
 {
-       int offset, i;
+       unsigned int offset, i;
 
        mutex_lock(qs_cfg->qs_mutex);
        offset = bitmap_find_next_zero_area(qs_cfg->pf_map, qs_cfg->pf_map_size,
@@ -39,7 +39,7 @@ static int __ice_vsi_get_qs_contig(struct ice_qs_cfg *qs_cfg)
  */
 static int __ice_vsi_get_qs_sc(struct ice_qs_cfg *qs_cfg)
 {
-       int i, index = 0;
+       unsigned int i, index = 0;
 
        mutex_lock(qs_cfg->qs_mutex);
        for (i = 0; i < qs_cfg->q_count; i++) {
index 1c255b2..c2da3e1 100644 (file)
@@ -5035,7 +5035,7 @@ static int ice_change_mtu(struct net_device *netdev, int new_mtu)
        struct ice_pf *pf = vsi->back;
        u8 count = 0;
 
-       if (new_mtu == netdev->mtu) {
+       if (new_mtu == (int)netdev->mtu) {
                netdev_warn(netdev, "MTU is already %u\n", netdev->mtu);
                return 0;
        }
@@ -5050,11 +5050,11 @@ static int ice_change_mtu(struct net_device *netdev, int new_mtu)
                }
        }
 
-       if (new_mtu < netdev->min_mtu) {
+       if (new_mtu < (int)netdev->min_mtu) {
                netdev_err(netdev, "new MTU invalid. min_mtu is %d\n",
                           netdev->min_mtu);
                return -EINVAL;
-       } else if (new_mtu > netdev->max_mtu) {
+       } else if (new_mtu > (int)netdev->max_mtu) {
                netdev_err(netdev, "new MTU invalid. max_mtu is %d\n",
                           netdev->min_mtu);
                return -EINVAL;
@@ -5075,7 +5075,7 @@ static int ice_change_mtu(struct net_device *netdev, int new_mtu)
                return -EBUSY;
        }
 
-       netdev->mtu = new_mtu;
+       netdev->mtu = (unsigned int)new_mtu;
 
        /* if VSI is up, bring it down and then back up */
        if (!test_and_set_bit(__ICE_DOWN, vsi->state)) {
index cf21b4f..e70c461 100644 (file)
@@ -38,7 +38,8 @@
  */
 #if (PAGE_SIZE < 8192)
 #define ICE_2K_TOO_SMALL_WITH_PADDING \
-((NET_SKB_PAD + ICE_RXBUF_1536) > SKB_WITH_OVERHEAD(ICE_RXBUF_2048))
+       ((unsigned int)(NET_SKB_PAD + ICE_RXBUF_1536) > \
+                       SKB_WITH_OVERHEAD(ICE_RXBUF_2048))
 
 /**
  * ice_compute_pad - compute the padding
@@ -107,8 +108,8 @@ static inline int ice_skb_pad(void)
 #define DESC_NEEDED (MAX_SKB_FRAGS + ICE_DESCS_FOR_CTX_DESC + \
                     ICE_DESCS_PER_CACHE_LINE + ICE_DESCS_FOR_SKB_DATA_PTR)
 #define ICE_DESC_UNUSED(R)     \
-       ((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
-       (R)->next_to_clean - (R)->next_to_use - 1)
+       (u16)((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \
+             (R)->next_to_clean - (R)->next_to_use - 1)
 
 #define ICE_TX_FLAGS_TSO       BIT(0)
 #define ICE_TX_FLAGS_HW_VLAN   BIT(1)