mirror of
https://github.com/openvswitch/ovs
synced 2025-09-01 06:45:17 +00:00
list.h: Define OVS_LIST_POISON statically
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>
This commit is contained in:
14
lib/list.h
14
lib/list.h
@@ -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.
|
||||
@@ -24,10 +24,14 @@
|
||||
#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 *);
|
||||
|
Reference in New Issue
Block a user