From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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: , X-List-Received-Date: Wed, 09 May 2018 01:31:11 -0000 /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