diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2019-06-27 01:05:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-27 01:05:18 +0200 |
commit | eaaff9da3178fa515a0f051fda932c1dd04d53db (patch) | |
tree | 56173535c376e0324f89baccf4bc14b2580ead23 /core/os | |
parent | d8c96461183f0dc3208c3d624674fa4544212ea5 (diff) | |
parent | 4e5310cc60dc17e5ef09e57115ca8236544679e4 (diff) | |
download | redot-engine-eaaff9da3178fa515a0f051fda932c1dd04d53db.tar.gz |
Merge pull request #29941 from qarmin/redundant_code_and_others
Remove redundant code, possible NULL pointers and others
Diffstat (limited to 'core/os')
-rw-r--r-- | core/os/dir_access.cpp | 2 | ||||
-rw-r--r-- | core/os/file_access.cpp | 6 | ||||
-rw-r--r-- | core/os/input_event.cpp | 8 | ||||
-rw-r--r-- | core/os/os.cpp | 3 |
4 files changed, 11 insertions, 8 deletions
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp index d81c30f33a..1c57bfdf3d 100644 --- a/core/os/dir_access.cpp +++ b/core/os/dir_access.cpp @@ -373,7 +373,7 @@ Error DirAccess::_copy_dir(DirAccess *p_target_da, String p_to, int p_chmod_flag if (current_is_dir()) dirs.push_back(n); else { - String rel_path = n; + const String &rel_path = n; if (!n.is_rel_path()) { list_dir_end(); return ERR_BUG; diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index 913caf6584..b5580b5c6e 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -601,7 +601,8 @@ Vector<uint8_t> FileAccess::get_file_as_array(const String &p_path, Error *r_err if (r_error) { // if error requested, do not throw error return Vector<uint8_t>(); } - ERR_FAIL_COND_V(!f, Vector<uint8_t>()); + ERR_EXPLAIN("Can't open file from path: " + String(p_path)); + ERR_FAIL_V(Vector<uint8_t>()); } Vector<uint8_t> data; data.resize(f->get_len()); @@ -621,7 +622,8 @@ String FileAccess::get_file_as_string(const String &p_path, Error *r_error) { if (r_error) { return String(); } - ERR_FAIL_COND_V(err != OK, String()); + ERR_EXPLAIN("Can't get file as string from path: " + String(p_path)); + ERR_FAIL_V(String()); } String ret; diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp index 9c5066da3d..a40a50cfce 100644 --- a/core/os/input_event.cpp +++ b/core/os/input_event.cpp @@ -314,7 +314,7 @@ bool InputEventKey::action_match(const Ref<InputEvent> &p_event, bool *p_pressed if (p_pressed != NULL) *p_pressed = key->is_pressed(); if (p_strength != NULL) - *p_strength = (*p_pressed) ? 1.0f : 0.0f; + *p_strength = (p_pressed != NULL && *p_pressed) ? 1.0f : 0.0f; } return match; } @@ -483,7 +483,7 @@ bool InputEventMouseButton::action_match(const Ref<InputEvent> &p_event, bool *p if (p_pressed != NULL) *p_pressed = mb->is_pressed(); if (p_strength != NULL) - *p_strength = (*p_pressed) ? 1.0f : 0.0f; + *p_strength = (p_pressed != NULL && *p_pressed) ? 1.0f : 0.0f; } return match; @@ -795,7 +795,7 @@ bool InputEventJoypadButton::action_match(const Ref<InputEvent> &p_event, bool * if (p_pressed != NULL) *p_pressed = jb->is_pressed(); if (p_strength != NULL) - *p_strength = (*p_pressed) ? 1.0f : 0.0f; + *p_strength = (p_pressed != NULL && *p_pressed) ? 1.0f : 0.0f; } return match; @@ -1041,7 +1041,7 @@ bool InputEventAction::action_match(const Ref<InputEvent> &p_event, bool *p_pres if (p_pressed != NULL) *p_pressed = act->pressed; if (p_strength != NULL) - *p_strength = (*p_pressed) ? 1.0f : 0.0f; + *p_strength = (p_pressed != NULL && *p_pressed) ? 1.0f : 0.0f; } return match; } diff --git a/core/os/os.cpp b/core/os/os.cpp index 1a3c9ac5f8..027740c6a9 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -239,7 +239,8 @@ void OS::print_all_resources(String p_to_file) { _OSPRF = FileAccess::open(p_to_file, FileAccess::WRITE, &err); if (err != OK) { _OSPRF = NULL; - ERR_FAIL_COND(err != OK); + ERR_EXPLAIN("Can't print all resources to file: " + String(p_to_file)); + ERR_FAIL(); } } |