Skip to content

Commit 0ff056e

Browse files
committed
Merge pull request godotengine#90218 from Repiteo/do-while-false-cleanup
Update lingering `do/while(0)` defines
2 parents 63db506 + bbb3eb3 commit 0ff056e

File tree

4 files changed

+27
-18
lines changed

4 files changed

+27
-18
lines changed

core/math/convex_hull.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,17 @@ subject to the following restrictions:
7777

7878
#ifdef DEBUG_ENABLED
7979
#define CHULL_ASSERT(m_cond) \
80-
do { \
80+
if constexpr (true) { \
8181
if (unlikely(!(m_cond))) { \
8282
ERR_PRINT("Assertion \"" _STR(m_cond) "\" failed."); \
8383
} \
84-
} while (0)
84+
} else \
85+
((void)0)
8586
#else
8687
#define CHULL_ASSERT(m_cond) \
87-
do { \
88-
} while (0)
88+
if constexpr (true) { \
89+
} else \
90+
((void)0)
8991
#endif
9092

9193
#if defined(DEBUG_CONVEX_HULL) || defined(SHOW_ITERATIONS)

core/os/pool_allocator.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,13 @@
3636
#include "core/string/print_string.h"
3737

3838
#define COMPACT_CHUNK(m_entry, m_to_pos) \
39-
do { \
39+
if constexpr (true) { \
4040
void *_dst = &((unsigned char *)pool)[m_to_pos]; \
4141
void *_src = &((unsigned char *)pool)[(m_entry).pos]; \
4242
memmove(_dst, _src, aligned((m_entry).len)); \
4343
(m_entry).pos = m_to_pos; \
44-
} while (0);
44+
} else \
45+
((void)0)
4546

4647
void PoolAllocator::mt_lock() const {
4748
}

core/variant/variant_op.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,18 +230,20 @@ class OperatorEvaluatorDivNZ<Vector4, Vector4i, double> {
230230
};
231231

232232
#define register_string_op(m_op_type, m_op_code) \
233-
do { \
233+
if constexpr (true) { \
234234
register_op<m_op_type<String, String>>(m_op_code, Variant::STRING, Variant::STRING); \
235235
register_op<m_op_type<String, StringName>>(m_op_code, Variant::STRING, Variant::STRING_NAME); \
236236
register_op<m_op_type<StringName, String>>(m_op_code, Variant::STRING_NAME, Variant::STRING); \
237237
register_op<m_op_type<StringName, StringName>>(m_op_code, Variant::STRING_NAME, Variant::STRING_NAME); \
238-
} while (false)
238+
} else \
239+
((void)0)
239240

240241
#define register_string_modulo_op(m_class, m_type) \
241-
do { \
242+
if constexpr (true) { \
242243
register_op<OperatorEvaluatorStringFormat<String, m_class>>(Variant::OP_MODULE, Variant::STRING, m_type); \
243244
register_op<OperatorEvaluatorStringFormat<StringName, m_class>>(Variant::OP_MODULE, Variant::STRING_NAME, m_type); \
244-
} while (false)
245+
} else \
246+
((void)0)
245247

246248
void Variant::_register_variant_operators() {
247249
memset(operator_return_type_table, 0, sizeof(operator_return_type_table));

modules/openxr/util.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,23 @@
3434
#define UNPACK(...) __VA_ARGS__
3535

3636
#define INIT_XR_FUNC_V(openxr_api, name) \
37-
do { \
37+
if constexpr (true) { \
3838
XrResult get_instance_proc_addr_result; \
3939
get_instance_proc_addr_result = openxr_api->get_instance_proc_addr(#name, (PFN_xrVoidFunction *)&name##_ptr); \
4040
ERR_FAIL_COND_V(XR_FAILED(get_instance_proc_addr_result), false); \
41-
} while (0)
41+
} else \
42+
((void)0)
4243

4344
#define EXT_INIT_XR_FUNC_V(name) INIT_XR_FUNC_V(OpenXRAPI::get_singleton(), name)
4445
#define OPENXR_API_INIT_XR_FUNC_V(name) INIT_XR_FUNC_V(this, name)
4546

4647
#define INIT_XR_FUNC(openxr_api, name) \
47-
do { \
48+
if constexpr (true) { \
4849
XrResult get_instance_proc_addr_result; \
4950
get_instance_proc_addr_result = openxr_api->get_instance_proc_addr(#name, (PFN_xrVoidFunction *)&name##_ptr); \
5051
ERR_FAIL_COND(XR_FAILED(get_instance_proc_addr_result)); \
51-
} while (0)
52+
} else \
53+
((void)0)
5254

5355
#define EXT_INIT_XR_FUNC(name) INIT_XR_FUNC(OpenXRAPI::get_singleton(), name)
5456
#define OPENXR_API_INIT_XR_FUNC(name) INIT_XR_FUNC(this, name)
@@ -59,16 +61,18 @@
5961
#define EXT_TRY_INIT_XR_FUNC(name) TRY_INIT_XR_FUNC(OpenXRAPI::get_singleton(), name)
6062
#define OPENXR_TRY_API_INIT_XR_FUNC(name) TRY_INIT_XR_FUNC(this, name)
6163
#define GDEXTENSION_INIT_XR_FUNC(name) \
62-
do { \
64+
if constexpr (true) { \
6365
name##_ptr = reinterpret_cast<PFN_##name>(get_openxr_api()->get_instance_proc_addr(#name)); \
6466
ERR_FAIL_NULL(name##_ptr); \
65-
} while (0)
67+
} else \
68+
((void)0)
6669

6770
#define GDEXTENSION_INIT_XR_FUNC_V(name) \
68-
do { \
71+
if constexpr (true) { \
6972
name##_ptr = reinterpret_cast<PFN_##name>(get_openxr_api()->get_instance_proc_addr(#name)); \
7073
ERR_FAIL_NULL_V(name##_ptr, false); \
71-
} while (0)
74+
} else \
75+
((void)0)
7276

7377
#define EXT_PROTO_XRRESULT_FUNC1(func_name, arg1_type, arg1) \
7478
PFN_##func_name func_name##_ptr = nullptr; \

0 commit comments

Comments
 (0)