Skip to contentSkip to conversation

net/bnxt: fix CLANG compilation error

PATCH In review Ajit Khaparde 3 participants 5 messages Apr 20, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/bnxt: fix CLANG compilation error

Fix a compilation error seen with CLANG.
The current code causes a typedef redefinition error because 'p__LINE__' is a C11 feature. Fixing it by defining it to something which is not already defined in the language.

Fixes 3ca9012a81f9 ("net/bnxt: add initial TruFlow core session open")
---
 drivers/net/bnxt/tf_core/hwrm_tf.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/bnxt/tf_core/hwrm_tf.h +5 -1
index 2598ca7ee..6299d588a 100644
@@ -37,7 +37,11 @@ typedef enum tf_subtype {
 #define TF_MAX_REQ_SIZE 104
 /* u32_t	tlv_resp_value[170]; */
 #define TF_MAX_RESP_SIZE 680
-#define BUILD_BUG_ON(condition) typedef char p__LINE__[(condition) ? 1 : -1]
+
+#define __BUILD_BUG_ON(condition, line) \
+	char p##line[(condition) ? 1 : -1]
+#define _BUILD_BUG_ON(condition, line) __BUILD_BUG_ON(condition, line)
+#define BUILD_BUG_ON(condition) _BUILD_BUG_ON(condition, __LINE__)
 
 /* Use this to allocate/free any kind of
  * indexes over HWRM and fill the parms pointer
Signature · 1 line
2.21.1 (Apple Git-122.3)
#1 lore raw
Quoted 5 lines · Ajit Khaparde

Fix a compilation error seen with CLANG.
The current code causes a typedef redefinition error because 'p__LINE__' is a C11 feature. Fixing it by defining it to something which is not already defined in the language.

Can't you reuse the RTE_BUILD_BUG_ON macro instead of redefining this in your driver?
If the EAL macro is not enough, I suppose we could improve it.

Signature · 1 line
David Marchand
#2 lore raw
Quoted 12 lines · David Marchand
Quoted 5 lines · Ajit Khaparde

Fix a compilation error seen with CLANG.
The current code causes a typedef redefinition error because 'p__LINE__' is a C11 feature. Fixing it by defining it to something which is not already defined in the language.

Can't you reuse the RTE_BUILD_BUG_ON macro instead of redefining this in your driver?
If the EAL macro is not enough, I suppose we could improve it.

Will squash it on next-net to fix the build error. +1 to using 'RTE_BUILD_BUG_ON' comment if it possible but it can be done as incremental patch.

#3 lore raw
Quoted 9 lines · Ferruh Yigit
Quoted 8 lines · David Marchand
Quoted 5 lines · Ajit Khaparde

Fix a compilation error seen with CLANG.
The current code causes a typedef redefinition error because 'p__LINE__' is a C11 feature. Fixing it by defining it to something which is not already defined in the language.

Quoted 7 lines
Quoted 4 lines

Can't you reuse the RTE_BUILD_BUG_ON macro instead of redefining this in your driver?
If the EAL macro is not enough, I suppose we could improve it.

Will squash it on next-net to fix the build error. +1 to using 'RTE_BUILD_BUG_ON' comment if it possible but it can be done as incremental patch.

Ack.

Signature · 1 line
David Marchand
#4 lore raw
Quoted 15 lines · David Marchand
Quoted 14 lines · Ferruh Yigit
Quoted 12 lines · David Marchand
Quoted 5 lines · Ajit Khaparde

Fix a compilation error seen with CLANG.
The current code causes a typedef redefinition error because 'p__LINE__' is a C11 feature. Fixing it by defining it to something which is not already defined in the language.

Can't you reuse the RTE_BUILD_BUG_ON macro instead of redefining this in your driver?
If the EAL macro is not enough, I suppose we could improve it.

Quoted 5 lines
Quoted 2 lines

Will squash it on next-net to fix the build error. +1 to using 'RTE_BUILD_BUG_ON' comment if it possible but it can be done as incremental patch.

Ack.

Squashed into relevant commit in next-net, thanks.