From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id D357D8076 for ; Mon, 8 Dec 2014 10:21:11 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 08 Dec 2014 01:21:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,537,1413270000"; d="scan'208";a="634331599" Received: from irsmsx151.ger.corp.intel.com ([163.33.192.59]) by fmsmga001.fm.intel.com with ESMTP; 08 Dec 2014 01:21:10 -0800 Received: from irsmsx102.ger.corp.intel.com ([169.254.2.93]) by IRSMSX151.ger.corp.intel.com ([163.33.192.59]) with mapi id 14.03.0195.001; Mon, 8 Dec 2014 09:21:09 +0000 From: "Wodkowski, PawelX" To: "Doherty, Declan" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] bond: fix for mac assignment to slaves device Thread-Index: AQHQELH8s2mlFq9Vs0eyrOjzATCBlpyFaw1w Date: Mon, 8 Dec 2014 09:21:09 +0000 Message-ID: References: <1417800885-18643-1-git-send-email-declan.doherty@intel.com> In-Reply-To: <1417800885-18643-1-git-send-email-declan.doherty@intel.com> Accept-Language: pl-PL, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] bond: fix for mac assignment to slaves device 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: Mon, 08 Dec 2014 09:21:12 -0000 > + memmove(&internals->slaves[i], &internals- > >slaves[i+1], > + (sizeof(internals->slaves[0]) * ^^= ^ > + internals->slave_count - i - 1)); = ^^^ I think that this was not your intention. I also think that that whole slave_remove() is a little obfuscated. You are= using 'found' variable that is suggesting that there is situation when slave id might be = not in slaves array. You can do something like this diff --git a/lib/librte_pmd_bond/rte_eth_bond_pmd.c b/lib/librte_pmd_bond/r= te_eth_bond_pmd.c index bb2b909..cfa244d 100644 --- a/lib/librte_pmd_bond/rte_eth_bond_pmd.c +++ b/lib/librte_pmd_bond/rte_eth_bond_pmd.c @@ -982,16 +982,16 @@ slave_remove(struct bond_dev_private *internals, struct rte_eth_dev *slave_eth_dev) { - int i, found =3D 0; + uint8_t i; =20 for (i =3D 0; i < internals->slave_count; i++) { if (internals->slaves[i].port_id =3D=3D slave_eth_dev->data->port_id) - found =3D 1; - - if (found && i < (internals->slave_count - 1)) - memcpy(&internals->slaves[i], &internals->slaves[i+1], - sizeof(internals->slaves[i])); + break; } + + if (i !=3D internals->slave_count) + memmove(&internals->slaves[i], &internals->slaves[i + 1], + sizeof(internals->slaves[0]) * (internals->slave_count - i - 1)); =20 internals->slave_count--; } @@ -1501,6 +1501,8 @@