From patchwork Thu Aug 11 14:14:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 73753 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp133380qga; Thu, 11 Aug 2016 07:15:13 -0700 (PDT) X-Received: by 10.237.36.252 with SMTP id u57mr11493104qtc.39.1470924913067; Thu, 11 Aug 2016 07:15:13 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id r24si343610qkh.31.2016.08.11.07.15.12; Thu, 11 Aug 2016 07:15:13 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id A4BF561DF8; Thu, 11 Aug 2016 14:15:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id A7D8161DE1; Thu, 11 Aug 2016 14:14:39 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 1762561DF3; Thu, 11 Aug 2016 14:14:37 +0000 (UTC) Received: from mail-qk0-f179.google.com (mail-qk0-f179.google.com [209.85.220.179]) by lists.linaro.org (Postfix) with ESMTPS id 7B18E61DCF for ; Thu, 11 Aug 2016 14:14:32 +0000 (UTC) Received: by mail-qk0-f179.google.com with SMTP id p186so5354540qkd.1 for ; Thu, 11 Aug 2016 07:14:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=D45GJsGONGAOH/Ku6636rI1uuAp5111tj0svJ6g8tFc=; b=jpayFmWepnd8kDVVWavc9Vz5zS6qp4Rx8fYA2iIM7WsRjS/ZwePN4peHpZDKgzK/mD w3pRxVwgVBrOM54JGEAH2EcMWQZ5nEOlLm2qqGUSvGDATN7nPHEcJMtE52sTxPch2VD/ 11W91AhvMbDb56ohCPRD/lKw7piCFVW2TuqV64zdfWsbwc46ZUkicFGkaqgAjvKEO40k Z7BYNrHq2d4djIJG4BFa+vMbarTCKVzOp2P0qA2C56lLSvXj163PbJ526gqYlD0G5hgq Z6ehJ+G8Cr1wuK6cVyU0He+RXu2w9Xd/Ogw/IxKzMpFK7CWDPc+Y9NrqViy9wlfbjw9Z HA/Q== X-Gm-Message-State: AEkoouvsDXUl2FVa7p1BT1mFJvl/Ij1bZntbIZGu7Lf0MMjQ5jrvoxUDzwnRZ53/1on60tVNYuk= X-Received: by 10.46.33.222 with SMTP id h91mr1661697lji.50.1470924871976; Thu, 11 Aug 2016 07:14:31 -0700 (PDT) Received: from localhost.localdomain ([83.220.237.18]) by smtp.gmail.com with ESMTPSA id 21sm606913ljf.7.2016.08.11.07.14.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Aug 2016 07:14:31 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Thu, 11 Aug 2016 17:14:19 +0300 Message-Id: <1470924859-20182-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.7.1.250.gff4ea60 X-Topics: patch Subject: [lng-odp] [API-NEXT PATCHv2] helper: cuckootable: add missing return codes X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" add missing return codes for non void functions. Signed-off-by: Maxim Uvarov --- helper/cuckootable.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) -- 2.7.1.250.gff4ea60 diff --git a/helper/cuckootable.c b/helper/cuckootable.c index 91a73b4..b4fce6c 100644 --- a/helper/cuckootable.c +++ b/helper/cuckootable.c @@ -163,18 +163,19 @@ is_power_of_2(uint32_t n) odph_table_t odph_cuckoo_table_lookup(const char *name) { - odph_cuckoo_table_impl *tbl = NULL; + odph_cuckoo_table_impl *tbl; if (name == NULL || strlen(name) >= ODPH_TABLE_NAME_LEN) return NULL; tbl = (odph_cuckoo_table_impl *)odp_shm_addr(odp_shm_lookup(name)); + if (!tbl || tbl->magicword != ODPH_CUCKOO_TABLE_MAGIC_WORD) + return NULL; - if ( - tbl != NULL && - tbl->magicword == ODPH_CUCKOO_TABLE_MAGIC_WORD && - strcmp(tbl->name, name) == 0) - return (odph_table_t)tbl; + if (strcmp(tbl->name, name)) + return NULL; + + return (odph_table_t)tbl; } odph_table_t @@ -311,6 +312,9 @@ odph_cuckoo_table_destroy(odph_table_t tbl) int ret, i, j; odph_cuckoo_table_impl *impl = NULL; char pool_name[ODPH_TABLE_NAME_LEN + 3]; + odp_event_t ev; + odp_shm_t shm; + odp_pool_t pool; if (tbl == NULL) return -1; @@ -333,8 +337,6 @@ odph_cuckoo_table_destroy(odph_table_t tbl) } /* free all free buffers */ - odp_event_t ev; - while ((ev = odp_queue_deq(impl->free_slots)) != ODP_EVENT_INVALID) { odp_buffer_free(odp_buffer_from_event(ev)); @@ -347,14 +349,26 @@ odph_cuckoo_table_destroy(odph_table_t tbl) /* destroy key-value pool */ snprintf(pool_name, sizeof(pool_name), "kv_%s", impl->name); - ret = odp_pool_destroy(odp_pool_lookup(pool_name)); + pool = odp_pool_lookup(pool_name); + if (pool == ODP_POOL_INVALID) { + ODPH_DBG("invalid pool\n"); + return -1; + } + + ret = odp_pool_destroy(pool); if (ret != 0) { ODPH_DBG("failed to destroy key-value buffer pool\n"); - return ret; + return -1; } /* free impl */ - odp_shm_free(odp_shm_lookup(impl->name)); + shm = odp_shm_lookup(impl->name); + if (shm == ODP_SHM_INVALID) { + ODPH_DBG("unable look up shm\n"); + return -1; + } + + return odp_shm_free(shm); } static uint32_t hash(const odph_cuckoo_table_impl *h, const void *key)