summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Admiraal <madmiraal@users.noreply.github.com>2019-11-07 10:37:44 +0100
committerMarcel Admiraal <madmiraal@users.noreply.github.com>2020-02-05 11:19:12 +0100
commit6d69cd40bd43c744fd402507a02d42d328266dc8 (patch)
tree688f46e43730a2175f5d0c09a18aefbcfe47ef7e
parentf0db13502aa455f7bef320261ea3929589fcc6d9 (diff)
Add do..while(0) wrappers to macros without one.
- Add do..while(0) wrapper to ERR_FAIL_NULL macros. - Add do..while(0) wrapper to ERR_FAIL_COND macros. - Add do..while(0) wrapper to ERR_CONTINUE macros. - Add do..while(0) wrapper to ERR_BREAK macros. - Add do..while(0) wrapper to CRASH_COND macros. - Add do..while(0) wrapper to ERR_FAIL macros. - Add do..while(0) wrapper to ERR_PRINT macros. - Add do..while(0) wrapper to WARN_PRINT macros. - Add do..while(0) wrapper to WARN_DEPRECATED macros. - Add do..while(0) wrapper to CRASH_NOW macros.
-rw-r--r--core/error_macros.h158
-rw-r--r--core/math/bsp_tree.cpp2
-rw-r--r--editor/editor_vcs_interface.cpp2
-rw-r--r--editor/import/editor_scene_importer_gltf.cpp2
-rw-r--r--editor/plugins/version_control_editor_plugin.cpp2
-rw-r--r--modules/assimp/editor_scene_importer_assimp.cpp2
-rw-r--r--modules/bullet/area_bullet.cpp2
-rw-r--r--modules/bullet/rigid_body_bullet.cpp2
-rw-r--r--scene/main/viewport.cpp2
-rw-r--r--scene/resources/texture.cpp4
10 files changed, 89 insertions, 89 deletions
diff --git a/core/error_macros.h b/core/error_macros.h
index afbf76c47d..0fe3a5d796 100644
--- a/core/error_macros.h
+++ b/core/error_macros.h
@@ -230,38 +230,38 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
// The current function returns.
#define ERR_FAIL_NULL(m_param) \
- { \
+ do { \
if (unlikely(!m_param)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null."); \
return; \
} \
- }
+ } while (0)
#define ERR_FAIL_NULL_MSG(m_param, m_msg) \
- { \
+ do { \
if (unlikely(!m_param)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null.", DEBUG_STR(m_msg)); \
return; \
} \
- }
+ } while (0)
// The current function returns m_retval.
#define ERR_FAIL_NULL_V(m_param, m_retval) \
- { \
+ do { \
if (unlikely(!m_param)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null."); \
return m_retval; \
} \
- }
+ } while (0)
#define ERR_FAIL_NULL_V_MSG(m_param, m_retval, m_msg) \
- { \
+ do { \
if (unlikely(!m_param)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Parameter \"" _STR(m_param) "\" is null.", DEBUG_STR(m_msg)); \
return m_retval; \
} \
- }
+ } while (0)
// Error condition macros.
// Ensures that `m_cond` is not true.
@@ -269,193 +269,193 @@ void _err_print_index_error(const char *p_function, const char *p_file, int p_li
// The current function returns.
#define ERR_FAIL_COND(m_cond) \
- { \
+ do { \
if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true."); \
return; \
} \
- }
+ } while (0)
#define ERR_FAIL_COND_MSG(m_cond, m_msg) \
- { \
+ do { \
if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true.", DEBUG_STR(m_msg)); \
return; \
} \
- }
+ } while (0)
// The current function returns m_retval.
#define ERR_FAIL_COND_V(m_cond, m_retval) \
- { \
+ do { \
if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. returned: " _STR(m_retval)); \
return m_retval; \
} \
- }
+ } while (0)
#define ERR_FAIL_COND_V_MSG(m_cond, m_retval, m_msg) \
- { \
+ do { \
if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. returned: " _STR(m_retval), DEBUG_STR(m_msg)); \
return m_retval; \
} \
- }
+ } while (0)
// The current loop continues.
-#define ERR_CONTINUE(m_cond) \
- { \
- if (unlikely(m_cond)) { \
+#define ERR_CONTINUE(m_cond) \
+ do { \
+ if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Continuing."); \
- continue; \
- } \
- }
+ continue; \
+ } \
+ } while (0)
-#define ERR_CONTINUE_MSG(m_cond, m_msg) \
- { \
- if (unlikely(m_cond)) { \
+#define ERR_CONTINUE_MSG(m_cond, m_msg) \
+ do { \
+ if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Continuing.", DEBUG_STR(m_msg)); \
- continue; \
- } \
- }
+ continue; \
+ } \
+ } while (0)
// The current loop breaks.
-#define ERR_BREAK(m_cond) \
- { \
- if (unlikely(m_cond)) { \
+#define ERR_BREAK(m_cond) \
+ do { \
+ if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Breaking."); \
- break; \
- } \
- }
+ break; \
+ } \
+ } while (0)
-#define ERR_BREAK_MSG(m_cond, m_msg) \
- { \
- if (unlikely(m_cond)) { \
+#define ERR_BREAK_MSG(m_cond, m_msg) \
+ do { \
+ if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition \"" _STR(m_cond) "\" is true. Breaking.", DEBUG_STR(m_msg)); \
- break; \
- } \
- }
+ break; \
+ } \
+ } while (0)
// Only use CRASH macros if there is no sensible fallback, that is, the error is unrecoverable.
#define CRASH_COND(m_cond) \
- { \
+ do { \
if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Condition \"" _STR(m_cond) "\" is true."); \
GENERATE_TRAP(); \
} \
- }
+ } while (0)
#define CRASH_COND_MSG(m_cond, m_msg) \
- { \
+ do { \
if (unlikely(m_cond)) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Condition \"" _STR(m_cond) "\" is true.", DEBUG_STR(m_msg)); \
GENERATE_TRAP(); \
} \
- }
+ } while (0)
// Generic error macros.
// The current function returns.
#define ERR_FAIL() \
- { \
+ do { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/Function Failed."); \
return; \
- }
+ } while (0)
#define ERR_FAIL_MSG(m_msg) \
- { \
+ do { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/Function Failed.", DEBUG_STR(m_msg)); \
return; \
- }
+ } while (0)
// The current function returns m_retval.
#define ERR_FAIL_V(m_retval) \
- { \
+ do { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/Function Failed, returning: " __STR(m_value)); \
return m_retval; \
- }
+ } while (0)
#define ERR_FAIL_V_MSG(m_value, m_msg) \
- { \
+ do { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Method/Function Failed, returning: " __STR(m_value), DEBUG_STR(m_msg)); \
return m_value; \
- }
+ } while (0)
// Print error message macros.
#define ERR_PRINT(m_msg) \
- { \
+ do { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, DEBUG_STR(m_msg)); \
- }
+ } while (0)
// Only prints the error message once.
#define ERR_PRINT_ONCE(m_msg) \
- { \
+ do { \
static bool first_print = true; \
if (first_print) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, DEBUG_STR(m_msg)); \
first_print = false; \
} \
- }
+ } while (0)
// Print warning message macros.
// To warn about deprecated usage, use `WARN_DEPRECATED` or `WARN_DEPRECATED_MSG` instead.
#define WARN_PRINT(m_msg) \
- { \
+ do { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, DEBUG_STR(m_msg), ERR_HANDLER_WARNING); \
- }
+ } while (0)
// Only prints the warning message once.
#define WARN_PRINT_ONCE(m_msg) \
- { \
+ do { \
static bool first_print = true; \
if (first_print) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, DEBUG_STR(m_msg), ERR_HANDLER_WARNING); \
first_print = false; \
} \
- }
+ } while (0)
// Print deprecated warning message macros.
// Only prints the warning message once.
-#define WARN_DEPRECATED \
- { \
- static volatile bool warning_shown = false; \
- if (!warning_shown) { \
+#define WARN_DEPRECATED \
+ do { \
+ static volatile bool warning_shown = false; \
+ if (!warning_shown) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "This method has been deprecated and will be removed in the future.", ERR_HANDLER_WARNING); \
- warning_shown = true; \
- } \
- }
-
-#define WARN_DEPRECATED_MSG(m_msg) \
- { \
- static volatile bool warning_shown = false; \
- if (!warning_shown) { \
+ warning_shown = true; \
+ } \
+ } while (0)
+
+#define WARN_DEPRECATED_MSG(m_msg) \
+ do { \
+ static volatile bool warning_shown = false; \
+ if (!warning_shown) { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "This method has been deprecated and will be removed in the future.", DEBUG_STR(m_msg), ERR_HANDLER_WARNING); \
- warning_shown = true; \
- } \
- }
+ warning_shown = true; \
+ } \
+ } while (0)
// Only use CRASH macros if there is no sensible fallback, that is, the error is unrecoverable.
#define CRASH_NOW() \
- { \
+ do { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Method/Function Failed."); \
GENERATE_TRAP(); \
- }
+ } while (0)
#define CRASH_NOW_MSG(m_msg) \
- { \
+ do { \
_err_print_error(FUNCTION_STR, __FILE__, __LINE__, "FATAL: Method/Function Failed.", DEBUG_STR(m_msg)); \
GENERATE_TRAP(); \
- }
+ } while (0)
#endif
diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp
index f155d626d7..7ad907db97 100644
--- a/core/math/bsp_tree.cpp
+++ b/core/math/bsp_tree.cpp
@@ -341,7 +341,7 @@ static int _bsp_create_node(const Face3 *p_faces, const Vector<int> &p_indices,
ERR_FAIL_COND_V(p_nodes.size() == BSP_Tree::MAX_NODES, -1);
// should not reach here
- ERR_FAIL_COND_V(p_indices.size() == 0, -1)
+ ERR_FAIL_COND_V(p_indices.size() == 0, -1);
int ic = p_indices.size();
const int *indices = p_indices.ptr();
diff --git a/editor/editor_vcs_interface.cpp b/editor/editor_vcs_interface.cpp
index 0562c3ba43..c420cf44e7 100644
--- a/editor/editor_vcs_interface.cpp
+++ b/editor/editor_vcs_interface.cpp
@@ -63,7 +63,7 @@ void EditorVCSInterface::_bind_methods() {
bool EditorVCSInterface::_initialize(String p_project_root_path) {
- WARN_PRINT("Selected VCS addon does not implement an initialization function. This warning will be suppressed.")
+ WARN_PRINT("Selected VCS addon does not implement an initialization function. This warning will be suppressed.");
return true;
}
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp
index f2cb1152f6..fc9c877ac7 100644
--- a/editor/import/editor_scene_importer_gltf.cpp
+++ b/editor/import/editor_scene_importer_gltf.cpp
@@ -233,7 +233,7 @@ Error EditorSceneImporterGLTF::_parse_scenes(GLTFState &state) {
if (state.json.has("scene")) {
loaded_scene = state.json["scene"];
} else {
- WARN_PRINT("The load-time scene is not defined in the glTF2 file. Picking the first scene.")
+ WARN_PRINT("The load-time scene is not defined in the glTF2 file. Picking the first scene.");
}
if (scenes.size()) {
diff --git a/editor/plugins/version_control_editor_plugin.cpp b/editor/plugins/version_control_editor_plugin.cpp
index c53fc7e6c5..3622ca8d61 100644
--- a/editor/plugins/version_control_editor_plugin.cpp
+++ b/editor/plugins/version_control_editor_plugin.cpp
@@ -203,7 +203,7 @@ void VersionControlEditorPlugin::_refresh_stage_area() {
}
} else {
- WARN_PRINT("No VCS addon is initialized. Select a Version Control Addon from Project menu.")
+ WARN_PRINT("No VCS addon is initialized. Select a Version Control Addon from Project menu.");
}
}
diff --git a/modules/assimp/editor_scene_importer_assimp.cpp b/modules/assimp/editor_scene_importer_assimp.cpp
index a547dabb60..69ab068648 100644
--- a/modules/assimp/editor_scene_importer_assimp.cpp
+++ b/modules/assimp/editor_scene_importer_assimp.cpp
@@ -389,7 +389,7 @@ EditorSceneImporterAssimp::_generate_scene(const String &p_path, aiScene *scene,
Spatial *parent_node = parent_lookup->value();
ERR_FAIL_COND_V_MSG(parent_node == NULL, state.root,
- "Parent node invalid even though lookup successful, out of ram?")
+ "Parent node invalid even though lookup successful, out of ram?");
if (spatial != state.root) {
parent_node->add_child(spatial);
diff --git a/modules/bullet/area_bullet.cpp b/modules/bullet/area_bullet.cpp
index 1cfb77e762..8d03a99556 100644
--- a/modules/bullet/area_bullet.cpp
+++ b/modules/bullet/area_bullet.cpp
@@ -167,7 +167,7 @@ bool AreaBullet::is_monitoring() const {
}
void AreaBullet::main_shape_changed() {
- CRASH_COND(!get_main_shape())
+ CRASH_COND(!get_main_shape());
btGhost->setCollisionShape(get_main_shape());
}
diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp
index 2bcb25457a..dfc9647813 100644
--- a/modules/bullet/rigid_body_bullet.cpp
+++ b/modules/bullet/rigid_body_bullet.cpp
@@ -320,7 +320,7 @@ void RigidBodyBullet::destroy_kinematic_utilities() {
}
void RigidBodyBullet::main_shape_changed() {
- CRASH_COND(!get_main_shape())
+ CRASH_COND(!get_main_shape());
btBody->setCollisionShape(get_main_shape());
set_continuous_collision_detection(is_continuous_collision_detection_enabled()); // Reset
}
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index a56903636f..72ab817e98 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -1845,7 +1845,7 @@ bool Viewport::_gui_drop(Control *p_at_control, Point2 p_at_pos, bool p_just_che
void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
- ERR_FAIL_COND(p_event.is_null())
+ ERR_FAIL_COND(p_event.is_null());
//?
/*
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 4d23f0eb41..b7805b7e38 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -2374,13 +2374,13 @@ RES ResourceFormatLoaderTextureLayered::load(const String &p_path, const String
if (tex3d.is_null()) {
f->close();
memdelete(f);
- ERR_FAIL_COND_V(tex3d.is_null(), RES())
+ ERR_FAIL_COND_V(tex3d.is_null(), RES());
}
} else if (header[0] == 'G' && header[1] == 'D' && header[2] == 'A' && header[3] == 'T') {
if (texarr.is_null()) {
f->close();
memdelete(f);
- ERR_FAIL_COND_V(texarr.is_null(), RES())
+ ERR_FAIL_COND_V(texarr.is_null(), RES());
}
} else {