[dpdk-dev] hash: fix compilation for gcc 4.4/4.5

Message ID 1436964043-5729-2-git-send-email-pablo.de.lara.guarch@intel.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

De Lara Guarch, Pablo July 15, 2015, 12:40 p.m. UTC
  gcc 4.4 and 4.5 throws following error:
rte_cuckoo_hash.c:145: error: flexible array member in otherwise empty struct.

This is due to empty length in flexible array, which has been changed to use
size 0 in the declaration of the array.

Fixes: 48a399119619 ("hash: replace with cuckoo hash implementation")

Reported-by: Olga Shern <olgas@mellanox.com>
Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 lib/librte_hash/rte_cuckoo_hash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Thomas Monjalon July 16, 2015, 2:55 p.m. UTC | #1
2015-07-15 13:40, Pablo de Lara:
> gcc 4.4 and 4.5 throws following error:
> rte_cuckoo_hash.c:145: error: flexible array member in otherwise empty struct.
> 
> This is due to empty length in flexible array, which has been changed to use
> size 0 in the declaration of the array.
> 
> Fixes: 48a399119619 ("hash: replace with cuckoo hash implementation")
> 
> Reported-by: Olga Shern <olgas@mellanox.com>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 39cafb7..80cb126 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -142,7 +142,7 @@  struct rte_hash_key {
 		void *pdata;
 	};
 	/* Variable key size */
-	char key[];
+	char key[0];
 } __attribute__((aligned(KEY_ALIGNMENT)));
 
 /** Bucket structure */