From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 991119ACB for ; Fri, 20 May 2016 14:58:31 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP; 20 May 2016 05:58:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,339,1459839600"; d="scan'208";a="985292126" Received: from gklab-246-018.igk.intel.com (HELO stargo) ([10.217.246.18]) by fmsmga002.fm.intel.com with SMTP; 20 May 2016 05:58:27 -0700 Received: by stargo (sSMTP sendmail emulation); Fri, 20 May 2016 15:03:39 +0200 From: Slawomir Mrozowicz To: helin.zhang@intel.com, jingjing.wu@intel.com Cc: dev@dpdk.org, Slawomir Mrozowicz Date: Fri, 20 May 2016 15:03:36 +0200 Message-Id: <1463749416-7658-1-git-send-email-slawomirx.mrozowicz@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH] i40e: unintended sign extension X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 May 2016 12:58:32 -0000 Suspicious implicit sign extension: pf->fdir.match_counter_index with type unsigned short (16 bits, unsigned) is promoted in pf->fdir.match_counter_index << 20 to type int (32 bits, signed), then sign-extended to type unsigned long (64 bits, unsigned). If pf->fdir.match_counter_index << 20 is greater than 0x7FFFFFFF, the upper bits of the result will all be 1. To fix the issue set explicit cast uint32_t of pf->fdir.match_counter_index. Fixes: 05999aab4ca6 ("i40e: add or delete flow director") Coverity ID 13315 Signed-off-by: Slawomir Mrozowicz --- drivers/net/i40e/i40e_fdir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c index 8aa41e5..66ef83f 100644 --- a/drivers/net/i40e/i40e_fdir.c +++ b/drivers/net/i40e/i40e_fdir.c @@ -1141,7 +1141,8 @@ i40e_fdir_filter_programming(struct i40e_pf *pf, fdirdp->dtype_cmd_cntindex |= rte_cpu_to_le_32(I40E_TXD_FLTR_QW1_CNT_ENA_MASK); fdirdp->dtype_cmd_cntindex |= - rte_cpu_to_le_32((pf->fdir.match_counter_index << + rte_cpu_to_le_32( + ((uint32_t)pf->fdir.match_counter_index << I40E_TXD_FLTR_QW1_CNTINDEX_SHIFT) & I40E_TXD_FLTR_QW1_CNTINDEX_MASK); -- 1.9.1