DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Wodkowski, PawelX" <pawelx.wodkowski@intel.com>
To: "Doherty, Declan" <declan.doherty@intel.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] bond: fix for mac assignment to slaves device
Date: Mon, 8 Dec 2014 09:21:09 +0000	[thread overview]
Message-ID: <F6F2A6264E145F47A18AB6DF8E87425D12B67417@IRSMSX102.ger.corp.intel.com> (raw)
In-Reply-To: <1417800885-18643-1-git-send-email-declan.doherty@intel.com>

> +			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/rte_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 = 0;
+	uint8_t i;
 
 	for (i = 0; i < internals->slave_count; i++) {
 		if (internals->slaves[i].port_id ==	slave_eth_dev->data->port_id)
-			found = 1;
-
-		if (found && i < (internals->slave_count - 1))
-			memcpy(&internals->slaves[i], &internals->slaves[i+1],
-					sizeof(internals->slaves[i]));
+			break;
 	}
+
+	if (i != internals->slave_count)
+		memmove(&internals->slaves[i], &internals->slaves[i + 1],
+			sizeof(internals->slaves[0]) * (internals->slave_count - i - 1));
 
 	internals->slave_count--;
 }
@@ -1501,6 +1501,8 @@

  parent reply	other threads:[~2014-12-08  9:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-05 17:34 Declan Doherty
2014-12-08  7:10 ` Jiajia, SunX
2014-12-08  9:21 ` Wodkowski, PawelX [this message]
2014-12-08  9:31   ` Wodkowski, PawelX
2014-12-08 11:19 ` [dpdk-dev] [PATCH v2] " Declan Doherty
2014-12-08 14:54   ` Wodkowski, PawelX
2014-12-11  1:01     ` Thomas Monjalon
2014-12-09  5:43   ` Jiajia, SunX

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F6F2A6264E145F47A18AB6DF8E87425D12B67417@IRSMSX102.ger.corp.intel.com \
    --to=pawelx.wodkowski@intel.com \
    --cc=declan.doherty@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).