The previous definitions of these variables using designated
initializers caused a variety of issues when attempting to compile with
MSVC, particularly if including these headers from C++ code. By defining
them like this, we can appease MSVC and keep the definitions the same on
all platforms.

VMware-BZ: #1517163
Suggested-by: Yin Lin <li...@vmware.com>
Signed-off-by: Joe Stringer <j...@ovn.org>
---
 include/openvswitch/types.h | 6 ++++--
 lib/util.h                  | 4 +---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/openvswitch/types.h b/include/openvswitch/types.h
index 32b27d03365e..075d24677cd9 100644
--- a/include/openvswitch/types.h
+++ b/include/openvswitch/types.h
@@ -99,8 +99,10 @@ typedef union {
     } be64;
 } ovs_be128;
 
-#define OVS_U128_MAX (ovs_u128) { .u64 = { UINT64_MAX, UINT64_MAX } }
-#define OVS_BE128_MAX (ovs_be128) { .be64 = { OVS_BE64_MAX, OVS_BE64_MAX } }
+static const ovs_u128 OVS_U128_MAX = { { UINT32_MAX, UINT32_MAX,
+                                         UINT32_MAX, UINT32_MAX } };
+static const ovs_be128 OVS_BE128_MAX = { { OVS_BE32_MAX, OVS_BE32_MAX,
+                                           OVS_BE32_MAX, OVS_BE32_MAX } };
 
 /* A 64-bit value, in network byte order, that is only aligned on a 32-bit
  * boundary. */
diff --git a/lib/util.h b/lib/util.h
index 340ef65f07ab..248058334c49 100644
--- a/lib/util.h
+++ b/lib/util.h
@@ -574,9 +574,7 @@ ovs_u128_is_zero(const ovs_u128 *val)
 static inline bool
 ovs_u128_is_ones(const ovs_u128 *val)
 {
-    ovs_u128 ones = OVS_U128_MAX;
-
-    return ovs_u128_equals(val, &ones);
+    return ovs_u128_equals(val, &OVS_U128_MAX);
 }
 
 /* Returns non-zero if the parameters have equal value. */
-- 
2.1.4

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to