Commit 1fa89a4b authored by Shannon Nelson's avatar Shannon Nelson Committed by Jeff Kirsher

i40e/i40evf: fix up type clash in i40e_aq_rc_to_posix conversion

The error code sent into i40e_aq_rc_to_posix() are signed values, so we
really need to treat them as such.

Change-ID: I3d1ae0ee9ae0b1b6f5fc424f8b8cc58b0ea93203
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 4c4935a9
...@@ -109,9 +109,10 @@ struct i40e_adminq_info { ...@@ -109,9 +109,10 @@ struct i40e_adminq_info {
/** /**
* i40e_aq_rc_to_posix - convert errors to user-land codes * i40e_aq_rc_to_posix - convert errors to user-land codes
* aq_rc: AdminQ error code to convert * aq_ret: AdminQ handler error code can override aq_rc
* aq_rc: AdminQ firmware error code to convert
**/ **/
static inline int i40e_aq_rc_to_posix(u32 aq_ret, u16 aq_rc) static inline int i40e_aq_rc_to_posix(int aq_ret, int aq_rc)
{ {
int aq_to_posix[] = { int aq_to_posix[] = {
0, /* I40E_AQ_RC_OK */ 0, /* I40E_AQ_RC_OK */
...@@ -143,8 +144,10 @@ static inline int i40e_aq_rc_to_posix(u32 aq_ret, u16 aq_rc) ...@@ -143,8 +144,10 @@ static inline int i40e_aq_rc_to_posix(u32 aq_ret, u16 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 >= ARRAY_SIZE(aq_to_posix)) if (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];
} }
......
...@@ -109,9 +109,10 @@ struct i40e_adminq_info { ...@@ -109,9 +109,10 @@ struct i40e_adminq_info {
/** /**
* i40e_aq_rc_to_posix - convert errors to user-land codes * i40e_aq_rc_to_posix - convert errors to user-land codes
* aq_rc: AdminQ error code to convert * aq_ret: AdminQ handler error code can override aq_rc
* aq_rc: AdminQ firmware error code to convert
**/ **/
static inline int i40e_aq_rc_to_posix(u32 aq_ret, u16 aq_rc) static inline int i40e_aq_rc_to_posix(int aq_ret, int aq_rc)
{ {
int aq_to_posix[] = { int aq_to_posix[] = {
0, /* I40E_AQ_RC_OK */ 0, /* I40E_AQ_RC_OK */
...@@ -143,8 +144,10 @@ static inline int i40e_aq_rc_to_posix(u32 aq_ret, u16 aq_rc) ...@@ -143,8 +144,10 @@ static inline int i40e_aq_rc_to_posix(u32 aq_ret, u16 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 >= ARRAY_SIZE(aq_to_posix)) if (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