i40e/i40evf: fix a potential type compare issue
authorShannon Nelson <shannon.nelson@intel.com>
Wed, 26 Aug 2015 19:14:11 +0000 (15:14 -0400)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Wed, 7 Oct 2015 20:38:11 +0000 (13:38 -0700)
Rework an if expression to assure there is no type compare problem between
a size and a possible negative number.

Change-ID: I4921fcc96abfcf69490efce020a9e4007f251c99
Reported-by: Helin Zhang <helin.zhang@intel.com>
Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/i40e/i40e_adminq.h
drivers/net/ethernet/intel/i40evf/i40e_adminq.h

index ca81b0b9db97835330e2c4f9232cf52e01c2013c..12fbbddea299efdf39a441bc922418efd97ebd40 100644 (file)
@@ -144,8 +144,7 @@ static inline int i40e_aq_rc_to_posix(int aq_ret, int aq_rc)
        if (aq_ret == I40E_ERR_ADMIN_QUEUE_TIMEOUT)
                return -EAGAIN;
 
-       if (aq_rc >= (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0])) ||
-           aq_rc < 0)
+       if (!((u32)aq_rc < (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0]))))
                return -ERANGE;
 
        return aq_to_posix[aq_rc];
index e62e951cf2088f2b090c0de98edf748e21d6d052..a3eae5d9a2bd4416c2f53336c0ba10e435182025 100644 (file)
@@ -144,8 +144,7 @@ static inline int i40e_aq_rc_to_posix(int aq_ret, int aq_rc)
        if (aq_ret == I40E_ERR_ADMIN_QUEUE_TIMEOUT)
                return -EAGAIN;
 
-       if (aq_rc >= (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0])) ||
-           aq_rc < 0)
+       if (!((u32)aq_rc < (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0]))))
                return -ERANGE;
 
        return aq_to_posix[aq_rc];