]> git.proxmox.com Git - ovs.git/commitdiff
list.h: Define OVS_LIST_POISON statically
authorNithin Raju <nithin@vmware.com>
Fri, 18 Mar 2016 20:17:54 +0000 (13:17 -0700)
committerBen Pfaff <blp@ovn.org>
Mon, 21 Mar 2016 16:16:44 +0000 (09:16 -0700)
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.

Suggested-by: Yin Lin <linyi@vmware.com>
Signed-off-by: Nithin Raju <nithin@vmware.com>
[blp@ovn.org changed large literal to avoid sparse warning]
Signed-off-by: Ben Pfaff <blp@ovn.org>
lib/list.h

index f9c9d850717e35b73df71a50f4d46e81c8c06996..96bbafdaffdf04c6ff4d153989985d7fa8188d72 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, 2010, 2011, 2013, 2015 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2013, 2015, 2016 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include "openvswitch/list.h"
 
 /* "struct ovs_list" with pointers that will (probably) cause segfaults if
- * dereferenced and, better yet, show up clearly in a debugger. */
-#define OVS_LIST_POISON \
-(struct ovs_list) { (struct ovs_list *) (uintptr_t) 0xccccccccccccccccULL, \
-                    (struct ovs_list *) (uintptr_t) 0xccccccccccccccccULL }
+ * dereferenced and, better yet, show up clearly in a debugger.
+
+ * MSVC2015 doesn't support designated initializers when compiling C++,
+ * and doesn't support ternary operators with non-designated initializers.
+ * So we use these static definitions rather than using initializer macros. */
+static const struct ovs_list OVS_LIST_POISON =
+    { (struct ovs_list *) (UINTPTR_MAX / 0xf * 0xc),
+      (struct ovs_list *) (UINTPTR_MAX / 0xf * 0xc) };
 
 static inline void list_init(struct ovs_list *);
 static inline void list_poison(struct ovs_list *);