Skip to contentSkip to conversation

Fix clang compilation on FreeBSD

PATCH Applied Bruce Richardson 2 participants 4 messages Dec 1, 2014 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

cover Fix clang compilation on FreeBSD

This patch contains fixes for two compilation errors that occur with clang on FreeBSD. These errors are not seen when compiling with clang on Fedora Linux.

Bruce Richardson (2):
testpmd: fix out-of-range compiler error
testpmd: fix macro check for little endian

 app/test-pmd/csumonly.c | 2 +-
 app/test-pmd/icmpecho.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.1.0
#2 lore raw

PATCH 1/2 testpmd: fix out-of-range compiler error

In reply to a message not in the archive

The definition value for IPPROTO_DIVERT protocol uses a value which is out of range of the uint8_t type, giving clang compiler errors on FreeBSD.

app/test-pmd/icmpecho.c:231:7: fatal error: overflow converting case value to switch condition type (258 to 2) [-Wswitch]
case IPPROTO_DIVERT: /**< divert pseudo-protocol */

This is fixed by having the code to return the protocol name use the uint16_t type for the protocol value input.

---
 app/test-pmd/icmpecho.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/icmpecho.c +1 -1
index c25a54b..08ea01d 100644
@@ -88,7 +88,7 @@ arp_op_name(uint16_t arp_op)
 }
 
 static const char *
-ip_proto_name(uint8_t ip_proto)
+ip_proto_name(uint16_t ip_proto)
 {
 	static const char * ip_proto_names[] = {
 		"IP6HOPOPTS", /**< IP6 hop-by-hop options */
Signature · 1 line
2.1.0
#3 lore raw

PATCH 2/2 testpmd: fix macro check for little endian

In reply to a message not in the archive

Compiling with clang on FreeBSD gave a compilation error:
app/test-pmd/csumonly.c:84:5: fatal error: '__BYTE_ORDER' is not defined, evaluates to 0 [-Wundef]

Querying the preprocessor defines show both the define and value used are incorrect.

$ clang -dM -E - < /dev/null | grep BYTE
\#define  __BYTE_ORDER__  __ORDER_LITTLE_ENDIAN__

Changing the check to __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ then resolves the issue.

---
 app/test-pmd/csumonly.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-pmd/csumonly.c +1 -1
index d8c080a..6f43761 100644
@@ -81,7 +81,7 @@
 
 /* we cannot use htons() from arpa/inet.h due to name conflicts, and we
  * cannot use rte_cpu_to_be_16() on a constant in a switch/case */
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#if  __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
 #define _htons(x) ((uint16_t)((((x) & 0x00ffU) << 8) | (((x) & 0xff00U) >> 8)))
 #else
 #define _htons(x) (x)
Signature · 1 line
2.1.0