From 89a311205f20efd28faff8e4695bd1af730613ae Mon Sep 17 00:00:00 2001 From: Thaddeus Crews Date: Fri, 21 Jun 2024 11:19:04 -0500 Subject: [PATCH 1/3] Style: Apply `clang-tidy` fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • `modernize-use-default-member-init` and `readability-redundant-member-init` • Minor adjustments to `.clang-tidy` to improve syntax & remove redundancies --- .clang-tidy | 21 ++++++++----------- core/typedefs.h | 2 -- core/variant/variant.cpp | 12 ++++------- core/variant/variant.h | 3 +-- .../vulkan/rendering_device_driver_vulkan.cpp | 2 +- .../vulkan/rendering_device_driver_vulkan.h | 2 +- editor/editor_node.h | 2 +- editor/gui/editor_quick_open_dialog.cpp | 3 ++- .../tiles/tile_set_atlas_source_editor.h | 2 +- modules/betsy/image_compress_betsy.h | 4 ++-- modules/navigation/nav_agent.h | 2 +- .../openxr_extension_wrapper_extension.cpp | 3 +-- scene/3d/skeleton_3d.h | 2 +- scene/3d/skeleton_ik_3d.h | 2 +- scene/gui/code_edit.h | 6 +++--- scene/gui/text_edit.h | 2 +- .../skeleton/skeleton_modification_stack_2d.h | 2 +- scene/resources/2d/tile_set.h | 2 +- .../renderer_rd/storage_rd/texture_storage.h | 6 +++--- servers/rendering/shader_language.h | 2 +- tests/servers/test_navigation_server_3d.h | 2 +- 21 files changed, 37 insertions(+), 47 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 366781cc823..1eb974f3f86 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,14 +1,12 @@ ---- -Checks: >- - -*, - cppcoreguidelines-pro-type-member-init, - modernize-redundant-void-arg, - modernize-use-bool-literals, - modernize-use-default-member-init, - modernize-use-nullptr, - readability-braces-around-statements, - readability-redundant-member-init -WarningsAsErrors: '' +Checks: + - -* + - cppcoreguidelines-pro-type-member-init + - modernize-redundant-void-arg + - modernize-use-bool-literals + - modernize-use-default-member-init + - modernize-use-nullptr + - readability-braces-around-statements + - readability-redundant-member-init HeaderFileExtensions: ['', h, hh, hpp, hxx, inc, glsl] ImplementationFileExtensions: [c, cc, cpp, cxx, m, mm, java] HeaderFilterRegex: (core|doc|drivers|editor|main|modules|platform|scene|servers|tests)/ @@ -19,4 +17,3 @@ CheckOptions: modernize-use-bool-literals.IgnoreMacros: false modernize-use-default-member-init.IgnoreMacros: false modernize-use-default-member-init.UseAssignment: true -... diff --git a/core/typedefs.h b/core/typedefs.h index 85d62df96bb..35c4668581b 100644 --- a/core/typedefs.h +++ b/core/typedefs.h @@ -315,6 +315,4 @@ struct BuildIndexSequence<0, Is...> : IndexSequence {}; #define ___gd_is_defined(val) ____gd_is_defined(__GDARG_PLACEHOLDER_##val) #define GD_IS_DEFINED(x) ___gd_is_defined(x) -#define FORCE_SEMICOLON ; - #endif // TYPEDEFS_H diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index 7550477d70e..65bfc29a555 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -2719,8 +2719,7 @@ Variant::Variant(const Vector &p_array) : } } -Variant::Variant(const Vector &p_face_array) : - type(NIL) { +Variant::Variant(const Vector &p_face_array) { PackedVector3Array vertices; int face_count = p_face_array.size(); vertices.resize(face_count * 3); @@ -2739,8 +2738,7 @@ Variant::Variant(const Vector &p_face_array) : *this = vertices; } -Variant::Variant(const Vector &p_array) : - type(NIL) { +Variant::Variant(const Vector &p_array) { Array arr; arr.resize(p_array.size()); for (int i = 0; i < p_array.size(); i++) { @@ -2749,8 +2747,7 @@ Variant::Variant(const Vector &p_array) : *this = arr; } -Variant::Variant(const Vector &p_array) : - type(NIL) { +Variant::Variant(const Vector &p_array) { PackedStringArray v; int len = p_array.size(); v.resize(len); @@ -2908,8 +2905,7 @@ Variant::Variant(const IPAddress &p_address) : memnew_placement(_data._mem, String(p_address)); } -Variant::Variant(const Variant &p_variant) : - type(NIL) { +Variant::Variant(const Variant &p_variant) { reference(p_variant); } diff --git a/core/variant/variant.h b/core/variant/variant.h index 3b1924e8eab..9702c67a371 100644 --- a/core/variant/variant.h +++ b/core/variant/variant.h @@ -814,8 +814,7 @@ public: static void unregister_types(); Variant(const Variant &p_variant); - _FORCE_INLINE_ Variant() : - type(NIL) {} + _FORCE_INLINE_ Variant() {} _FORCE_INLINE_ ~Variant() { clear(); } diff --git a/drivers/vulkan/rendering_device_driver_vulkan.cpp b/drivers/vulkan/rendering_device_driver_vulkan.cpp index f9f1168a97a..e109489f0c0 100644 --- a/drivers/vulkan/rendering_device_driver_vulkan.cpp +++ b/drivers/vulkan/rendering_device_driver_vulkan.cpp @@ -4017,7 +4017,7 @@ RDD::UniformSetID RenderingDeviceDriverVulkan::uniform_set_create(VectorViewvalue[vk_pool]++; diff --git a/drivers/vulkan/rendering_device_driver_vulkan.h b/drivers/vulkan/rendering_device_driver_vulkan.h index 33cce30b349..eeaefe43e7f 100644 --- a/drivers/vulkan/rendering_device_driver_vulkan.h +++ b/drivers/vulkan/rendering_device_driver_vulkan.h @@ -487,7 +487,7 @@ private: struct UniformSetInfo { VkDescriptorSet vk_descriptor_set = VK_NULL_HANDLE; VkDescriptorPool vk_descriptor_pool = VK_NULL_HANDLE; - DescriptorSetPools::Iterator pool_sets_it = {}; + DescriptorSetPools::Iterator pool_sets_it; }; public: diff --git a/editor/editor_node.h b/editor/editor_node.h index 39a4c7df651..49c1699c282 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -789,7 +789,7 @@ public: struct AdditiveNodeEntry { Node *node = nullptr; - NodePath parent = NodePath(); + NodePath parent; Node *owner = nullptr; int index = 0; // Used if the original parent node is lost diff --git a/editor/gui/editor_quick_open_dialog.cpp b/editor/gui/editor_quick_open_dialog.cpp index a6ad002de74..b8f3b259cab 100644 --- a/editor/gui/editor_quick_open_dialog.cpp +++ b/editor/gui/editor_quick_open_dialog.cpp @@ -649,8 +649,9 @@ QuickOpenDisplayMode QuickOpenResultContainer::get_adaptive_display_mode(const V for (const StringName &type : grid_preferred_types) { for (const StringName &base_type : p_base_types) { - if (base_type == type || ClassDB::is_parent_class(base_type, type)) + if (base_type == type || ClassDB::is_parent_class(base_type, type)) { return QuickOpenDisplayMode::GRID; + } } } diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.h b/editor/plugins/tiles/tile_set_atlas_source_editor.h index 39f2f51ef36..f8b65bd6759 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.h +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.h @@ -91,7 +91,7 @@ public: TileSetAtlasSourceEditor *tiles_set_atlas_source_editor = nullptr; Ref tile_set_atlas_source; - RBSet tiles = RBSet(); + RBSet tiles; protected: bool _set(const StringName &p_name, const Variant &p_value); diff --git a/modules/betsy/image_compress_betsy.h b/modules/betsy/image_compress_betsy.h index 4e0bf0538f1..ab7b7858030 100644 --- a/modules/betsy/image_compress_betsy.h +++ b/modules/betsy/image_compress_betsy.h @@ -91,10 +91,10 @@ class BetsyCompressor : public Object { RenderingDevice *compress_rd = nullptr; RenderingContextDriver *compress_rcd = nullptr; HashMap cached_shaders; - RID src_sampler = RID(); + RID src_sampler; // Format-specific resources. - RID dxt1_encoding_table_buffer = RID(); + RID dxt1_encoding_table_buffer; void _init(); void _assign_mt_ids(WorkerThreadPool::TaskID p_pump_task_id); diff --git a/modules/navigation/nav_agent.h b/modules/navigation/nav_agent.h index e3671504f2b..d56e053ac4c 100644 --- a/modules/navigation/nav_agent.h +++ b/modules/navigation/nav_agent.h @@ -67,7 +67,7 @@ class NavAgent : public NavRid { uint32_t avoidance_mask = 1; real_t avoidance_priority = 1.0; - Callable avoidance_callback = Callable(); + Callable avoidance_callback; bool agent_dirty = true; diff --git a/modules/openxr/extensions/openxr_extension_wrapper_extension.cpp b/modules/openxr/extensions/openxr_extension_wrapper_extension.cpp index 07ca476421d..c205e7f5bf1 100644 --- a/modules/openxr/extensions/openxr_extension_wrapper_extension.cpp +++ b/modules/openxr/extensions/openxr_extension_wrapper_extension.cpp @@ -298,8 +298,7 @@ void OpenXRExtensionWrapperExtension::register_extension_wrapper() { OpenXRAPI::register_extension_wrapper(this); } -OpenXRExtensionWrapperExtension::OpenXRExtensionWrapperExtension() : - Object(), OpenXRExtensionWrapper() { +OpenXRExtensionWrapperExtension::OpenXRExtensionWrapperExtension() { openxr_api.instantiate(); } diff --git a/scene/3d/skeleton_3d.h b/scene/3d/skeleton_3d.h index ecfe095f1de..90902f71e2f 100644 --- a/scene/3d/skeleton_3d.h +++ b/scene/3d/skeleton_3d.h @@ -162,7 +162,7 @@ private: Vector parentless_bones; AHashMap name_to_bone_index; - mutable StringName concatenated_bone_names = StringName(); + mutable StringName concatenated_bone_names; void _update_bone_names() const; void _make_dirty(); diff --git a/scene/3d/skeleton_ik_3d.h b/scene/3d/skeleton_ik_3d.h index 5d6020194e1..94145a69152 100644 --- a/scene/3d/skeleton_ik_3d.h +++ b/scene/3d/skeleton_ik_3d.h @@ -131,7 +131,7 @@ class SkeletonIK3D : public SkeletonModifier3D { real_t min_distance = 0.01; int max_iterations = 10; - Variant target_node_override_ref = Variant(); + Variant target_node_override_ref; FabrikInverseKinematic::Task *task = nullptr; #ifndef DISABLE_DEPRECATED diff --git a/scene/gui/code_edit.h b/scene/gui/code_edit.h index ab443e95e14..2cd34ec99f1 100644 --- a/scene/gui/code_edit.h +++ b/scene/gui/code_edit.h @@ -251,13 +251,13 @@ private: Ref completion_color_bg; Color breakpoint_color = Color(1, 1, 1); - Ref breakpoint_icon = Ref(); + Ref breakpoint_icon; Color bookmark_color = Color(1, 1, 1); - Ref bookmark_icon = Ref(); + Ref bookmark_icon; Color executing_line_color = Color(1, 1, 1); - Ref executing_line_icon = Ref(); + Ref executing_line_icon; Color line_number_color = Color(1, 1, 1); diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index e0d552848d5..6b137581f2f 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -139,7 +139,7 @@ private: Variant metadata; bool clickable = false; - Ref icon = Ref(); + Ref icon; String text = ""; Color color = Color(1, 1, 1); }; diff --git a/scene/resources/2d/skeleton/skeleton_modification_stack_2d.h b/scene/resources/2d/skeleton/skeleton_modification_stack_2d.h index 07321539970..d1e50cb702f 100644 --- a/scene/resources/2d/skeleton/skeleton_modification_stack_2d.h +++ b/scene/resources/2d/skeleton/skeleton_modification_stack_2d.h @@ -64,7 +64,7 @@ public: execution_mode_physics_process }; - Vector> modifications = Vector>(); + Vector> modifications; void setup(); void execute(float p_delta, int p_execution_mode); diff --git a/scene/resources/2d/tile_set.h b/scene/resources/2d/tile_set.h index 7979e2ca39a..8343c22b91b 100644 --- a/scene/resources/2d/tile_set.h +++ b/scene/resources/2d/tile_set.h @@ -836,7 +836,7 @@ private: bool flip_v = false; bool transpose = false; Vector2i texture_origin; - Ref material = Ref(); + Ref material; Color modulate = Color(1.0, 1.0, 1.0, 1.0); int z_index = 0; int y_sort_origin = 0; diff --git a/servers/rendering/renderer_rd/storage_rd/texture_storage.h b/servers/rendering/renderer_rd/storage_rd/texture_storage.h index b9acd0d7584..3d281cf98a2 100644 --- a/servers/rendering/renderer_rd/storage_rd/texture_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/texture_storage.h @@ -102,9 +102,9 @@ private: /* Canvas Texture API */ struct CanvasTextureCache { - RID diffuse = RID(); - RID normal = RID(); - RID specular = RID(); + RID diffuse; + RID normal; + RID specular; }; class CanvasTexture { diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h index ddd4c410595..4dade4d79fd 100644 --- a/servers/rendering/shader_language.h +++ b/servers/rendering/shader_language.h @@ -1213,7 +1213,7 @@ public: struct ShaderCompileInfo { HashMap functions; Vector render_modes; - VaryingFunctionNames varying_function_names = VaryingFunctionNames(); + VaryingFunctionNames varying_function_names; HashSet shader_types; GlobalShaderUniformGetTypeFunc global_shader_uniform_type_func = nullptr; bool is_include = false; diff --git a/tests/servers/test_navigation_server_3d.h b/tests/servers/test_navigation_server_3d.h index 4411b1aae5c..1b2a5e0db29 100644 --- a/tests/servers/test_navigation_server_3d.h +++ b/tests/servers/test_navigation_server_3d.h @@ -49,7 +49,7 @@ public: } unsigned function1_calls{ 0 }; - Variant function1_latest_arg0{}; + Variant function1_latest_arg0; }; static inline Array build_array() { From bb5f390fb9b466be35a5df7651323d7e66afca31 Mon Sep 17 00:00:00 2001 From: Thaddeus Crews Date: Fri, 21 Jun 2024 11:21:18 -0500 Subject: [PATCH 2/3] Style: Apply `clang-tidy` fixes (superficial) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • `modernize-use-bool-literals`, `modernize-use-nullptr`, and `readability-braces-around-statements` --- core/input/input.cpp | 2 +- core/object/message_queue.h | 2 +- drivers/gles3/storage/particles_storage.h | 2 +- .../vulkan/rendering_device_driver_vulkan.cpp | 4 +-- drivers/windows/dir_access_windows.cpp | 2 +- drivers/windows/file_access_windows.cpp | 2 +- drivers/windows/file_access_windows_pipe.cpp | 20 +++++------ drivers/windows/file_access_windows_pipe.h | 2 +- editor/animation_track_editor.cpp | 3 +- editor/plugins/bone_map_editor_plugin.cpp | 4 +-- editor/plugins/font_config_plugin.cpp | 2 +- .../plugins/tiles/tile_map_layer_editor.cpp | 2 ++ editor/project_converter_3_to_4.cpp | 6 ++-- modules/camera/camera_feed_linux.cpp | 2 +- modules/fbx/fbx_document.cpp | 12 ++++--- modules/gdscript/gdscript_disassembler.cpp | 6 ++-- modules/godot_physics_2d/godot_joints_2d.cpp | 2 +- .../godot_physics_server_2d.cpp | 4 +-- modules/godot_physics_2d/godot_space_2d.cpp | 4 +-- .../godot_collision_solver_3d_sat.cpp | 11 +++--- .../godot_physics_server_3d.cpp | 2 +- modules/godot_physics_3d/godot_shape_3d.cpp | 3 +- modules/godot_physics_3d/godot_space_3d.cpp | 4 +-- .../joints/godot_generic_6dof_joint_3d.cpp | 2 +- .../openxr_composition_layer_extension.cpp | 2 +- .../openxr_debug_utils_extension.cpp | 4 +-- .../platform/openxr_opengl_extension.cpp | 2 +- modules/openxr/openxr_api.cpp | 3 +- modules/theora/video_stream_theora.cpp | 2 +- modules/webp/webp_common.cpp | 2 +- platform/linuxbsd/os_linuxbsd.cpp | 8 ++--- .../windows/crash_handler_windows_signal.cpp | 2 +- platform/windows/display_server_windows.cpp | 2 +- platform/windows/joypad_windows.cpp | 3 +- platform/windows/native_menu_windows.cpp | 6 ++-- platform/windows/os_windows.cpp | 14 ++++---- platform/windows/windows_utils.cpp | 4 +-- scene/gui/text_edit.cpp | 4 +-- scene/resources/font.cpp | 34 +++++++++---------- servers/audio/audio_stream.cpp | 2 +- servers/rendering/renderer_canvas_cull.cpp | 3 +- .../rendering/renderer_rd/environment/gi.cpp | 2 +- .../storage_rd/particles_storage.h | 2 +- servers/rendering_server.cpp | 2 +- tests/scene/test_primitives.h | 18 ++++++---- tests/test_macros.h | 2 +- 46 files changed, 126 insertions(+), 102 deletions(-) diff --git a/core/input/input.cpp b/core/input/input.cpp index 4117193c8b7..7e2227c729f 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -1034,7 +1034,7 @@ void Input::action_release(const StringName &p_action) { // Create or retrieve existing action. ActionState &action_state = action_states[p_action]; - action_state.cache.pressed = 0; + action_state.cache.pressed = false; action_state.cache.strength = 0.0; action_state.cache.raw_strength = 0.0; // As input may come in part way through a physics tick, the earliest we can react to it is the next physics tick. diff --git a/core/object/message_queue.h b/core/object/message_queue.h index 673eb3845b5..64e244bda8b 100644 --- a/core/object/message_queue.h +++ b/core/object/message_queue.h @@ -153,7 +153,7 @@ public: bool is_flushing() const; int get_max_buffer_usage() const; - CallQueue(Allocator *p_custom_allocator = 0, uint32_t p_max_pages = 8192, const String &p_error_text = String()); + CallQueue(Allocator *p_custom_allocator = nullptr, uint32_t p_max_pages = 8192, const String &p_error_text = String()); virtual ~CallQueue(); }; diff --git a/drivers/gles3/storage/particles_storage.h b/drivers/gles3/storage/particles_storage.h index 086f5f79361..0552a5324f5 100644 --- a/drivers/gles3/storage/particles_storage.h +++ b/drivers/gles3/storage/particles_storage.h @@ -396,7 +396,7 @@ public: _FORCE_INLINE_ bool particles_has_collision(RID p_particles) { Particles *particles = particles_owner.get_or_null(p_particles); - ERR_FAIL_NULL_V(particles, 0); + ERR_FAIL_NULL_V(particles, false); return particles->has_collision_cache; } diff --git a/drivers/vulkan/rendering_device_driver_vulkan.cpp b/drivers/vulkan/rendering_device_driver_vulkan.cpp index e109489f0c0..98ba862f1e2 100644 --- a/drivers/vulkan/rendering_device_driver_vulkan.cpp +++ b/drivers/vulkan/rendering_device_driver_vulkan.cpp @@ -1519,7 +1519,7 @@ RDD::BufferID RenderingDeviceDriverVulkan::buffer_create(uint64_t p_size, BitFie ERR_FAIL_COND_V_MSG(err, BufferID(), "Can't create buffer of size: " + itos(p_size) + ", error " + itos(err) + "."); err = vmaAllocateMemoryForBuffer(allocator, vk_buffer, &alloc_create_info, &allocation, &alloc_info); ERR_FAIL_COND_V_MSG(err, BufferID(), "Can't allocate memory for buffer of size: " + itos(p_size) + ", error " + itos(err) + "."); - err = vmaBindBufferMemory2(allocator, allocation, 0, vk_buffer, NULL); + err = vmaBindBufferMemory2(allocator, allocation, 0, vk_buffer, nullptr); ERR_FAIL_COND_V_MSG(err, BufferID(), "Can't bind memory to buffer of size: " + itos(p_size) + ", error " + itos(err) + "."); // Bookkeep. @@ -1745,7 +1745,7 @@ RDD::TextureID RenderingDeviceDriverVulkan::texture_create(const TextureFormat & ERR_FAIL_COND_V_MSG(err, TextureID(), "vkCreateImage failed with error " + itos(err) + "."); err = vmaAllocateMemoryForImage(allocator, vk_image, &alloc_create_info, &allocation, &alloc_info); ERR_FAIL_COND_V_MSG(err, TextureID(), "Can't allocate memory for image, error: " + itos(err) + "."); - err = vmaBindImageMemory2(allocator, allocation, 0, vk_image, NULL); + err = vmaBindImageMemory2(allocator, allocation, 0, vk_image, nullptr); ERR_FAIL_COND_V_MSG(err, TextureID(), "Can't bind memory to image, error: " + itos(err) + "."); // Create view. diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index f7632842ed6..24a26b56ef6 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -282,7 +282,7 @@ Error DirAccessWindows::rename(String p_path, String p_new_path) { uint64_t id = OS::get_singleton()->get_ticks_usec(); while (true) { tmpfile_utf16 = (path + itos(id++) + ".tmp").utf16(); - HANDLE handle = CreateFileW((LPCWSTR)tmpfile_utf16.get_data(), GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); + HANDLE handle = CreateFileW((LPCWSTR)tmpfile_utf16.get_data(), GENERIC_WRITE, 0, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr); if (handle != INVALID_HANDLE_VALUE) { CloseHandle(handle); break; diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index a8a2ea6b5e0..5c06295f148 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -193,7 +193,7 @@ Error FileAccessWindows::open_internal(const String &p_path, int p_mode_flags) { uint64_t id = OS::get_singleton()->get_ticks_usec(); while (true) { tmpfile = path + itos(id++) + ".tmp"; - HANDLE handle = CreateFileW((LPCWSTR)tmpfile.utf16().get_data(), GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); + HANDLE handle = CreateFileW((LPCWSTR)tmpfile.utf16().get_data(), GENERIC_WRITE, 0, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr); if (handle != INVALID_HANDLE_VALUE) { CloseHandle(handle); break; diff --git a/drivers/windows/file_access_windows_pipe.cpp b/drivers/windows/file_access_windows_pipe.cpp index 9bf0f4d8527..7348b29a92b 100644 --- a/drivers/windows/file_access_windows_pipe.cpp +++ b/drivers/windows/file_access_windows_pipe.cpp @@ -40,7 +40,7 @@ Error FileAccessWindowsPipe::open_existing(HANDLE p_rfd, HANDLE p_wfd, bool p_bl _close(); path_src = String(); - ERR_FAIL_COND_V_MSG(fd[0] != 0 || fd[1] != 0, ERR_ALREADY_IN_USE, "Pipe is already in use."); + ERR_FAIL_COND_V_MSG(fd[0] != nullptr || fd[1] != nullptr, ERR_ALREADY_IN_USE, "Pipe is already in use."); fd[0] = p_rfd; fd[1] = p_wfd; @@ -58,18 +58,18 @@ Error FileAccessWindowsPipe::open_internal(const String &p_path, int p_mode_flag _close(); path_src = p_path; - ERR_FAIL_COND_V_MSG(fd[0] != 0 || fd[1] != 0, ERR_ALREADY_IN_USE, "Pipe is already in use."); + ERR_FAIL_COND_V_MSG(fd[0] != nullptr || fd[1] != nullptr, ERR_ALREADY_IN_USE, "Pipe is already in use."); path = String("\\\\.\\pipe\\LOCAL\\") + p_path.replace("pipe://", "").replace("/", "_"); - HANDLE h = CreateFileW((LPCWSTR)path.utf16().get_data(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE h = CreateFileW((LPCWSTR)path.utf16().get_data(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (h == INVALID_HANDLE_VALUE) { h = CreateNamedPipeW((LPCWSTR)path.utf16().get_data(), PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT, 1, 4096, 4096, 0, nullptr); if (h == INVALID_HANDLE_VALUE) { last_error = ERR_FILE_CANT_OPEN; return last_error; } - ConnectNamedPipe(h, NULL); + ConnectNamedPipe(h, nullptr); } fd[0] = h; fd[1] = h; @@ -79,19 +79,19 @@ Error FileAccessWindowsPipe::open_internal(const String &p_path, int p_mode_flag } void FileAccessWindowsPipe::_close() { - if (fd[0] == 0) { + if (fd[0] == nullptr) { return; } if (fd[1] != fd[0]) { CloseHandle(fd[1]); } CloseHandle(fd[0]); - fd[0] = 0; - fd[1] = 0; + fd[0] = nullptr; + fd[1] = nullptr; } bool FileAccessWindowsPipe::is_open() const { - return (fd[0] != 0 || fd[1] != 0); + return (fd[0] != nullptr || fd[1] != nullptr); } String FileAccessWindowsPipe::get_path() const { @@ -103,7 +103,7 @@ String FileAccessWindowsPipe::get_path_absolute() const { } uint64_t FileAccessWindowsPipe::get_buffer(uint8_t *p_dst, uint64_t p_length) const { - ERR_FAIL_COND_V_MSG(fd[0] == 0, -1, "Pipe must be opened before use."); + ERR_FAIL_COND_V_MSG(fd[0] == nullptr, -1, "Pipe must be opened before use."); ERR_FAIL_COND_V(!p_dst && p_length > 0, -1); DWORD read = 0; @@ -120,7 +120,7 @@ Error FileAccessWindowsPipe::get_error() const { } void FileAccessWindowsPipe::store_buffer(const uint8_t *p_src, uint64_t p_length) { - ERR_FAIL_COND_MSG(fd[1] == 0, "Pipe must be opened before use."); + ERR_FAIL_COND_MSG(fd[1] == nullptr, "Pipe must be opened before use."); ERR_FAIL_COND(!p_src && p_length > 0); DWORD read = -1; diff --git a/drivers/windows/file_access_windows_pipe.h b/drivers/windows/file_access_windows_pipe.h index 1eb3c6ef2fc..5edf0500a59 100644 --- a/drivers/windows/file_access_windows_pipe.h +++ b/drivers/windows/file_access_windows_pipe.h @@ -39,7 +39,7 @@ #define WIN32_LEAN_AND_MEAN #include class FileAccessWindowsPipe : public FileAccess { - HANDLE fd[2] = { 0, 0 }; + HANDLE fd[2] = { nullptr, nullptr }; mutable Error last_error = OK; diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 77d21cb7b07..c210ad0761b 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -6337,8 +6337,9 @@ bool AnimationTrackEditor::_is_track_compatible(int p_target_track_idx, Variant: } if (path_valid) { - if (is_source_bezier) + if (is_source_bezier) { p_source_value_type = Variant::FLOAT; + } return property_type == p_source_value_type; } else { if (animation->track_get_key_count(p_target_track_idx) > 0) { diff --git a/editor/plugins/bone_map_editor_plugin.cpp b/editor/plugins/bone_map_editor_plugin.cpp index d9f8aae7f77..8b105955e75 100644 --- a/editor/plugins/bone_map_editor_plugin.cpp +++ b/editor/plugins/bone_map_editor_plugin.cpp @@ -859,7 +859,7 @@ void BoneMapper::auto_mapping_process(Ref &p_bone_map) { // 4-1. Guess Finger int tips_index = -1; - bool thumb_tips_size = 0; + bool thumb_tips_size = false; bool named_finger_is_found = false; LocalVector fingers; fingers.push_back("thumb|pollex"); @@ -994,7 +994,7 @@ void BoneMapper::auto_mapping_process(Ref &p_bone_map) { } tips_index = -1; - thumb_tips_size = 0; + thumb_tips_size = false; named_finger_is_found = false; if (right_hand_or_palm != -1) { LocalVector> right_fingers_map; diff --git a/editor/plugins/font_config_plugin.cpp b/editor/plugins/font_config_plugin.cpp index d27e85495cd..7cf0b2d2acc 100644 --- a/editor/plugins/font_config_plugin.cpp +++ b/editor/plugins/font_config_plugin.cpp @@ -470,7 +470,7 @@ void EditorPropertyOTVariation::update_property() { Vector3i range = supported.get_value_at_index(i); EditorPropertyInteger *prop = memnew(EditorPropertyInteger); - prop->setup(range.x, range.y, false, 1, false, false); + prop->setup(range.x, range.y, false, true, false, false); prop->set_object_and_property(object.ptr(), "keys/" + itos(name_tag)); String name = TS->tag_to_name(name_tag); diff --git a/editor/plugins/tiles/tile_map_layer_editor.cpp b/editor/plugins/tiles/tile_map_layer_editor.cpp index 804db68f86b..16d4ee6f684 100644 --- a/editor/plugins/tiles/tile_map_layer_editor.cpp +++ b/editor/plugins/tiles/tile_map_layer_editor.cpp @@ -1550,6 +1550,7 @@ int TileMapLayerEditorTilesPlugin::_get_transformed_alternative(int p_alternativ case TRANSFORM_ROTATE_RIGHT: { // A matrix with every possible flip/transpose combination, sorted by what comes next when you rotate. const LocalVector rotation_matrix = { + // NOLINTBEGIN(modernize-use-bool-literals) 0, 0, 0, 0, 1, 1, 1, 1, 0, @@ -1558,6 +1559,7 @@ int TileMapLayerEditorTilesPlugin::_get_transformed_alternative(int p_alternativ 0, 0, 1, 0, 1, 0, 1, 1, 1 + // NOLINTEND(modernize-use-bool-literals) }; for (int i = 0; i < 8; i++) { diff --git a/editor/project_converter_3_to_4.cpp b/editor/project_converter_3_to_4.cpp index f8ceb871dc4..d08610c93fc 100644 --- a/editor/project_converter_3_to_4.cpp +++ b/editor/project_converter_3_to_4.cpp @@ -716,8 +716,9 @@ Vector ProjectConverter3To4::check_for_files() { directories_to_check.append(current_dir.path_join(file_name) + "/"); } else { bool proper_extension = false; - if (file_name.ends_with(".gd") || file_name.ends_with(".shader") || file_name.ends_with(".gdshader") || file_name.ends_with(".tscn") || file_name.ends_with(".tres") || file_name.ends_with(".godot") || file_name.ends_with(".cs") || file_name.ends_with(".csproj") || file_name.ends_with(".import")) + if (file_name.ends_with(".gd") || file_name.ends_with(".shader") || file_name.ends_with(".gdshader") || file_name.ends_with(".tscn") || file_name.ends_with(".tres") || file_name.ends_with(".godot") || file_name.ends_with(".cs") || file_name.ends_with(".csproj") || file_name.ends_with(".import")) { proper_extension = true; + } if (proper_extension) { collected_files.append(current_dir.path_join(file_name)); @@ -1321,8 +1322,9 @@ Vector ProjectConverter3To4::parse_arguments(const String &line) { break; }; case '"': { - if (previous_character != '\\') + if (previous_character != '\\') { is_inside_string = !is_inside_string; + } } } previous_character = character; diff --git a/modules/camera/camera_feed_linux.cpp b/modules/camera/camera_feed_linux.cpp index 94bb2b6ad32..3ae1b70ac9f 100644 --- a/modules/camera/camera_feed_linux.cpp +++ b/modules/camera/camera_feed_linux.cpp @@ -145,7 +145,7 @@ bool CameraFeedLinux::_request_buffers() { } buffers[i].length = buffer.length; - buffers[i].start = mmap(NULL, buffer.length, PROT_READ | PROT_WRITE, MAP_SHARED, file_descriptor, buffer.m.offset); + buffers[i].start = mmap(nullptr, buffer.length, PROT_READ | PROT_WRITE, MAP_SHARED, file_descriptor, buffer.m.offset); if (buffers[i].start == MAP_FAILED) { for (unsigned int b = 0; b < i; b++) { diff --git a/modules/fbx/fbx_document.cpp b/modules/fbx/fbx_document.cpp index ce097092fbd..66eac5473ee 100644 --- a/modules/fbx/fbx_document.cpp +++ b/modules/fbx/fbx_document.cpp @@ -369,21 +369,25 @@ Error FBXDocument::_parse_nodes(Ref p_state) { // all skin clusters connected to the bone. for (const ufbx_connection &child_conn : fbx_node->element.connections_src) { ufbx_skin_cluster *child_cluster = ufbx_as_skin_cluster(child_conn.dst); - if (!child_cluster) + if (!child_cluster) { continue; + } ufbx_skin_deformer *child_deformer = _find_skin_deformer(child_cluster); - if (!child_deformer) + if (!child_deformer) { continue; + } // Found a skin cluster: Now iterate through all the skin clusters of the parent and // try to find one that used by the same deformer. for (const ufbx_connection &parent_conn : fbx_node->parent->element.connections_src) { ufbx_skin_cluster *parent_cluster = ufbx_as_skin_cluster(parent_conn.dst); - if (!parent_cluster) + if (!parent_cluster) { continue; + } ufbx_skin_deformer *parent_deformer = _find_skin_deformer(parent_cluster); - if (parent_deformer != child_deformer) + if (parent_deformer != child_deformer) { continue; + } // Success: Found two skin clusters from the same deformer, now we can resolve the // local bind pose from the difference between the two world-space bind poses. diff --git a/modules/gdscript/gdscript_disassembler.cpp b/modules/gdscript/gdscript_disassembler.cpp index bc063693a39..d94a6dfda29 100644 --- a/modules/gdscript/gdscript_disassembler.cpp +++ b/modules/gdscript/gdscript_disassembler.cpp @@ -790,8 +790,9 @@ void GDScriptFunction::disassemble(const Vector &p_code_lines) const { text += method->get_name(); text += "("; for (int i = 0; i < argc; i++) { - if (i > 0) + if (i > 0) { text += ", "; + } text += DADDR(1 + i); } text += ")"; @@ -833,8 +834,9 @@ void GDScriptFunction::disassemble(const Vector &p_code_lines) const { text += method->get_name(); text += "("; for (int i = 0; i < argc; i++) { - if (i > 0) + if (i > 0) { text += ", "; + } text += DADDR(1 + i); } text += ")"; diff --git a/modules/godot_physics_2d/godot_joints_2d.cpp b/modules/godot_physics_2d/godot_joints_2d.cpp index 5c76eb9dadb..d5a779ebb58 100644 --- a/modules/godot_physics_2d/godot_joints_2d.cpp +++ b/modules/godot_physics_2d/godot_joints_2d.cpp @@ -311,7 +311,7 @@ bool GodotPinJoint2D::get_flag(PhysicsServer2D::PinJointFlag p_flag) const { return motor_enabled; } } - ERR_FAIL_V(0); + ERR_FAIL_V(false); } GodotPinJoint2D::GodotPinJoint2D(const Vector2 &p_pos, GodotBody2D *p_body_a, GodotBody2D *p_body_b) : diff --git a/modules/godot_physics_2d/godot_physics_server_2d.cpp b/modules/godot_physics_2d/godot_physics_server_2d.cpp index 71d1d3b6b18..2516ed3616d 100644 --- a/modules/godot_physics_2d/godot_physics_server_2d.cpp +++ b/modules/godot_physics_2d/godot_physics_server_2d.cpp @@ -1169,8 +1169,8 @@ void GodotPhysicsServer2D::pin_joint_set_flag(RID p_joint, PinJointFlag p_flag, bool GodotPhysicsServer2D::pin_joint_get_flag(RID p_joint, PinJointFlag p_flag) const { GodotJoint2D *joint = joint_owner.get_or_null(p_joint); - ERR_FAIL_NULL_V(joint, 0); - ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, 0); + ERR_FAIL_NULL_V(joint, false); + ERR_FAIL_COND_V(joint->get_type() != JOINT_TYPE_PIN, false); GodotPinJoint2D *pin_joint = static_cast(joint); return pin_joint->get_flag(p_flag); diff --git a/modules/godot_physics_2d/godot_space_2d.cpp b/modules/godot_physics_2d/godot_space_2d.cpp index 2966818bebb..df3c9d82659 100644 --- a/modules/godot_physics_2d/godot_space_2d.cpp +++ b/modules/godot_physics_2d/godot_space_2d.cpp @@ -342,7 +342,7 @@ bool GodotPhysicsDirectSpaceState2D::collide_shape(const ShapeParameters &p_para } GodotShape2D *shape = GodotPhysicsServer2D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid); - ERR_FAIL_NULL_V(shape, 0); + ERR_FAIL_NULL_V(shape, false); Rect2 aabb = p_parameters.transform.xform(shape->get_aabb()); aabb = aabb.merge(Rect2(aabb.position + p_parameters.motion, aabb.size)); //motion @@ -439,7 +439,7 @@ static void _rest_cbk_result(const Vector2 &p_point_A, const Vector2 &p_point_B, bool GodotPhysicsDirectSpaceState2D::rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) { GodotShape2D *shape = GodotPhysicsServer2D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid); - ERR_FAIL_NULL_V(shape, 0); + ERR_FAIL_NULL_V(shape, false); real_t margin = MAX(p_parameters.margin, TEST_MOTION_MARGIN_MIN_VALUE); diff --git a/modules/godot_physics_3d/godot_collision_solver_3d_sat.cpp b/modules/godot_physics_3d/godot_collision_solver_3d_sat.cpp index c53c8481f4b..2adbb51297d 100644 --- a/modules/godot_physics_3d/godot_collision_solver_3d_sat.cpp +++ b/modules/godot_physics_3d/godot_collision_solver_3d_sat.cpp @@ -76,8 +76,9 @@ struct _CollectorCallback { Vector3 *prev_axis = nullptr; _FORCE_INLINE_ void call(const Vector3 &p_point_A, const Vector3 &p_point_B, Vector3 p_normal) { - if (p_normal.dot(p_point_B - p_point_A) < 0) + if (p_normal.dot(p_point_B - p_point_A) < 0) { p_normal = -p_normal; + } if (swap) { callback(p_point_B, 0, p_point_A, 0, -p_normal, userdata); } else { @@ -175,10 +176,11 @@ static void _generate_contacts_edge_edge(const Vector3 *p_points_A, int p_point_ // The normal should be perpendicular to both edges. Vector3 normal = rel_A.cross(rel_B); real_t normal_len = normal.length(); - if (normal_len > 1e-3) + if (normal_len > 1e-3) { normal /= normal_len; - else + } else { normal = p_callback->normal; + } p_callback->call(closest_A, closest_B, normal); } @@ -784,8 +786,9 @@ static void analytic_sphere_collision(const Vector3 &p_origin_a, real_t p_radius // Calculate the sphere overlap, and bail if not overlapping real_t overlap = p_radius_a + p_radius_b - b_to_a_len; - if (overlap < 0) + if (overlap < 0) { return; + } // Report collision p_collector->collided = true; diff --git a/modules/godot_physics_3d/godot_physics_server_3d.cpp b/modules/godot_physics_3d/godot_physics_server_3d.cpp index 43f8d2658dc..ad55e415e62 100644 --- a/modules/godot_physics_3d/godot_physics_server_3d.cpp +++ b/modules/godot_physics_3d/godot_physics_server_3d.cpp @@ -826,7 +826,7 @@ void GodotPhysicsServer3D::body_set_axis_lock(RID p_body, BodyAxis p_axis, bool bool GodotPhysicsServer3D::body_is_axis_locked(RID p_body, BodyAxis p_axis) const { const GodotBody3D *body = body_owner.get_or_null(p_body); - ERR_FAIL_NULL_V(body, 0); + ERR_FAIL_NULL_V(body, false); return body->is_axis_locked(p_axis); } diff --git a/modules/godot_physics_3d/godot_shape_3d.cpp b/modules/godot_physics_3d/godot_shape_3d.cpp index 70b6bcf19ed..a7cccc5cb8d 100644 --- a/modules/godot_physics_3d/godot_shape_3d.cpp +++ b/modules/godot_physics_3d/godot_shape_3d.cpp @@ -1133,8 +1133,9 @@ void GodotConvexPolygonShape3D::_setup(const Vector &p_vertices) { max_support = s; } } - if (!extreme_vertices.has(best_vertex)) + if (!extreme_vertices.has(best_vertex)) { extreme_vertices.push_back(best_vertex); + } } } } diff --git a/modules/godot_physics_3d/godot_space_3d.cpp b/modules/godot_physics_3d/godot_space_3d.cpp index 9a6ba776b42..9f82a87f852 100644 --- a/modules/godot_physics_3d/godot_space_3d.cpp +++ b/modules/godot_physics_3d/godot_space_3d.cpp @@ -385,7 +385,7 @@ bool GodotPhysicsDirectSpaceState3D::collide_shape(const ShapeParameters &p_para } GodotShape3D *shape = GodotPhysicsServer3D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid); - ERR_FAIL_NULL_V(shape, 0); + ERR_FAIL_NULL_V(shape, false); AABB aabb = p_parameters.transform.xform(shape->get_aabb()); aabb = aabb.grow(p_parameters.margin); @@ -511,7 +511,7 @@ static void _rest_cbk_result(const Vector3 &p_point_A, int p_index_A, const Vect bool GodotPhysicsDirectSpaceState3D::rest_info(const ShapeParameters &p_parameters, ShapeRestInfo *r_info) { GodotShape3D *shape = GodotPhysicsServer3D::godot_singleton->shape_owner.get_or_null(p_parameters.shape_rid); - ERR_FAIL_NULL_V(shape, 0); + ERR_FAIL_NULL_V(shape, false); real_t margin = MAX(p_parameters.margin, TEST_MOTION_MARGIN_MIN_VALUE); diff --git a/modules/godot_physics_3d/joints/godot_generic_6dof_joint_3d.cpp b/modules/godot_physics_3d/joints/godot_generic_6dof_joint_3d.cpp index 226f8a0f7fe..5f9cf9de49e 100644 --- a/modules/godot_physics_3d/joints/godot_generic_6dof_joint_3d.cpp +++ b/modules/godot_physics_3d/joints/godot_generic_6dof_joint_3d.cpp @@ -647,7 +647,7 @@ void GodotGeneric6DOFJoint3D::set_flag(Vector3::Axis p_axis, PhysicsServer3D::G6 } bool GodotGeneric6DOFJoint3D::get_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const { - ERR_FAIL_INDEX_V(p_axis, 3, 0); + ERR_FAIL_INDEX_V(p_axis, 3, false); switch (p_flag) { case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT: { return m_linearLimits.enable_limit[p_axis]; diff --git a/modules/openxr/extensions/openxr_composition_layer_extension.cpp b/modules/openxr/extensions/openxr_composition_layer_extension.cpp index dc30b95b27e..2d29b8a82c4 100644 --- a/modules/openxr/extensions/openxr_composition_layer_extension.cpp +++ b/modules/openxr/extensions/openxr_composition_layer_extension.cpp @@ -341,7 +341,7 @@ XrCompositionLayerBaseHeader *OpenXRViewportCompositionLayerProvider::get_compos } XrSwapchainSubImage subimage = { - 0, // swapchain + 0, // swapchain // NOLINT(modernize-use-nullptr) - 32-bit uses non-pointer uint64 { { 0, 0 }, { 0, 0 } }, // imageRect 0, // imageArrayIndex }; diff --git a/modules/openxr/extensions/openxr_debug_utils_extension.cpp b/modules/openxr/extensions/openxr_debug_utils_extension.cpp index 10dbe629f71..cb7f72d02d2 100644 --- a/modules/openxr/extensions/openxr_debug_utils_extension.cpp +++ b/modules/openxr/extensions/openxr_debug_utils_extension.cpp @@ -173,7 +173,7 @@ void OpenXRDebugUtilsExtension::begin_debug_label_region(const char *p_label_nam const XrDebugUtilsLabelEXT session_active_region_label = { XR_TYPE_DEBUG_UTILS_LABEL_EXT, // type - NULL, // next + nullptr, // next p_label_name, // labelName }; @@ -199,7 +199,7 @@ void OpenXRDebugUtilsExtension::insert_debug_label(const char *p_label_name) { const XrDebugUtilsLabelEXT session_active_region_label = { XR_TYPE_DEBUG_UTILS_LABEL_EXT, // type - NULL, // next + nullptr, // next p_label_name, // labelName }; diff --git a/modules/openxr/extensions/platform/openxr_opengl_extension.cpp b/modules/openxr/extensions/platform/openxr_opengl_extension.cpp index f75da49d870..4fcb3f7b75b 100644 --- a/modules/openxr/extensions/platform/openxr_opengl_extension.cpp +++ b/modules/openxr/extensions/platform/openxr_opengl_extension.cpp @@ -193,7 +193,7 @@ void *OpenXROpenGLExtension::set_session_create_and_get_next_pointer(void *p_nex // spec says to use proper values but runtimes don't care graphics_binding_gl.visualid = 0; - graphics_binding_gl.glxFBConfig = 0; + graphics_binding_gl.glxFBConfig = nullptr; #endif #endif diff --git a/modules/openxr/openxr_api.cpp b/modules/openxr/openxr_api.cpp index 715d24cfd9f..a6fd7272908 100644 --- a/modules/openxr/openxr_api.cpp +++ b/modules/openxr/openxr_api.cpp @@ -2752,8 +2752,9 @@ void OpenXRAPI::parse_velocities(const XrSpaceVelocity &p_velocity, Vector3 &r_l } bool OpenXRAPI::xr_result(XrResult result, const char *format, Array args) const { - if (XR_SUCCEEDED(result)) + if (XR_SUCCEEDED(result)) { return true; + } char resultString[XR_MAX_RESULT_STRING_SIZE]; xrResultToString(instance, result, resultString); diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp index f7c6ea899f9..8b2c58acd53 100644 --- a/modules/theora/video_stream_theora.cpp +++ b/modules/theora/video_stream_theora.cpp @@ -115,7 +115,7 @@ void VideoStreamPlaybackTheora::video_write() { format = Image::FORMAT_RGBA8; } - Ref img = memnew(Image(size.x, size.y, 0, Image::FORMAT_RGBA8, frame_data)); //zero copy image creation + Ref img = memnew(Image(size.x, size.y, false, Image::FORMAT_RGBA8, frame_data)); //zero copy image creation texture->update(img); //zero copy send to rendering server diff --git a/modules/webp/webp_common.cpp b/modules/webp/webp_common.cpp index 3a2ac5a90e6..0284eec574b 100644 --- a/modules/webp/webp_common.cpp +++ b/modules/webp/webp_common.cpp @@ -149,7 +149,7 @@ Ref _webp_unpack(const Vector &p_buffer) { ERR_FAIL_COND_V_MSG(errdec, Ref(), "Failed decoding WebP image."); - Ref img = memnew(Image(features.width, features.height, 0, features.has_alpha ? Image::FORMAT_RGBA8 : Image::FORMAT_RGB8, dst_image)); + Ref img = memnew(Image(features.width, features.height, false, features.has_alpha ? Image::FORMAT_RGBA8 : Image::FORMAT_RGB8, dst_image)); return img; } diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp index 6355562febd..b309e8d8ebb 100644 --- a/platform/linuxbsd/os_linuxbsd.cpp +++ b/platform/linuxbsd/os_linuxbsd.cpp @@ -771,11 +771,11 @@ Vector OS_LinuxBSD::get_system_font_path_for_text(const String &p_font_n FcLangSetAdd(lang_set, reinterpret_cast(p_locale.utf8().get_data())); FcPatternAddLangSet(pattern, FC_LANG, lang_set); - FcConfigSubstitute(0, pattern, FcMatchPattern); + FcConfigSubstitute(nullptr, pattern, FcMatchPattern); FcDefaultSubstitute(pattern); FcResult result; - FcPattern *match = FcFontMatch(0, pattern, &result); + FcPattern *match = FcFontMatch(nullptr, pattern, &result); if (match) { char *file_name = nullptr; if (FcPatternGetString(match, FC_FILE, 0, reinterpret_cast(&file_name)) == FcResultMatch) { @@ -816,11 +816,11 @@ String OS_LinuxBSD::get_system_font_path(const String &p_font_name, int p_weight FcPatternAddInteger(pattern, FC_WIDTH, _stretch_to_fc(p_stretch)); FcPatternAddInteger(pattern, FC_SLANT, p_italic ? FC_SLANT_ITALIC : FC_SLANT_ROMAN); - FcConfigSubstitute(0, pattern, FcMatchPattern); + FcConfigSubstitute(nullptr, pattern, FcMatchPattern); FcDefaultSubstitute(pattern); FcResult result; - FcPattern *match = FcFontMatch(0, pattern, &result); + FcPattern *match = FcFontMatch(nullptr, pattern, &result); if (match) { if (!allow_substitutes) { char *family_name = nullptr; diff --git a/platform/windows/crash_handler_windows_signal.cpp b/platform/windows/crash_handler_windows_signal.cpp index e11a60bdc7f..c3a0d08ad6a 100644 --- a/platform/windows/crash_handler_windows_signal.cpp +++ b/platform/windows/crash_handler_windows_signal.cpp @@ -159,7 +159,7 @@ extern void CrashHandlerException(int signal) { // Load process and image info to determine ASLR addresses offset. MODULEINFO mi; - GetModuleInformation(GetCurrentProcess(), GetModuleHandle(NULL), &mi, sizeof(mi)); + GetModuleInformation(GetCurrentProcess(), GetModuleHandle(nullptr), &mi, sizeof(mi)); int64_t image_mem_base = reinterpret_cast(mi.lpBaseOfDll); int64_t image_file_base = get_image_base(_execpath); data.offset = image_mem_base - image_file_base; diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 3bc32fc2184..e252b26ddde 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -735,7 +735,7 @@ Error DisplayServerWindows::_file_dialog_with_options_show(const String &p_title GetWindowRect(fd->hwnd_owner, &crect); fd->wrect = Rect2i(crect.left, crect.top, crect.right - crect.left, crect.bottom - crect.top); } else { - fd->hwnd_owner = 0; + fd->hwnd_owner = nullptr; fd->wrect = Rect2i(CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT); } fd->appid = appname; diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp index a5f1629cf03..0f55cda5d74 100644 --- a/platform/windows/joypad_windows.cpp +++ b/platform/windows/joypad_windows.cpp @@ -122,8 +122,9 @@ bool JoypadWindows::is_xinput_device(const GUID *p_guid) { memcmp(p_guid, &IID_XOneSWirelessGamepad, sizeof(*p_guid)) == 0 || memcmp(p_guid, &IID_XOneSBluetoothGamepad, sizeof(*p_guid)) == 0 || memcmp(p_guid, &IID_XOneEliteWirelessGamepad, sizeof(*p_guid)) == 0 || - memcmp(p_guid, &IID_XOneElite2WirelessGamepad, sizeof(*p_guid)) == 0) + memcmp(p_guid, &IID_XOneElite2WirelessGamepad, sizeof(*p_guid)) == 0) { return true; + } PRAWINPUTDEVICELIST dev_list = nullptr; unsigned int dev_list_count = 0; diff --git a/platform/windows/native_menu_windows.cpp b/platform/windows/native_menu_windows.cpp index fde55918e43..9fa2849e7b9 100644 --- a/platform/windows/native_menu_windows.cpp +++ b/platform/windows/native_menu_windows.cpp @@ -158,7 +158,7 @@ Size2 NativeMenuWindows::get_size(const RID &p_rid) const { int count = GetMenuItemCount(md->menu); for (int i = 0; i < count; i++) { RECT rect; - if (GetMenuItemRect(NULL, md->menu, i, &rect)) { + if (GetMenuItemRect(nullptr, md->menu, i, &rect)) { size.x = MAX(size.x, rect.right - rect.left); size.y += rect.bottom - rect.top; } @@ -992,7 +992,7 @@ void NativeMenuWindows::set_item_submenu(const RID &p_rid, int p_idx, const RID if (p_submenu_rid.is_valid()) { item.hSubMenu = md_sub->menu; } else { - item.hSubMenu = 0; + item.hSubMenu = nullptr; } SetMenuItemInfoW(md->menu, p_idx, true, &item); } @@ -1095,7 +1095,7 @@ void NativeMenuWindows::set_item_icon(const RID &p_rid, int p_idx, const Refbmp = _make_bitmap(item_data->img); } else { item_data->img = Ref(); - item_data->bmp = 0; + item_data->bmp = nullptr; } item.hbmpItem = item_data->bmp; SetMenuItemInfoW(md->menu, p_idx, true, &item); diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index ce4ebb03f2f..bff34432148 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -139,13 +139,13 @@ void RedirectIOToConsole() { if (AttachConsole(ATTACH_PARENT_PROCESS)) { // Restore redirection (Note: if not redirected it's NULL handles not INVALID_HANDLE_VALUE). - if (h_stdin != 0) { + if (h_stdin != nullptr) { SetStdHandle(STD_INPUT_HANDLE, h_stdin); } - if (h_stdout != 0) { + if (h_stdout != nullptr) { SetStdHandle(STD_OUTPUT_HANDLE, h_stdout); } - if (h_stderr != 0) { + if (h_stderr != nullptr) { SetStdHandle(STD_ERROR_HANDLE, h_stderr); } @@ -908,9 +908,9 @@ Dictionary OS_Windows::execute_with_pipe(const String &p_path, const List err_pipe; err_pipe.instantiate(); - err_pipe->open_existing(pipe_err[0], 0, p_blocking); + err_pipe->open_existing(pipe_err[0], nullptr, p_blocking); ret["stdio"] = main_pipe; ret["stderr"] = err_pipe; diff --git a/platform/windows/windows_utils.cpp b/platform/windows/windows_utils.cpp index 30743c6900a..3b9bfb50f76 100644 --- a/platform/windows/windows_utils.cpp +++ b/platform/windows/windows_utils.cpp @@ -67,11 +67,11 @@ Error WindowsUtils::copy_and_rename_pdb(const String &p_dll_path) { { // The custom LoadLibraryExW is used instead of open_dynamic_library // to avoid loading the original PDB into the debugger. - HMODULE library_ptr = LoadLibraryExW((LPCWSTR)(p_dll_path.utf16().get_data()), NULL, LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE); + HMODULE library_ptr = LoadLibraryExW((LPCWSTR)(p_dll_path.utf16().get_data()), nullptr, LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE); ERR_FAIL_NULL_V_MSG(library_ptr, ERR_FILE_CANT_OPEN, vformat("Failed to load library '%s'.", p_dll_path)); - IMAGE_DEBUG_DIRECTORY *dbg_dir = (IMAGE_DEBUG_DIRECTORY *)ImageDirectoryEntryToDataEx(library_ptr, FALSE, IMAGE_DIRECTORY_ENTRY_DEBUG, &dbg_info_size, NULL); + IMAGE_DEBUG_DIRECTORY *dbg_dir = (IMAGE_DEBUG_DIRECTORY *)ImageDirectoryEntryToDataEx(library_ptr, FALSE, IMAGE_DIRECTORY_ENTRY_DEBUG, &dbg_info_size, nullptr); bool has_debug = dbg_dir && dbg_dir->Type == IMAGE_DEBUG_TYPE_CODEVIEW; if (has_debug) { diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 6b5ff23436e..7a2570f400e 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -5069,7 +5069,7 @@ bool TextEdit::multicaret_edit_ignore_caret(int p_caret) const { } bool TextEdit::is_caret_visible(int p_caret) const { - ERR_FAIL_INDEX_V(p_caret, carets.size(), 0); + ERR_FAIL_INDEX_V(p_caret, carets.size(), false); return carets[p_caret].visible; } @@ -5736,7 +5736,7 @@ TextServer::AutowrapMode TextEdit::get_autowrap_mode() const { } bool TextEdit::is_line_wrapped(int p_line) const { - ERR_FAIL_INDEX_V(p_line, text.size(), 0); + ERR_FAIL_INDEX_V(p_line, text.size(), false); if (get_line_wrapping_mode() == LineWrappingMode::LINE_WRAPPING_NONE) { return false; } diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 5e4136f4493..a4677d917db 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -647,13 +647,13 @@ void FontFile::_convert_packed_8bit(Ref &p_source, int p_page, int p_sz) wa[ofs_dst + 1] = r[ofs_src + 3]; } } - Ref img_r = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_r)); + Ref img_r = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_r)); set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 0, img_r); - Ref img_g = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_g)); + Ref img_g = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_g)); set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 1, img_g); - Ref img_b = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_b)); + Ref img_b = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_b)); set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 2, img_b); - Ref img_a = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_a)); + Ref img_a = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_a)); set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 3, img_a); } @@ -738,22 +738,22 @@ void FontFile::_convert_packed_4bit(Ref &p_source, int p_page, int p_sz) } } } - Ref img_r = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_r)); + Ref img_r = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_r)); set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 0, img_r); - Ref img_g = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_g)); + Ref img_g = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_g)); set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 1, img_g); - Ref img_b = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_b)); + Ref img_b = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_b)); set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 2, img_b); - Ref img_a = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_a)); + Ref img_a = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_a)); set_texture_image(0, Vector2i(p_sz, 0), p_page * 4 + 3, img_a); - Ref img_ro = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_ro)); + Ref img_ro = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_ro)); set_texture_image(0, Vector2i(p_sz, 1), p_page * 4 + 0, img_ro); - Ref img_go = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_go)); + Ref img_go = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_go)); set_texture_image(0, Vector2i(p_sz, 1), p_page * 4 + 1, img_go); - Ref img_bo = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_bo)); + Ref img_bo = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_bo)); set_texture_image(0, Vector2i(p_sz, 1), p_page * 4 + 2, img_bo); - Ref img_ao = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_ao)); + Ref img_ao = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_ao)); set_texture_image(0, Vector2i(p_sz, 1), p_page * 4 + 3, img_ao); } @@ -806,10 +806,10 @@ void FontFile::_convert_rgba_4bit(Ref &p_source, int p_page, int p_sz) { } } } - Ref img_g = memnew(Image(w, h, 0, Image::FORMAT_RGBA8, imgdata_g)); + Ref img_g = memnew(Image(w, h, false, Image::FORMAT_RGBA8, imgdata_g)); set_texture_image(0, Vector2i(p_sz, 0), p_page, img_g); - Ref img_o = memnew(Image(w, h, 0, Image::FORMAT_RGBA8, imgdata_o)); + Ref img_o = memnew(Image(w, h, false, Image::FORMAT_RGBA8, imgdata_o)); set_texture_image(0, Vector2i(p_sz, 1), p_page, img_o); } @@ -838,7 +838,7 @@ void FontFile::_convert_mono_8bit(Ref &p_source, int p_page, int p_ch, in wg[ofs_dst + 1] = r[ofs_src + p_ch]; } } - Ref img_g = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_g)); + Ref img_g = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_g)); set_texture_image(0, Vector2i(p_sz, p_ol), p_page, img_g); } @@ -878,10 +878,10 @@ void FontFile::_convert_mono_4bit(Ref &p_source, int p_page, int p_ch, in } } } - Ref img_g = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_g)); + Ref img_g = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_g)); set_texture_image(0, Vector2i(p_sz, 0), p_page, img_g); - Ref img_o = memnew(Image(w, h, 0, Image::FORMAT_LA8, imgdata_o)); + Ref img_o = memnew(Image(w, h, false, Image::FORMAT_LA8, imgdata_o)); set_texture_image(0, Vector2i(p_sz, p_ol), p_page, img_o); } diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp index 42aa43269bc..d5c37c2acca 100644 --- a/servers/audio/audio_stream.cpp +++ b/servers/audio/audio_stream.cpp @@ -281,7 +281,7 @@ double AudioStream::get_bpm() const { } bool AudioStream::has_loop() const { - bool ret = 0; + bool ret = false; GDVIRTUAL_CALL(_has_loop, ret); return ret; } diff --git a/servers/rendering/renderer_canvas_cull.cpp b/servers/rendering/renderer_canvas_cull.cpp index 701b4da8f84..d01976acf22 100644 --- a/servers/rendering/renderer_canvas_cull.cpp +++ b/servers/rendering/renderer_canvas_cull.cpp @@ -612,8 +612,9 @@ void RendererCanvasCull::canvas_item_set_visibility_layer(RID p_item, uint32_t p uint32_t RendererCanvasCull::canvas_item_get_visibility_layer(RID p_item) { Item *canvas_item = canvas_item_owner.get_or_null(p_item); - if (!canvas_item) + if (!canvas_item) { return 0; + } return canvas_item->visibility_layer; } diff --git a/servers/rendering/renderer_rd/environment/gi.cpp b/servers/rendering/renderer_rd/environment/gi.cpp index 12ff28d7b05..235aa9f8280 100644 --- a/servers/rendering/renderer_rd/environment/gi.cpp +++ b/servers/rendering/renderer_rd/environment/gi.cpp @@ -350,7 +350,7 @@ bool GI::voxel_gi_is_using_two_bounces(RID p_voxel_gi) const { bool GI::voxel_gi_is_interior(RID p_voxel_gi) const { VoxelGI *voxel_gi = voxel_gi_owner.get_or_null(p_voxel_gi); - ERR_FAIL_NULL_V(voxel_gi, 0); + ERR_FAIL_NULL_V(voxel_gi, false); return voxel_gi->interior; } diff --git a/servers/rendering/renderer_rd/storage_rd/particles_storage.h b/servers/rendering/renderer_rd/storage_rd/particles_storage.h index 33f44f3045a..744f9eb0eaa 100644 --- a/servers/rendering/renderer_rd/storage_rd/particles_storage.h +++ b/servers/rendering/renderer_rd/storage_rd/particles_storage.h @@ -509,7 +509,7 @@ public: _FORCE_INLINE_ bool particles_has_collision(RID p_particles) { Particles *particles = particles_owner.get_or_null(p_particles); - ERR_FAIL_NULL_V(particles, 0); + ERR_FAIL_NULL_V(particles, false); return particles->has_collision_cache; } diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index 1008d5706e4..eaa8176b79d 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -309,7 +309,7 @@ RID RenderingServer::get_white_texture() { w[i] = 255; } } - Ref white = memnew(Image(4, 4, 0, Image::FORMAT_RGB8, wt)); + Ref white = memnew(Image(4, 4, false, Image::FORMAT_RGB8, wt)); white_texture = texture_2d_create(white); return white_texture; } diff --git a/tests/scene/test_primitives.h b/tests/scene/test_primitives.h index 59f23983e57..7426a9ce290 100644 --- a/tests/scene/test_primitives.h +++ b/tests/scene/test_primitives.h @@ -104,8 +104,9 @@ TEST_CASE("[SceneTree][Primitive][Capsule] Capsule Primitive") { float dist_to_yaxis = 0.f; for (Vector3 point : points) { float new_dist_to_y = point.x * point.x + point.z * point.z; - if (new_dist_to_y > dist_to_yaxis) + if (new_dist_to_y > dist_to_yaxis) { dist_to_yaxis = new_dist_to_y; + } } CHECK(dist_to_yaxis <= radius * radius); @@ -114,10 +115,12 @@ TEST_CASE("[SceneTree][Primitive][Capsule] Capsule Primitive") { float max_y{ 0.f }; float min_y{ 0.f }; for (Vector3 point : points) { - if (point.y > max_y) + if (point.y > max_y) { max_y = point.y; - if (point.y < min_y) + } + if (point.y < min_y) { min_y = point.y; + } } CHECK(max_y - min_y <= height); @@ -196,12 +199,14 @@ TEST_CASE("[SceneTree][Primitive][Box] Box Primitive") { for (const Vector3 &normal : normals) { bool add_normal{ true }; for (const Vector3 &vec : distinct_normals) { - if (vec.is_equal_approx(normal)) + if (vec.is_equal_approx(normal)) { add_normal = false; + } } - if (add_normal) + if (add_normal) { distinct_normals.push_back(normal); + } } CHECK_MESSAGE(distinct_normals.size() == 6, @@ -218,8 +223,9 @@ TEST_CASE("[SceneTree][Primitive][Box] Box Primitive") { break; } } - if (!normal_correct_direction) + if (!normal_correct_direction) { break; + } } CHECK_MESSAGE(normal_correct_direction, diff --git a/tests/test_macros.h b/tests/test_macros.h index d32b26f1115..9cc075b6d34 100644 --- a/tests/test_macros.h +++ b/tests/test_macros.h @@ -474,6 +474,6 @@ public: for (int i = 0; i < string_list.size(); ++i) { \ CHECK(string_list[i] == m_slices[i]); \ } \ - } while (0) + } while (false) #endif // TEST_MACROS_H From 2dcfdde18398a6ffcc408d7ae7aa0f2a463f5837 Mon Sep 17 00:00:00 2001 From: Thaddeus Crews Date: Fri, 21 Jun 2024 11:23:48 -0500 Subject: [PATCH 3/3] clang-tidy commit to `.git-blame-ignore-revs` --- .git-blame-ignore-revs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index df5fd1beed7..f149078d5d5 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -60,3 +60,6 @@ b37fc1014abf7adda70dc30b0822d775b3a4433f # Set clang-format `RemoveSemicolon` rule to `true` 0d350e71086fffce0553811739aae9f6ad66136c + +# Style: Apply clang-tidy fixes (superficial) +bb5f390fb9b466be35a5df7651323d7e66afca31