Commit df08fd4d authored by Shannon Nelson's avatar Shannon Nelson Committed by Jeff Kirsher

i40e/i40evf: fix a potential type compare issue

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: default avatarHelin Zhang <helin.zhang@intel.com>
Signed-off-by: default avatarShannon Nelson <shannon.nelson@intel.com>
Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent bc5166b9
...@@ -144,8 +144,7 @@ static inline int i40e_aq_rc_to_posix(int aq_ret, int aq_rc) ...@@ -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) if (aq_ret == I40E_ERR_ADMIN_QUEUE_TIMEOUT)
return -EAGAIN; return -EAGAIN;
if (aq_rc >= (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0])) || if (!((u32)aq_rc < (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0]))))
aq_rc < 0)
return -ERANGE; return -ERANGE;
return aq_to_posix[aq_rc]; return aq_to_posix[aq_rc];
......
...@@ -144,8 +144,7 @@ static inline int i40e_aq_rc_to_posix(int aq_ret, int aq_rc) ...@@ -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) if (aq_ret == I40E_ERR_ADMIN_QUEUE_TIMEOUT)
return -EAGAIN; return -EAGAIN;
if (aq_rc >= (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0])) || if (!((u32)aq_rc < (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0]))))
aq_rc < 0)
return -ERANGE; return -ERANGE;
return aq_to_posix[aq_rc]; return aq_to_posix[aq_rc];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment