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 46ED74C8E for ; Thu, 31 May 2018 12:58:06 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 May 2018 03:58:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,463,1520924400"; d="scan'208";a="60619520" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 31 May 2018 03:58:00 -0700 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 w4VAw0cU004129; Thu, 31 May 2018 11:58:00 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id w4VAvx56002502; Thu, 31 May 2018 11:57:59 +0100 Received: (from aburakov@localhost) by sivswdev01.ir.intel.com with LOCAL id w4VAvx3J002497; Thu, 31 May 2018 11:57:59 +0100 From: Anatoly Burakov 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 Date: Thu, 31 May 2018 11:57:48 +0100 Message-Id: X-Mailer: git-send-email 1.7.0.7 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [RFC 1/3] fbarray: allow zero-sized elements X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 May 2018 10:58:06 -0000 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 --- 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