From patchwork Wed Aug 10 13:34:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Uvarov X-Patchwork-Id: 73638 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp406167qga; Wed, 10 Aug 2016 06:35:04 -0700 (PDT) X-Received: by 10.107.8.134 with SMTP id h6mr5106963ioi.49.1470836104845; Wed, 10 Aug 2016 06:35:04 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id e19si35552742ioe.229.2016.08.10.06.35.00; Wed, 10 Aug 2016 06:35:04 -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 3103A61B94; Wed, 10 Aug 2016 13:35:00 +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 ABEDE60A4D; Wed, 10 Aug 2016 13:34:56 +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 5DE9960B0D; Wed, 10 Aug 2016 13:34:53 +0000 (UTC) Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) by lists.linaro.org (Postfix) with ESMTPS id 287B160867 for ; Wed, 10 Aug 2016 13:34:52 +0000 (UTC) Received: by mail-wm0-f42.google.com with SMTP id i5so104725018wmg.0 for ; Wed, 10 Aug 2016 06:34:52 -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=xS+bzPsiQUxDpMzeeQJyyztTRq8L4memRMHL4RdzKLk=; b=OAe0pA8FrmkMRLyrAQqc4Kpc/nhkrL2WKzMO9mQ8mTdz/gxTIYvwPxgZOFEZXlldNw K9YALvWrvse9x+NxhhZJ1oq7AyKve8zQvNTg3vC0hIByxQJ+rq0lJGYACnquGO1REpx5 pNcad7rmnRvDGoEynfZzonqG6eBdEAviqwYmUFAFB2tNbLRTvQoAF49u1YYTRFAv/gP/ oYns8Qh3Hqiuu8MI+3flDb0wVQMa16Mwfk4GdACi0h9s5P/xewP1b3e0AlIFVfrQCCSs KQHnk+Gzk8oSGBRV2n/B/SrlDr2YE3hsRduYqUqmO2S+JlIF0pm6nAXDTxEAAFaWmRli InDg== X-Gm-Message-State: AEkoouslenwFbMI4TEEsKZ8ByAPUweP5zIIrNKutl1464rQhUie+DX5c1gdM645IJ8lA3TWWtCw= X-Received: by 10.25.24.233 with SMTP id 102mr697333lfy.187.1470836091130; Wed, 10 Aug 2016 06:34:51 -0700 (PDT) Received: from localhost.localdomain ([83.220.237.18]) by smtp.gmail.com with ESMTPSA id n128sm7567609lfb.45.2016.08.10.06.34.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Aug 2016 06:34:50 -0700 (PDT) From: Maxim Uvarov To: lng-odp@lists.linaro.org Date: Wed, 10 Aug 2016 16:34:45 +0300 Message-Id: <1470836085-9582-1-git-send-email-maxim.uvarov@linaro.org> X-Mailer: git-send-email 2.7.1.250.gff4ea60 X-Topics: patch Subject: [lng-odp] [PATCH] 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 | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) -- 2.7.1.250.gff4ea60 diff --git a/helper/cuckootable.c b/helper/cuckootable.c index 91a73b4..c27c7b1 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,6 +349,12 @@ odph_cuckoo_table_destroy(odph_table_t tbl) /* destroy key-value pool */ snprintf(pool_name, sizeof(pool_name), "kv_%s", impl->name); + pool = odp_pool_lookup(pool_name); + if (pool == ODP_POOL_INVALID) { + ODPH_DBG("invalid pool\n"); + return -1; + } + ret = odp_pool_destroy(odp_pool_lookup(pool_name)); if (ret != 0) { ODPH_DBG("failed to destroy key-value buffer pool\n"); @@ -354,7 +362,13 @@ odph_cuckoo_table_destroy(odph_table_t tbl) } /* 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)