Fix clang compilation on FreeBSD
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
A message that is not in the archive (sent off-list or not yet received): 1417433935-29181-1-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
PATCH 1/2 testpmd: fix out-of-range compiler error
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
@@ -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
PATCH 2/2 testpmd: fix macro check for little endian
In reply to a message not in the archiveCompiling 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
@@ -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
Quoted 7 lines
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
Applied
Thanks
Signature · 1 line
Thomas