Skip to content

Commit bb5f390

Browse files
committed
Style: Apply clang-tidy fixes (superficial)
• `modernize-use-bool-literals`, `modernize-use-nullptr`, and `readability-braces-around-statements`
1 parent 89a3112 commit bb5f390

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+126
-102
lines changed

core/input/input.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ void Input::action_release(const StringName &p_action) {
10341034

10351035
// Create or retrieve existing action.
10361036
ActionState &action_state = action_states[p_action];
1037-
action_state.cache.pressed = 0;
1037+
action_state.cache.pressed = false;
10381038
action_state.cache.strength = 0.0;
10391039
action_state.cache.raw_strength = 0.0;
10401040
// As input may come in part way through a physics tick, the earliest we can react to it is the next physics tick.

core/object/message_queue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class CallQueue {
153153
bool is_flushing() const;
154154
int get_max_buffer_usage() const;
155155

156-
CallQueue(Allocator *p_custom_allocator = 0, uint32_t p_max_pages = 8192, const String &p_error_text = String());
156+
CallQueue(Allocator *p_custom_allocator = nullptr, uint32_t p_max_pages = 8192, const String &p_error_text = String());
157157
virtual ~CallQueue();
158158
};
159159

drivers/gles3/storage/particles_storage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ class ParticlesStorage : public RendererParticlesStorage {
396396

397397
_FORCE_INLINE_ bool particles_has_collision(RID p_particles) {
398398
Particles *particles = particles_owner.get_or_null(p_particles);
399-
ERR_FAIL_NULL_V(particles, 0);
399+
ERR_FAIL_NULL_V(particles, false);
400400

401401
return particles->has_collision_cache;
402402
}

drivers/vulkan/rendering_device_driver_vulkan.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ RDD::BufferID RenderingDeviceDriverVulkan::buffer_create(uint64_t p_size, BitFie
15191519
ERR_FAIL_COND_V_MSG(err, BufferID(), "Can't create buffer of size: " + itos(p_size) + ", error " + itos(err) + ".");
15201520
err = vmaAllocateMemoryForBuffer(allocator, vk_buffer, &alloc_create_info, &allocation, &alloc_info);
15211521
ERR_FAIL_COND_V_MSG(err, BufferID(), "Can't allocate memory for buffer of size: " + itos(p_size) + ", error " + itos(err) + ".");
1522-
err = vmaBindBufferMemory2(allocator, allocation, 0, vk_buffer, NULL);
1522+
err = vmaBindBufferMemory2(allocator, allocation, 0, vk_buffer, nullptr);
15231523
ERR_FAIL_COND_V_MSG(err, BufferID(), "Can't bind memory to buffer of size: " + itos(p_size) + ", error " + itos(err) + ".");
15241524

15251525
// Bookkeep.
@@ -1745,7 +1745,7 @@ RDD::TextureID RenderingDeviceDriverVulkan::texture_create(const TextureFormat &
17451745
ERR_FAIL_COND_V_MSG(err, TextureID(), "vkCreateImage failed with error " + itos(err) + ".");
17461746
err = vmaAllocateMemoryForImage(allocator, vk_image, &alloc_create_info, &allocation, &alloc_info);
17471747
ERR_FAIL_COND_V_MSG(err, TextureID(), "Can't allocate memory for image, error: " + itos(err) + ".");
1748-
err = vmaBindImageMemory2(allocator, allocation, 0, vk_image, NULL);
1748+
err = vmaBindImageMemory2(allocator, allocation, 0, vk_image, nullptr);
17491749
ERR_FAIL_COND_V_MSG(err, TextureID(), "Can't bind memory to image, error: " + itos(err) + ".");
17501750

17511751
// Create view.

drivers/windows/dir_access_windows.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ Error DirAccessWindows::rename(String p_path, String p_new_path) {
282282
uint64_t id = OS::get_singleton()->get_ticks_usec();
283283
while (true) {
284284
tmpfile_utf16 = (path + itos(id++) + ".tmp").utf16();
285-
HANDLE handle = CreateFileW((LPCWSTR)tmpfile_utf16.get_data(), GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
285+
HANDLE handle = CreateFileW((LPCWSTR)tmpfile_utf16.get_data(), GENERIC_WRITE, 0, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
286286
if (handle != INVALID_HANDLE_VALUE) {
287287
CloseHandle(handle);
288288
break;

drivers/windows/file_access_windows.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Error FileAccessWindows::open_internal(const String &p_path, int p_mode_flags) {
193193
uint64_t id = OS::get_singleton()->get_ticks_usec();
194194
while (true) {
195195
tmpfile = path + itos(id++) + ".tmp";
196-
HANDLE handle = CreateFileW((LPCWSTR)tmpfile.utf16().get_data(), GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
196+
HANDLE handle = CreateFileW((LPCWSTR)tmpfile.utf16().get_data(), GENERIC_WRITE, 0, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
197197
if (handle != INVALID_HANDLE_VALUE) {
198198
CloseHandle(handle);
199199
break;

drivers/windows/file_access_windows_pipe.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Error FileAccessWindowsPipe::open_existing(HANDLE p_rfd, HANDLE p_wfd, bool p_bl
4040
_close();
4141

4242
path_src = String();
43-
ERR_FAIL_COND_V_MSG(fd[0] != 0 || fd[1] != 0, ERR_ALREADY_IN_USE, "Pipe is already in use.");
43+
ERR_FAIL_COND_V_MSG(fd[0] != nullptr || fd[1] != nullptr, ERR_ALREADY_IN_USE, "Pipe is already in use.");
4444
fd[0] = p_rfd;
4545
fd[1] = p_wfd;
4646

@@ -58,18 +58,18 @@ Error FileAccessWindowsPipe::open_internal(const String &p_path, int p_mode_flag
5858
_close();
5959

6060
path_src = p_path;
61-
ERR_FAIL_COND_V_MSG(fd[0] != 0 || fd[1] != 0, ERR_ALREADY_IN_USE, "Pipe is already in use.");
61+
ERR_FAIL_COND_V_MSG(fd[0] != nullptr || fd[1] != nullptr, ERR_ALREADY_IN_USE, "Pipe is already in use.");
6262

6363
path = String("\\\\.\\pipe\\LOCAL\\") + p_path.replace("pipe://", "").replace("/", "_");
6464

65-
HANDLE h = CreateFileW((LPCWSTR)path.utf16().get_data(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
65+
HANDLE h = CreateFileW((LPCWSTR)path.utf16().get_data(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
6666
if (h == INVALID_HANDLE_VALUE) {
6767
h = CreateNamedPipeW((LPCWSTR)path.utf16().get_data(), PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT, 1, 4096, 4096, 0, nullptr);
6868
if (h == INVALID_HANDLE_VALUE) {
6969
last_error = ERR_FILE_CANT_OPEN;
7070
return last_error;
7171
}
72-
ConnectNamedPipe(h, NULL);
72+
ConnectNamedPipe(h, nullptr);
7373
}
7474
fd[0] = h;
7575
fd[1] = h;
@@ -79,19 +79,19 @@ Error FileAccessWindowsPipe::open_internal(const String &p_path, int p_mode_flag
7979
}
8080

8181
void FileAccessWindowsPipe::_close() {
82-
if (fd[0] == 0) {
82+
if (fd[0] == nullptr) {
8383
return;
8484
}
8585
if (fd[1] != fd[0]) {
8686
CloseHandle(fd[1]);
8787
}
8888
CloseHandle(fd[0]);
89-
fd[0] = 0;
90-
fd[1] = 0;
89+
fd[0] = nullptr;
90+
fd[1] = nullptr;
9191
}
9292

9393
bool FileAccessWindowsPipe::is_open() const {
94-
return (fd[0] != 0 || fd[1] != 0);
94+
return (fd[0] != nullptr || fd[1] != nullptr);
9595
}
9696

9797
String FileAccessWindowsPipe::get_path() const {
@@ -103,7 +103,7 @@ String FileAccessWindowsPipe::get_path_absolute() const {
103103
}
104104

105105
uint64_t FileAccessWindowsPipe::get_buffer(uint8_t *p_dst, uint64_t p_length) const {
106-
ERR_FAIL_COND_V_MSG(fd[0] == 0, -1, "Pipe must be opened before use.");
106+
ERR_FAIL_COND_V_MSG(fd[0] == nullptr, -1, "Pipe must be opened before use.");
107107
ERR_FAIL_COND_V(!p_dst && p_length > 0, -1);
108108

109109
DWORD read = 0;
@@ -120,7 +120,7 @@ Error FileAccessWindowsPipe::get_error() const {
120120
}
121121

122122
void FileAccessWindowsPipe::store_buffer(const uint8_t *p_src, uint64_t p_length) {
123-
ERR_FAIL_COND_MSG(fd[1] == 0, "Pipe must be opened before use.");
123+
ERR_FAIL_COND_MSG(fd[1] == nullptr, "Pipe must be opened before use.");
124124
ERR_FAIL_COND(!p_src && p_length > 0);
125125

126126
DWORD read = -1;

drivers/windows/file_access_windows_pipe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#define WIN32_LEAN_AND_MEAN
4040
#include <windows.h>
4141
class FileAccessWindowsPipe : public FileAccess {
42-
HANDLE fd[2] = { 0, 0 };
42+
HANDLE fd[2] = { nullptr, nullptr };
4343

4444
mutable Error last_error = OK;
4545

editor/animation_track_editor.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6337,8 +6337,9 @@ bool AnimationTrackEditor::_is_track_compatible(int p_target_track_idx, Variant:
63376337
}
63386338

63396339
if (path_valid) {
6340-
if (is_source_bezier)
6340+
if (is_source_bezier) {
63416341
p_source_value_type = Variant::FLOAT;
6342+
}
63426343
return property_type == p_source_value_type;
63436344
} else {
63446345
if (animation->track_get_key_count(p_target_track_idx) > 0) {

editor/plugins/bone_map_editor_plugin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ void BoneMapper::auto_mapping_process(Ref<BoneMap> &p_bone_map) {
859859

860860
// 4-1. Guess Finger
861861
int tips_index = -1;
862-
bool thumb_tips_size = 0;
862+
bool thumb_tips_size = false;
863863
bool named_finger_is_found = false;
864864
LocalVector<String> fingers;
865865
fingers.push_back("thumb|pollex");
@@ -994,7 +994,7 @@ void BoneMapper::auto_mapping_process(Ref<BoneMap> &p_bone_map) {
994994
}
995995

996996
tips_index = -1;
997-
thumb_tips_size = 0;
997+
thumb_tips_size = false;
998998
named_finger_is_found = false;
999999
if (right_hand_or_palm != -1) {
10001000
LocalVector<LocalVector<String>> right_fingers_map;

0 commit comments

Comments
 (0)