[Intel-wired-lan] [next PATCH S11 05/15] i40e/i40evf: fix a potential type compare issue
Catherine Sullivan
catherine.sullivan at intel.com
Wed Aug 26 19:14:11 UTC 2015
From: Shannon Nelson <shannon.nelson at intel.com>
Rework an if expression to assure there is no type compare problem between
a size and a possible negative number.
Reported-by: Helin Zhang <helin.zhang at intel.com>
Signed-off-by: Shannon Nelson <shannon.nelson at intel.com>
Change-ID: I4921fcc96abfcf69490efce020a9e4007f251c99
---
drivers/net/ethernet/intel/i40e/i40e_adminq.h | 3 +--
drivers/net/ethernet/intel/i40evf/i40e_adminq.h | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq.h b/drivers/net/ethernet/intel/i40e/i40e_adminq.h
index 299e3d3..fa5c2cd 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_adminq.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_adminq.h
@@ -143,8 +143,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];
diff --git a/drivers/net/ethernet/intel/i40evf/i40e_adminq.h b/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
index c4efa6b..81f9ffa 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
+++ b/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
@@ -143,8 +143,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];
--
1.9.3
More information about the Intel-wired-lan
mailing list