From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <wujingji@shecgisg004.sh.intel.com>
Received: from mga01.intel.com (mga01.intel.com [192.55.52.88])
 by dpdk.org (Postfix) with ESMTP id 2C5E48E83
 for <dev@dpdk.org>; Sun,  6 Sep 2015 09:13:36 +0200 (CEST)
Received: from fmsmga001.fm.intel.com ([10.253.24.23])
 by fmsmga101.fm.intel.com with ESMTP; 06 Sep 2015 00:13:20 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.17,478,1437462000"; d="scan'208";a="783753614"
Received: from shvmail01.sh.intel.com ([10.239.29.42])
 by fmsmga001.fm.intel.com with ESMTP; 06 Sep 2015 00:13:08 -0700
Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com
 [10.239.29.89])
 by shvmail01.sh.intel.com with ESMTP id t867D6rq019615;
 Sun, 6 Sep 2015 15:13:06 +0800
Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1])
 by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id
 t867D46n026414; Sun, 6 Sep 2015 15:13:06 +0800
Received: (from wujingji@localhost)
 by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t867D4nP026410;
 Sun, 6 Sep 2015 15:13:04 +0800
From: Jingjing Wu <jingjing.wu@intel.com>
To: dev@dpdk.org
Date: Sun,  6 Sep 2015 15:11:39 +0800
Message-Id: <1441523526-26202-26-git-send-email-jingjing.wu@intel.com>
X-Mailer: git-send-email 1.7.4.1
In-Reply-To: <1441523526-26202-1-git-send-email-jingjing.wu@intel.com>
References: <1441523526-26202-1-git-send-email-jingjing.wu@intel.com>
Subject: [dpdk-dev] [PATCH 25/52] i40e/base: fix up type clash in
	i40e_aq_rc_to_posix conversion
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Sun, 06 Sep 2015 07:13:36 -0000

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

Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 drivers/net/i40e/base/i40e_adminq.h | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/i40e/base/i40e_adminq.h b/drivers/net/i40e/base/i40e_adminq.h
index 3d267bc..434c754 100644
--- a/drivers/net/i40e/base/i40e_adminq.h
+++ b/drivers/net/i40e/base/i40e_adminq.h
@@ -116,9 +116,10 @@ struct i40e_adminq_info {
 
 /**
  * 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(int aq_ret, u16 aq_rc)
+STATIC inline int i40e_aq_rc_to_posix(int aq_ret, int aq_rc)
 {
 	int aq_to_posix[] = {
 		0,           /* I40E_AQ_RC_OK */
@@ -150,8 +151,9 @@ STATIC inline int i40e_aq_rc_to_posix(int aq_ret, u16 aq_rc)
 	if (aq_ret == I40E_ERR_ADMIN_QUEUE_TIMEOUT)
 		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]))))
 		return -ERANGE;
+
 	return aq_to_posix[aq_rc];
 }
 
-- 
2.4.0