DPDK patches and discussions
 help / color / mirror / Atom feed
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, hemant.agrawal@nxp.com,
	bruce.richardson@intel.com, ferruh.yigit@intel.com,
	konstantin.ananyev@intel.com, jerin.jacob@caviumnetworks.com,
	olivier.matz@6wind.com, stephen@networkplumber.org,
	nhorman@tuxdriver.com, david.marchand@6wind.com,
	gowrishankar.m@linux.vnet.ibm.com
Subject: [dpdk-dev] [RFC 1/3] fbarray: allow zero-sized elements
Date: Thu, 31 May 2018 11:57:48 +0100	[thread overview]
Message-ID: <feb11c52d421567123dc1da39eed9e3e9e16b358.1527764061.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <cover.1527764061.git.anatoly.burakov@intel.com>
In-Reply-To: <cover.1527764061.git.anatoly.burakov@intel.com>

We need to keep usage of our memory area indexed, but we don't
actually need to store any data - we need just the indexing
capabilities of fbarray. Yet, it currently disallows zero-sized
elements. Fix that by removing the check for zero-sized elements -
the rest will work correctly already.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/librte_eal/common/eal_common_fbarray.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_fbarray.c b/lib/librte_eal/common/eal_common_fbarray.c
index 019f84c18..4a365e7ce 100644
--- a/lib/librte_eal/common/eal_common_fbarray.c
+++ b/lib/librte_eal/common/eal_common_fbarray.c
@@ -391,9 +391,9 @@ set_used(struct rte_fbarray *arr, unsigned int idx, bool used)
 }
 
 static int
-fully_validate(const char *name, unsigned int elt_sz, unsigned int len)
+fully_validate(const char *name, unsigned int len)
 {
-	if (name == NULL || elt_sz == 0 || len == 0 || len > INT_MAX) {
+	if (name == NULL || len == 0 || len > INT_MAX) {
 		rte_errno = EINVAL;
 		return -1;
 	}
@@ -420,7 +420,7 @@ rte_fbarray_init(struct rte_fbarray *arr, const char *name, unsigned int len,
 		return -1;
 	}
 
-	if (fully_validate(name, elt_sz, len))
+	if (fully_validate(name, len))
 		return -1;
 
 	page_sz = sysconf(_SC_PAGESIZE);
@@ -511,7 +511,7 @@ rte_fbarray_attach(struct rte_fbarray *arr)
 	 * the array, so the parts we care about will not race.
 	 */
 
-	if (fully_validate(arr->name, arr->elt_sz, arr->len))
+	if (fully_validate(arr->name, arr->len))
 		return -1;
 
 	page_sz = sysconf(_SC_PAGESIZE);
@@ -858,7 +858,7 @@ rte_fbarray_dump_metadata(struct rte_fbarray *arr, FILE *f)
 		return;
 	}
 
-	if (fully_validate(arr->name, arr->elt_sz, arr->len)) {
+	if (fully_validate(arr->name, arr->len)) {
 		fprintf(f, "Invalid file-backed array\n");
 		goto out;
 	}
-- 
2.17.0

  reply	other threads:[~2018-05-31 10:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-31 10:57 [dpdk-dev] [RFC 0/3] Make device mapping more reliable Anatoly Burakov
2018-05-31 10:57 ` Anatoly Burakov [this message]
2018-05-31 10:57 ` [dpdk-dev] [RFC 2/3] mem: add device memory reserve/free API Anatoly Burakov
2018-05-31 10:57 ` [dpdk-dev] [RFC 3/3] bus/pci: use the new device memory API for BAR mapping Anatoly Burakov
2018-08-14 10:13 ` [dpdk-dev] [RFC 0/3] Make device mapping more reliable Burakov, Anatoly

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=feb11c52d421567123dc1da39eed9e3e9e16b358.1527764061.git.anatoly.burakov@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=david.marchand@6wind.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=gowrishankar.m@linux.vnet.ibm.com \
    --cc=hemant.agrawal@nxp.com \
    --cc=jerin.jacob@caviumnetworks.com \
    --cc=konstantin.ananyev@intel.com \
    --cc=nhorman@tuxdriver.com \
    --cc=olivier.matz@6wind.com \
    --cc=stephen@networkplumber.org \
    --cc=thomas@monjalon.net \
    /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).