From patchwork Wed May 9 01:30:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andy Green X-Patchwork-Id: 39503 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7FC4C803D; Wed, 9 May 2018 03:31:16 +0200 (CEST) Received: from mail.warmcat.com (mail.warmcat.com [163.172.24.82]) by dpdk.org (Postfix) with ESMTP id 6959D7EEF for ; Wed, 9 May 2018 03:31:11 +0200 (CEST) From: Andy Green To: dev@dpdk.org Date: Wed, 09 May 2018 09:30:55 +0800 Message-ID: <152582945575.6809.1197897366448536704.stgit@localhost.localdomain> In-Reply-To: <152582834896.6809.14521072557832633661.stgit@localhost.localdomain> References: <152582834896.6809.14521072557832633661.stgit@localhost.localdomain> User-Agent: StGit/unknown-version Subject: [dpdk-dev] [PATCH v2 01/18] lib/libtre_table: workaround hash function cast error 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" /home/agreen/projects/dpdk/lib/librte_table/rte_table_hash_cuckoo.c: 110:16: error: cast between incompatible function types from ‘rte_table_hash_op_hash’ {aka ‘long unsigned int (*)(void *, void *, unsigned int, long unsigned int)’} to ‘uint32_t (*)(const void *, uint32_t, uint32_t)’ {aka ‘unsigned int (*)(const void *, unsigned int, unsigned int)’} [-Werror=cast-function-type] .hash_func = (rte_hash_function)(p->f_hash), The code seems to be quite broken. It's casting this typedef uint64_t (*rte_table_hash_op_hash)( void *key, void *key_mask, uint32_t key_size, uint64_t seed); to this typedef uint32_t (*rte_hash_function)(const void *key, uint32_t key_len, uint32_t init_val); if the definition with 4 args is later called with a pointer giving it three args, obviously it working is just an accident. I grepped around a bit and could not see it being cast back to the original type before use; the uses I saw have three args. I simply patch it to stop the build breaking, rather than fix it, since I am not sure what a fix should look like considering the whole code. (It seems others are working on fixing this, so you probably don't want to apply this. However it's necessary for build to continue atm) Signed-off-by: Andy Green --- lib/librte_table/rte_table_hash_cuckoo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_table/rte_table_hash_cuckoo.c b/lib/librte_table/rte_table_hash_cuckoo.c index dcb4fe978..eca72b506 100644 --- a/lib/librte_table/rte_table_hash_cuckoo.c +++ b/lib/librte_table/rte_table_hash_cuckoo.c @@ -107,7 +107,7 @@ rte_table_hash_cuckoo_create(void *params, struct rte_hash_parameters hash_cuckoo_params = { .entries = p->n_keys, .key_len = p->key_size, - .hash_func = (rte_hash_function)(p->f_hash), + .hash_func = (rte_hash_function)(void *)(p->f_hash), .hash_func_init_val = p->seed, .socket_id = socket_id, .name = p->name