From patchwork Fri Feb 20 16:11:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maciej Gajdzica X-Patchwork-Id: 3554 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 4E744B753; Fri, 20 Feb 2015 17:11:53 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 66592B747 for ; Fri, 20 Feb 2015 17:11:51 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 20 Feb 2015 08:04:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,615,1418112000"; d="scan'208";a="457278581" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by FMSMGA003.fm.intel.com with ESMTP; 20 Feb 2015 07:56:36 -0800 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t1KGBmvt020903; Fri, 20 Feb 2015 16:11:48 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id t1KGBlrn005523; Fri, 20 Feb 2015 16:11:47 GMT Received: (from mtgajdzx@localhost) by sivswdev01.ir.intel.com with id t1KGBlBM005519; Fri, 20 Feb 2015 16:11:47 GMT From: Maciej Gajdzica To: dev@dpdk.org Date: Fri, 20 Feb 2015 16:11:43 +0000 Message-Id: <1424448703-5483-1-git-send-email-maciejx.t.gajdzica@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] bond: changed port_id type to uint8_t to prevent data loss. 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In some places port_id is declared as int, which causes data loss when using functions expecting port_id as uint8_t. Issue found with static code analysis tool. Signed-off-by: Maciej Gajdzica --- lib/librte_pmd_bond/rte_eth_bond_pmd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/rte_eth_bond_pmd.c index a8df699..3ddba25 100644 --- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c +++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c @@ -417,7 +417,7 @@ bandwidth_cmp(const void *a, const void *b) } static void -bandwidth_left(int port_id, uint64_t load, uint8_t update_idx, +bandwidth_left(uint8_t port_id, uint64_t load, uint8_t update_idx, struct bwg_slave *bwg_slave) { struct rte_eth_link link_status; @@ -1681,7 +1681,8 @@ bond_ethdev_configure(struct rte_eth_dev *dev) char *name = dev->data->name; struct bond_dev_private *internals = dev->data->dev_private; struct rte_kvargs *kvlist = internals->kvlist; - int arg_count, port_id = dev - rte_eth_devices; + int arg_count; + uint8_t port_id = dev - rte_eth_devices; /* * if no kvlist, it means that this bonded device has been created