A left shift that would produce a result that is not representable by the type of the expression's result has "undefined behavior" according to the C language standard. Avoid this by casting values that could set the upper bit to unsigned types.
Found via gcc's undefined behavior sanitizer. Signed-off-by: Lance Richardson <lrich...@redhat.com> --- lib/byte-order.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/byte-order.h b/lib/byte-order.h index e864658..782439f 100644 --- a/lib/byte-order.h +++ b/lib/byte-order.h @@ -105,9 +105,9 @@ uint32_byteswap(uint32_t crc) { (OVS_FORCE ovs_be32)((uint32_t)(B1) << 16 | (B2)) #else #define BYTES_TO_BE32(B1, B2, B3, B4) \ - (OVS_FORCE ovs_be32)((uint32_t)(B1) | (B2) << 8 | (B3) << 16 | (B4) << 24) + (OVS_FORCE ovs_be32)((B1) | (B2) << 8 | (B3) << 16 | (uint32_t)(B4) << 24) #define BE16S_TO_BE32(B1, B2) \ - (OVS_FORCE ovs_be32)((uint32_t)(B1) | (B2) << 16) + (OVS_FORCE ovs_be32)((B1) | (uint32_t)(B2) << 16) #endif /* These functions zero-extend big-endian values to longer ones, -- 2.9.4 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev