[dpdk-dev,RFC,1/3] fbarray: allow zero-sized elements
diff mbox

Message ID feb11c52d421567123dc1da39eed9e3e9e16b358.1527764061.git.anatoly.burakov@intel.com
State New
Delegated to: Thomas Monjalon
Headers show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Burakov, Anatoly May 31, 2018, 10:57 a.m. UTC
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(-)

Patch
diff mbox

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;
 	}