Selaa lähdekoodia

Merge pull request #30126 from qarmin/remove_unnecessary_code

Remove unnecessary code and add some error explanations
Rémi Verschelde 6 vuotta sitten
vanhempi
commit
b0ce9401ff
48 muutettua tiedostoa jossa 149 lisäystä ja 187 poistoa
  1. 12 6
      core/array.cpp
  2. 7 5
      core/bind/core_bind.cpp
  3. 2 2
      core/class_db.cpp
  4. 1 2
      core/color.cpp
  5. 1 1
      core/command_queue_mt.h
  6. 4 2
      core/engine.cpp
  7. 8 3
      core/hash_map.h
  8. 5 2
      core/image.cpp
  9. 32 32
      core/io/file_access_buffered.cpp
  10. 4 1
      core/io/file_access_buffered_fa.h
  11. 0 2
      core/io/http_client.cpp
  12. 0 2
      core/io/json.cpp
  13. 4 3
      core/io/pck_packer.cpp
  14. 3 2
      core/io/resource_importer.cpp
  15. 0 4
      core/io/resource_loader.cpp
  16. 1 5
      core/math/bsp_tree.cpp
  17. 30 30
      core/math/camera_matrix.cpp
  18. 0 2
      core/math/math_funcs.cpp
  19. 1 1
      core/math/random_number_generator.h
  20. 2 4
      core/object.cpp
  21. 0 4
      core/os/dir_access.cpp
  22. 1 1
      core/os/memory.h
  23. 0 2
      core/project_settings.cpp
  24. 0 6
      core/ustring.cpp
  25. 0 20
      core/variant.cpp
  26. 2 1
      core/variant_op.cpp
  27. 0 14
      core/variant_parser.cpp
  28. 4 4
      drivers/unix/net_socket_posix.cpp
  29. 2 2
      editor/animation_bezier_editor.cpp
  30. 1 1
      editor/animation_track_editor_plugins.cpp
  31. 2 1
      editor/create_dialog.cpp
  32. 1 1
      editor/editor_plugin.cpp
  33. 1 1
      editor/groups_editor.cpp
  34. 1 1
      editor/plugins/collision_shape_2d_editor_plugin.h
  35. 1 1
      editor/plugins/curve_editor_plugin.cpp
  36. 1 1
      editor/plugins/path_2d_editor_plugin.h
  37. 1 1
      editor/plugins/script_editor_plugin.cpp
  38. 6 1
      editor/plugins/texture_region_editor_plugin.cpp
  39. 2 2
      editor/project_settings_editor.cpp
  40. 0 1
      editor/scene_tree_dock.cpp
  41. 2 2
      editor/spatial_editor_gizmos.cpp
  42. 1 1
      modules/gdscript/gdscript.cpp
  43. 0 2
      modules/gdscript/gdscript_compiler.cpp
  44. 1 1
      modules/mono/csharp_script.cpp
  45. 0 1
      scene/2d/navigation_2d.cpp
  46. 1 1
      scene/3d/audio_stream_player_3d.h
  47. 0 1
      scene/3d/navigation.cpp
  48. 1 1
      scene/gui/option_button.cpp

+ 12 - 6
core/array.cpp

@@ -133,12 +133,18 @@ void Array::erase(const Variant &p_value) {
 }
 
 Variant Array::front() const {
-	ERR_FAIL_COND_V(_p->array.size() == 0, Variant());
+	if (_p->array.size() == 0) {
+		ERR_EXPLAIN("Can't take value from empty array");
+		ERR_FAIL_V(Variant());
+	}
 	return operator[](0);
 }
 
 Variant Array::back() const {
-	ERR_FAIL_COND_V(_p->array.size() == 0, Variant());
+	if (_p->array.size() == 0) {
+		ERR_EXPLAIN("Can't take value from empty array");
+		ERR_FAIL_V(Variant());
+	}
 	return operator[](_p->array.size() - 1);
 }
 
@@ -165,8 +171,8 @@ int Array::rfind(const Variant &p_value, int p_from) const {
 
 		if (_p->array[i] == p_value) {
 			return i;
-		};
-	};
+		}
+	}
 
 	return -1;
 }
@@ -186,8 +192,8 @@ int Array::count(const Variant &p_value) const {
 
 		if (_p->array[i] == p_value) {
 			amount++;
-		};
-	};
+		}
+	}
 
 	return amount;
 }

+ 7 - 5
core/bind/core_bind.cpp

@@ -149,8 +149,10 @@ _ResourceLoader::_ResourceLoader() {
 }
 
 Error _ResourceSaver::save(const String &p_path, const RES &p_resource, SaverFlags p_flags) {
-
-	ERR_FAIL_COND_V(p_resource.is_null(), ERR_INVALID_PARAMETER);
+	if (p_resource.is_null()) {
+		ERR_EXPLAIN("Can't save empty resource to path: " + String(p_path))
+		ERR_FAIL_V(ERR_INVALID_PARAMETER);
+	}
 	return ResourceSaver::save(p_path, p_resource, p_flags);
 }
 
@@ -246,11 +248,11 @@ PoolStringArray _OS::get_connected_midi_inputs() {
 }
 
 void _OS::open_midi_inputs() {
-	return OS::get_singleton()->open_midi_inputs();
+	OS::get_singleton()->open_midi_inputs();
 }
 
 void _OS::close_midi_inputs() {
-	return OS::get_singleton()->close_midi_inputs();
+	OS::get_singleton()->close_midi_inputs();
 }
 
 void _OS::set_video_mode(const Size2 &p_size, bool p_fullscreen, bool p_resizeable, int p_screen) {
@@ -2266,7 +2268,7 @@ bool _Directory::current_is_dir() const {
 void _Directory::list_dir_end() {
 
 	ERR_FAIL_COND(!d);
-	return d->list_dir_end();
+	d->list_dir_end();
 }
 
 int _Directory::get_drive_count() {

+ 2 - 2
core/class_db.cpp

@@ -925,7 +925,7 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons
 #ifdef DEBUG_METHODS_ENABLED
 		if (!mb_set) {
 			ERR_EXPLAIN("Invalid Setter: " + p_class + "::" + p_setter + " for property: " + p_pinfo.name);
-			ERR_FAIL_COND(!mb_set);
+			ERR_FAIL();
 		} else {
 			int exp_args = 1 + (p_index >= 0 ? 1 : 0);
 			if (mb_set->get_argument_count() != exp_args) {
@@ -944,7 +944,7 @@ void ClassDB::add_property(StringName p_class, const PropertyInfo &p_pinfo, cons
 
 		if (!mb_get) {
 			ERR_EXPLAIN("Invalid Getter: " + p_class + "::" + p_getter + " for property: " + p_pinfo.name);
-			ERR_FAIL_COND(!mb_get);
+			ERR_FAIL();
 		} else {
 
 			int exp_args = 0 + (p_index >= 0 ? 1 : 0);

+ 1 - 2
core/color.cpp

@@ -388,9 +388,8 @@ bool Color::html_is_valid(const String &p_color) {
 		return false;
 	}
 
-	int a = 255;
 	if (alpha) {
-		a = _parse_col(color, 0);
+		int a = _parse_col(color, 0);
 		if (a < 0) {
 			return false;
 		}

+ 1 - 1
core/command_queue_mt.h

@@ -346,7 +346,7 @@ class CommandQueueMT {
 				}
 				return NULL;
 			}
-		} else if (write_ptr >= dealloc_ptr) {
+		} else {
 			// ahead of dealloc_ptr, check that there is room
 
 			if ((COMMAND_MEM_SIZE - write_ptr) < alloc_size + sizeof(uint32_t)) {

+ 4 - 2
core/engine.cpp

@@ -197,8 +197,10 @@ void Engine::add_singleton(const Singleton &p_singleton) {
 Object *Engine::get_singleton_object(const String &p_name) const {
 
 	const Map<StringName, Object *>::Element *E = singleton_ptrs.find(p_name);
-	ERR_EXPLAIN("Failed to retrieve non-existent singleton '" + p_name + "'");
-	ERR_FAIL_COND_V(!E, NULL);
+	if (!E) {
+		ERR_EXPLAIN("Failed to retrieve non-existent singleton '" + p_name + "'");
+		ERR_FAIL_V(NULL);
+	}
 	return E->get();
 };
 

+ 8 - 3
core/hash_map.h

@@ -208,7 +208,10 @@ private:
 
 		/* if element doesn't exist, create it */
 		Element *e = memnew(Element);
-		ERR_FAIL_COND_V(!e, NULL); /* out of memory */
+		if (!e) {
+			ERR_EXPLAIN("Out of memory");
+			ERR_FAIL_V(NULL);
+		}
 		uint32_t hash = Hasher::hash(p_key);
 		uint32_t index = hash & ((1 << hash_table_power) - 1);
 		e->next = hash_table[index];
@@ -495,8 +498,10 @@ public:
 		} else { /* get the next key */
 
 			const Element *e = get_element(*p_key);
-			ERR_FAIL_COND_V(!e, NULL); /* invalid key supplied */
-
+			if (!e) {
+				ERR_EXPLAIN("Invalid key supplied")
+				ERR_FAIL_V(NULL);
+			}
 			if (e->next) {
 				/* if there is a "next" in the list, return that */
 				return &e->next->pair.key;

+ 5 - 2
core/image.cpp

@@ -1464,7 +1464,10 @@ Error Image::generate_mipmaps(bool p_renormalize) {
 		ERR_FAIL_V(ERR_UNAVAILABLE);
 	}
 
-	ERR_FAIL_COND_V(width == 0 || height == 0, ERR_UNCONFIGURED);
+	if (width == 0 || height == 0) {
+		ERR_EXPLAIN("Cannot generate mipmaps with width or height equal to 0.");
+		ERR_FAIL_V(ERR_UNCONFIGURED);
+	}
 
 	int mmcount;
 
@@ -2532,7 +2535,7 @@ Color Image::get_pixel(int p_x, int p_y) const {
 }
 
 void Image::set_pixelv(const Point2 &p_dst, const Color &p_color) {
-	return set_pixel(p_dst.x, p_dst.y, p_color);
+	set_pixel(p_dst.x, p_dst.y, p_color);
 }
 
 void Image::set_pixel(int p_x, int p_y, const Color &p_color) {

+ 32 - 32
core/io/file_access_buffered.cpp

@@ -35,79 +35,79 @@
 Error FileAccessBuffered::set_error(Error p_error) const {
 
 	return (last_error = p_error);
-};
+}
 
 void FileAccessBuffered::set_cache_size(int p_size) {
 
 	cache_size = p_size;
-};
+}
 
 int FileAccessBuffered::get_cache_size() {
 
 	return cache_size;
-};
+}
 
 int FileAccessBuffered::cache_data_left() const {
 
 	if (file.offset >= file.size) {
 		return 0;
-	};
+	}
 
 	if (cache.offset == -1 || file.offset < cache.offset || file.offset >= cache.offset + cache.buffer.size()) {
 
 		return read_data_block(file.offset, cache_size);
+	}
 
-	} else {
-
-		return cache.buffer.size() - (file.offset - cache.offset);
-	};
-
-	return 0;
-};
+	return cache.buffer.size() - (file.offset - cache.offset);
+}
 
 void FileAccessBuffered::seek(size_t p_position) {
 
 	file.offset = p_position;
-};
+}
 
 void FileAccessBuffered::seek_end(int64_t p_position) {
 
 	file.offset = file.size + p_position;
-};
+}
 
 size_t FileAccessBuffered::get_position() const {
 
 	return file.offset;
-};
+}
 
 size_t FileAccessBuffered::get_len() const {
 
 	return file.size;
-};
+}
 
 bool FileAccessBuffered::eof_reached() const {
 
 	return file.offset > file.size;
-};
+}
 
 uint8_t FileAccessBuffered::get_8() const {
-
-	ERR_FAIL_COND_V(!file.open, 0);
+	if (!file.open) {
+		ERR_EXPLAIN("Can't get data, when file is not opened.");
+		ERR_FAIL_V(0);
+	}
 
 	uint8_t byte = 0;
 	if (cache_data_left() >= 1) {
 
 		byte = cache.buffer[file.offset - cache.offset];
-	};
+	}
 
 	++file.offset;
 
 	return byte;
-};
+}
 
 int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const {
-
-	ERR_FAIL_COND_V(!file.open, -1);
+	if (!file.open) {
+		ERR_EXPLAIN("Can't get buffer, when file is not opened.");
+		ERR_FAIL_V(-1);
+	}
 
 	if (p_length > cache_size) {
 
@@ -124,16 +124,16 @@ int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const {
 			p_length -= size;
 			file.offset += size;
 			total_read += size;
-		};
+		}
 
 		int err = read_data_block(file.offset, p_length, p_dest);
 		if (err >= 0) {
 			total_read += err;
 			file.offset += err;
-		};
+		}
 
 		return total_read;
-	};
+	}
 
 	int to_read = p_length;
 	int total_read = 0;
@@ -143,10 +143,10 @@ int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const {
 		if (left == 0) {
 			file.offset += to_read;
 			return total_read;
-		};
+		}
 		if (left < 0) {
 			return left;
-		};
+		}
 
 		int r = MIN(left, to_read);
 		//PoolVector<uint8_t>::Read read = cache.buffer.read();
@@ -156,25 +156,25 @@ int FileAccessBuffered::get_buffer(uint8_t *p_dest, int p_length) const {
 		file.offset += r;
 		total_read += r;
 		to_read -= r;
-	};
+	}
 
 	return p_length;
-};
+}
 
 bool FileAccessBuffered::is_open() const {
 
 	return file.open;
-};
+}
 
 Error FileAccessBuffered::get_error() const {
 
 	return last_error;
-};
+}
 
 FileAccessBuffered::FileAccessBuffered() {
 
 	cache_size = DEFAULT_CACHE_SIZE;
-};
+}
 
 FileAccessBuffered::~FileAccessBuffered() {
 }

+ 4 - 1
core/io/file_access_buffered_fa.h

@@ -40,7 +40,10 @@ class FileAccessBufferedFA : public FileAccessBuffered {
 
 	int read_data_block(int p_offset, int p_size, uint8_t *p_dest = 0) const {
 
-		ERR_FAIL_COND_V(!f.is_open(), -1);
+		if (!f.is_open()) {
+			ERR_EXPLAIN("Can't read data block, when file is not opened.");
+			ERR_FAIL_V(-1);
+		}
 
 		((T *)&f)->seek(p_offset);
 

+ 0 - 2
core/io/http_client.cpp

@@ -482,8 +482,6 @@ Error HTTPClient::poll() {
 					return OK;
 				}
 			}
-			// Wait for response
-			return OK;
 		} break;
 		case STATUS_DISCONNECTED: {
 			return ERR_UNCONFIGURED;

+ 0 - 2
core/io/json.cpp

@@ -347,8 +347,6 @@ Error JSON::_parse_value(Variant &value, Token &token, const CharType *p_str, in
 		r_err_str = "Expected value, got " + String(tk_name[token.type]) + ".";
 		return ERR_PARSE_ERROR;
 	}
-
-	return ERR_PARSE_ERROR;
 }
 
 Error JSON::_parse_array(Array &array, const CharType *p_str, int &index, int p_len, int &line, String &r_err_str) {

+ 4 - 3
core/io/pck_packer.cpp

@@ -63,10 +63,11 @@ void PCKPacker::_bind_methods() {
 Error PCKPacker::pck_start(const String &p_file, int p_alignment) {
 
 	file = FileAccess::open(p_file, FileAccess::WRITE);
-	if (file == NULL) {
 
-		return ERR_CANT_CREATE;
-	};
+	if (!file) {
+		ERR_EXPLAIN("Can't open file to write: " + String(p_file));
+		ERR_FAIL_V(ERR_CANT_CREATE);
+	}
 
 	alignment = p_alignment;
 

+ 3 - 2
core/io/resource_importer.cpp

@@ -161,7 +161,8 @@ void ResourceFormatImporter::get_recognized_extensions(List<String> *p_extension
 void ResourceFormatImporter::get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const {
 
 	if (p_type == "") {
-		return get_recognized_extensions(p_extensions);
+		get_recognized_extensions(p_extensions);
+		return;
 	}
 
 	Set<String> found;
@@ -347,7 +348,7 @@ void ResourceFormatImporter::get_dependencies(const String &p_path, List<String>
 		return;
 	}
 
-	return ResourceLoader::get_dependencies(pat.path, p_dependencies, p_add_types);
+	ResourceLoader::get_dependencies(pat.path, p_dependencies, p_add_types);
 }
 
 Ref<ResourceImporter> ResourceFormatImporter::get_importer_by_name(const String &p_name) const {

+ 0 - 4
core/io/resource_loader.cpp

@@ -207,8 +207,6 @@ RES ResourceFormatLoader::load(const String &p_path, const String &p_original_pa
 
 		ERR_FAIL_COND_V(err != OK, RES());
 	}
-
-	return RES();
 }
 
 void ResourceFormatLoader::get_dependencies(const String &p_path, List<String> *p_dependencies, bool p_add_types) {
@@ -283,7 +281,6 @@ RES ResourceLoader::_load(const String &p_path, const String &p_original_path, c
 		ERR_EXPLAIN("No loader found for resource: " + p_path);
 	}
 	ERR_FAIL_V(RES());
-	return RES();
 }
 
 bool ResourceLoader::_add_to_loading_map(const String &p_path) {
@@ -543,7 +540,6 @@ Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String &p_
 		ERR_EXPLAIN("No loader found for resource: " + path);
 	}
 	ERR_FAIL_V(Ref<ResourceInteractiveLoader>());
-	return Ref<ResourceInteractiveLoader>();
 }
 
 void ResourceLoader::add_resource_format_loader(Ref<ResourceFormatLoader> p_format_loader, bool p_at_front) {

+ 1 - 5
core/math/bsp_tree.cpp

@@ -142,7 +142,7 @@ int BSP_Tree::_get_points_inside(int p_node, const Vector3 *p_points, int *p_ind
 		}
 
 		return _get_points_inside(node->over, p_points, p_indices, p_center, p_half_extents, p_indices_count);
-	} else if (dist_min <= 0) { //all points behind plane
+	} else { //all points behind plane
 
 		if (node->under == UNDER_LEAF) {
 
@@ -150,8 +150,6 @@ int BSP_Tree::_get_points_inside(int p_node, const Vector3 *p_points, int *p_ind
 		}
 		return _get_points_inside(node->under, p_points, p_indices, p_center, p_half_extents, p_indices_count);
 	}
-
-	return 0;
 }
 
 int BSP_Tree::get_points_inside(const Vector3 *p_points, int p_point_count) const {
@@ -271,8 +269,6 @@ bool BSP_Tree::point_is_inside(const Vector3 &p_point) const {
 		ERR_FAIL_COND_V(idx < MAX_NODES && idx >= node_count, false);
 #endif
 	}
-
-	return false;
 }
 
 static int _bsp_find_best_half_plane(const Face3 *p_faces, const Vector<int> &p_indices, real_t p_tolerance) {

+ 30 - 30
core/math/camera_matrix.cpp

@@ -507,21 +507,21 @@ void CameraMatrix::set_light_bias() {
 
 	real_t *m = &matrix[0][0];
 
-	m[0] = 0.5,
-	m[1] = 0.0,
-	m[2] = 0.0,
-	m[3] = 0.0,
-	m[4] = 0.0,
-	m[5] = 0.5,
-	m[6] = 0.0,
-	m[7] = 0.0,
-	m[8] = 0.0,
-	m[9] = 0.0,
-	m[10] = 0.5,
-	m[11] = 0.0,
-	m[12] = 0.5,
-	m[13] = 0.5,
-	m[14] = 0.5,
+	m[0] = 0.5;
+	m[1] = 0.0;
+	m[2] = 0.0;
+	m[3] = 0.0;
+	m[4] = 0.0;
+	m[5] = 0.5;
+	m[6] = 0.0;
+	m[7] = 0.0;
+	m[8] = 0.0;
+	m[9] = 0.0;
+	m[10] = 0.5;
+	m[11] = 0.0;
+	m[12] = 0.5;
+	m[13] = 0.5;
+	m[14] = 0.5;
 	m[15] = 1.0;
 }
 
@@ -529,21 +529,21 @@ void CameraMatrix::set_light_atlas_rect(const Rect2 &p_rect) {
 
 	real_t *m = &matrix[0][0];
 
-	m[0] = p_rect.size.width,
-	m[1] = 0.0,
-	m[2] = 0.0,
-	m[3] = 0.0,
-	m[4] = 0.0,
-	m[5] = p_rect.size.height,
-	m[6] = 0.0,
-	m[7] = 0.0,
-	m[8] = 0.0,
-	m[9] = 0.0,
-	m[10] = 1.0,
-	m[11] = 0.0,
-	m[12] = p_rect.position.x,
-	m[13] = p_rect.position.y,
-	m[14] = 0.0,
+	m[0] = p_rect.size.width;
+	m[1] = 0.0;
+	m[2] = 0.0;
+	m[3] = 0.0;
+	m[4] = 0.0;
+	m[5] = p_rect.size.height;
+	m[6] = 0.0;
+	m[7] = 0.0;
+	m[8] = 0.0;
+	m[9] = 0.0;
+	m[10] = 1.0;
+	m[11] = 0.0;
+	m[12] = p_rect.position.x;
+	m[13] = p_rect.position.y;
+	m[14] = 0.0;
 	m[15] = 1.0;
 }
 

+ 0 - 2
core/math/math_funcs.cpp

@@ -161,8 +161,6 @@ uint32_t Math::larger_prime(uint32_t p_val) {
 			return primes[idx];
 		idx++;
 	}
-
-	return 0;
 }
 
 double Math::random(double from, double to) {

+ 1 - 1
core/math/random_number_generator.h

@@ -47,7 +47,7 @@ public:
 
 	_FORCE_INLINE_ uint64_t get_seed() { return randbase.get_seed(); }
 
-	_FORCE_INLINE_ void randomize() { return randbase.randomize(); }
+	_FORCE_INLINE_ void randomize() { randbase.randomize(); }
 
 	_FORCE_INLINE_ uint32_t randi() { return randbase.rand(); }
 

+ 2 - 4
core/object.cpp

@@ -742,13 +742,11 @@ void Object::call_multilevel(const StringName &p_method, const Variant **p_args,
 		if (Object::cast_to<Reference>(this)) {
 			ERR_EXPLAIN("Can't 'free' a reference.");
 			ERR_FAIL();
-			return;
 		}
 
 		if (_lock_index.get() > 1) {
 			ERR_EXPLAIN("Object is locked and can't be freed.");
 			ERR_FAIL();
-			return;
 		}
 #endif
 
@@ -1467,7 +1465,7 @@ Error Object::connect(const StringName &p_signal, Object *p_to_object, const Str
 
 		if (!signal_is_valid) {
 			ERR_EXPLAIN("In Object of type '" + String(get_class()) + "': Attempt to connect nonexistent signal '" + p_signal + "' to method '" + p_to_object->get_class() + "." + p_to_method + "'");
-			ERR_FAIL_COND_V(!signal_is_valid, ERR_INVALID_PARAMETER);
+			ERR_FAIL_V(ERR_INVALID_PARAMETER);
 		}
 		signal_map[p_signal] = Signal();
 		s = &signal_map[p_signal];
@@ -1517,7 +1515,7 @@ bool Object::is_connected(const StringName &p_signal, Object *p_to_object, const
 			return false;
 
 		ERR_EXPLAIN("Nonexistent signal: " + p_signal);
-		ERR_FAIL_COND_V(!s, false);
+		ERR_FAIL_V(false);
 	}
 
 	Signal::Target target(p_to_object->get_instance_id(), p_to_method);

+ 0 - 4
core/os/dir_access.cpp

@@ -43,8 +43,6 @@ String DirAccess::_get_root_path() const {
 		case ACCESS_USERDATA: return OS::get_singleton()->get_user_data_dir();
 		default: return "";
 	}
-
-	return "";
 }
 String DirAccess::_get_root_string() const {
 
@@ -54,8 +52,6 @@ String DirAccess::_get_root_string() const {
 		case ACCESS_USERDATA: return "user://";
 		default: return "";
 	}
-
-	return "";
 }
 
 int DirAccess::get_current_drive() {

+ 1 - 1
core/os/memory.h

@@ -66,7 +66,7 @@ public:
 class DefaultAllocator {
 public:
 	_FORCE_INLINE_ static void *alloc(size_t p_memory) { return Memory::alloc_static(p_memory, false); }
-	_FORCE_INLINE_ static void free(void *p_ptr) { return Memory::free_static(p_ptr, false); }
+	_FORCE_INLINE_ static void free(void *p_ptr) { Memory::free_static(p_ptr, false); }
 };
 
 void *operator new(size_t p_size, const char *p_description); ///< operator new that takes a description and uses MemoryStaticPool

+ 0 - 2
core/project_settings.cpp

@@ -863,8 +863,6 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust
 		ERR_EXPLAIN("Unknown config file format: " + p_path);
 		ERR_FAIL_V(ERR_FILE_UNRECOGNIZED);
 	}
-
-	return OK;
 }
 
 Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default, bool p_restart_if_changed) {

+ 0 - 6
core/ustring.cpp

@@ -481,8 +481,6 @@ signed char String::nocasecmp_to(const String &p_str) const {
 		this_str++;
 		that_str++;
 	}
-
-	return 0; //should never reach anyway
 }
 
 signed char String::casecmp_to(const String &p_str) const {
@@ -513,8 +511,6 @@ signed char String::casecmp_to(const String &p_str) const {
 		this_str++;
 		that_str++;
 	}
-
-	return 0; //should never reach anyway
 }
 
 signed char String::naturalnocasecmp_to(const String &p_str) const {
@@ -731,8 +727,6 @@ String String::get_slicec(CharType p_splitter, int p_slice) const {
 
 		i++;
 	}
-
-	return String(); //no find!
 }
 
 Vector<String> String::split_spaces() const {

+ 0 - 20
core/variant.cpp

@@ -1171,8 +1171,6 @@ Variant::operator signed int() const {
 			return 0;
 		}
 	}
-
-	return 0;
 }
 Variant::operator unsigned int() const {
 
@@ -1188,8 +1186,6 @@ Variant::operator unsigned int() const {
 			return 0;
 		}
 	}
-
-	return 0;
 }
 
 Variant::operator int64_t() const {
@@ -1206,8 +1202,6 @@ Variant::operator int64_t() const {
 			return 0;
 		}
 	}
-
-	return 0;
 }
 
 /*
@@ -1244,8 +1238,6 @@ Variant::operator uint64_t() const {
 			return 0;
 		}
 	}
-
-	return 0;
 }
 
 #ifdef NEED_LONG_INT
@@ -1300,8 +1292,6 @@ Variant::operator signed short() const {
 			return 0;
 		}
 	}
-
-	return 0;
 }
 Variant::operator unsigned short() const {
 
@@ -1317,8 +1307,6 @@ Variant::operator unsigned short() const {
 			return 0;
 		}
 	}
-
-	return 0;
 }
 Variant::operator signed char() const {
 
@@ -1334,8 +1322,6 @@ Variant::operator signed char() const {
 			return 0;
 		}
 	}
-
-	return 0;
 }
 Variant::operator unsigned char() const {
 
@@ -1351,8 +1337,6 @@ Variant::operator unsigned char() const {
 			return 0;
 		}
 	}
-
-	return 0;
 }
 
 Variant::operator CharType() const {
@@ -1374,8 +1358,6 @@ Variant::operator float() const {
 			return 0;
 		}
 	}
-
-	return 0;
 }
 Variant::operator double() const {
 
@@ -1391,8 +1373,6 @@ Variant::operator double() const {
 			return 0;
 		}
 	}
-
-	return true;
 }
 
 Variant::operator StringName() const {

+ 2 - 1
core/variant_op.cpp

@@ -2183,7 +2183,8 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
 					return;
 				}
 
-				return obj->set(p_index, p_value, r_valid);
+				obj->set(p_index, p_value, r_valid);
+				return;
 			}
 		} break;
 		case DICTIONARY: {

+ 0 - 14
core/variant_parser.cpp

@@ -436,8 +436,6 @@ Error VariantParser::_parse_enginecfg(Stream *p_stream, Vector<String> &strings,
 			line++;
 		}
 	}
-
-	return OK;
 }
 
 template <class T>
@@ -799,8 +797,6 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
 				}
 			}
 
-			return OK;
-
 		} else if (id == "Resource" || id == "SubResource" || id == "ExtResource") {
 
 			get_token(p_stream, token, line, r_err_str);
@@ -864,8 +860,6 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
 					return ERR_PARSE_ERROR;
 				}
 			}
-
-			return OK;
 #ifndef DISABLE_DEPRECATED
 		} else if (id == "InputEvent") {
 
@@ -1256,8 +1250,6 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
 		r_err_str = "Expected value, got " + String(tk_name[token.type]) + ".";
 		return ERR_PARSE_ERROR;
 	}
-
-	return ERR_PARSE_ERROR;
 }
 
 Error VariantParser::_parse_array(Array &array, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser) {
@@ -1301,8 +1293,6 @@ Error VariantParser::_parse_array(Array &array, Stream *p_stream, int &line, Str
 		array.push_back(v);
 		need_comma = true;
 	}
-
-	return OK;
 }
 
 Error VariantParser::_parse_dictionary(Dictionary &object, Stream *p_stream, int &line, String &r_err_str, ResourceParser *p_res_parser) {
@@ -1372,8 +1362,6 @@ Error VariantParser::_parse_dictionary(Dictionary &object, Stream *p_stream, int
 			at_key = true;
 		}
 	}
-
-	return OK;
 }
 
 Error VariantParser::_parse_tag(Token &token, Stream *p_stream, int &line, String &r_err_str, Tag &r_tag, ResourceParser *p_res_parser, bool p_simple_tag) {
@@ -1557,8 +1545,6 @@ Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r
 			line++;
 		}
 	}
-
-	return OK;
 }
 
 Error VariantParser::parse(Stream *p_stream, Variant &r_ret, String &r_err_str, int &r_err_line, ResourceParser *p_res_parser) {

+ 4 - 4
drivers/unix/net_socket_posix.cpp

@@ -684,10 +684,10 @@ Ref<NetSocket> NetSocketPosix::accept(IP_Address &r_ip, uint16_t &r_port) {
 	return Ref<NetSocket>(ns);
 }
 
-Error NetSocketPosix::join_multicast_group(const IP_Address &p_ip, String p_if_name) {
-	return _change_multicast_group(p_ip, p_if_name, true);
+Error NetSocketPosix::join_multicast_group(const IP_Address &p_multi_address, String p_if_name) {
+	return _change_multicast_group(p_multi_address, p_if_name, true);
 }
 
-Error NetSocketPosix::leave_multicast_group(const IP_Address &p_ip, String p_if_name) {
-	return _change_multicast_group(p_ip, p_if_name, false);
+Error NetSocketPosix::leave_multicast_group(const IP_Address &p_multi_address, String p_if_name) {
+	return _change_multicast_group(p_multi_address, p_if_name, false);
 }

+ 2 - 2
editor/animation_bezier_editor.cpp

@@ -275,8 +275,6 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
 		int margin = 0;
 
 		{
-			int ofs = 0;
-
 			NodePath path = animation->track_get_path(track);
 
 			Node *node = NULL;
@@ -290,6 +288,8 @@ void AnimationBezierTrackEdit::_notification(int p_what) {
 			int h = font->get_height();
 
 			if (node) {
+				int ofs = 0;
+
 				Ref<Texture> icon = EditorNode::get_singleton()->get_object_icon(node, "Node");
 
 				h = MAX(h, icon->get_height());

+ 1 - 1
editor/animation_track_editor_plugins.cpp

@@ -1009,7 +1009,7 @@ void AnimationTrackEditTypeAudio::drop_data(const Point2 &p_point, const Variant
 		}
 	}
 
-	return AnimationTrackEdit::drop_data(p_point, p_data);
+	AnimationTrackEdit::drop_data(p_point, p_data);
 }
 
 void AnimationTrackEditTypeAudio::_gui_input(const Ref<InputEvent> &p_event) {

+ 2 - 1
editor/create_dialog.cpp

@@ -329,8 +329,9 @@ void CreateDialog::_update_search() {
 		if (cpp_type && !ClassDB::can_instance(type))
 			continue; // can't create what can't be instanced
 
-		bool skip = false;
 		if (cpp_type) {
+			bool skip = false;
+
 			for (Set<StringName>::Element *E = type_blacklist.front(); E && !skip; E = E->next()) {
 				if (ClassDB::is_parent_class(type, E->get()))
 					skip = true;

+ 1 - 1
editor/editor_plugin.cpp

@@ -200,7 +200,7 @@ ScriptEditor *EditorInterface::get_script_editor() {
 }
 
 void EditorInterface::select_file(const String &p_file) {
-	return EditorNode::get_singleton()->get_filesystem_dock()->select_file(p_file);
+	EditorNode::get_singleton()->get_filesystem_dock()->select_file(p_file);
 }
 
 String EditorInterface::get_selected_path() const {

+ 1 - 1
editor/groups_editor.cpp

@@ -69,7 +69,7 @@ void GroupDialog::_load_nodes(Node *p_current) {
 		keep = false;
 	}
 
-	TreeItem *node;
+	TreeItem *node = NULL;
 	NodePath path = scene_tree->get_edited_scene_root()->get_path_to(p_current);
 	if (keep && p_current->is_in_group(selected_group)) {
 		if (remove_filter->get_text().is_subsequence_ofi(String(p_current->get_name()))) {

+ 1 - 1
editor/plugins/collision_shape_2d_editor_plugin.h

@@ -89,7 +89,7 @@ class CollisionShape2DEditorPlugin : public EditorPlugin {
 
 public:
 	virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) { return collision_shape_2d_editor->forward_canvas_gui_input(p_event); }
-	virtual void forward_canvas_draw_over_viewport(Control *p_overlay) { return collision_shape_2d_editor->forward_canvas_draw_over_viewport(p_overlay); }
+	virtual void forward_canvas_draw_over_viewport(Control *p_overlay) { collision_shape_2d_editor->forward_canvas_draw_over_viewport(p_overlay); }
 
 	virtual String get_name() const { return "CollisionShape2D"; }
 	bool has_main_screen() const { return false; }

+ 1 - 1
editor/plugins/curve_editor_plugin.cpp

@@ -156,9 +156,9 @@ void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) {
 		Vector2 mpos = mm.get_position();
 
 		if (_dragging && _curve_ref.is_valid()) {
-			Curve &curve = **_curve_ref;
 
 			if (_selected_point != -1) {
+				Curve &curve = **_curve_ref;
 
 				if (!_has_undo_data) {
 					// Save full curve state before dragging points,

+ 1 - 1
editor/plugins/path_2d_editor_plugin.h

@@ -123,7 +123,7 @@ class Path2DEditorPlugin : public EditorPlugin {
 
 public:
 	virtual bool forward_canvas_gui_input(const Ref<InputEvent> &p_event) { return path2d_editor->forward_gui_input(p_event); }
-	virtual void forward_canvas_draw_over_viewport(Control *p_overlay) { return path2d_editor->forward_canvas_draw_over_viewport(p_overlay); }
+	virtual void forward_canvas_draw_over_viewport(Control *p_overlay) { path2d_editor->forward_canvas_draw_over_viewport(p_overlay); }
 
 	virtual String get_name() const { return "Path2D"; }
 	bool has_main_screen() const { return false; }

+ 1 - 1
editor/plugins/script_editor_plugin.cpp

@@ -3463,7 +3463,7 @@ void ScriptEditorPlugin::get_window_layout(Ref<ConfigFile> p_layout) {
 
 void ScriptEditorPlugin::get_breakpoints(List<String> *p_breakpoints) {
 
-	return script_editor->get_breakpoints(p_breakpoints);
+	script_editor->get_breakpoints(p_breakpoints);
 }
 
 void ScriptEditorPlugin::edited_scene_changed() {

+ 6 - 1
editor/plugins/texture_region_editor_plugin.cpp

@@ -192,8 +192,8 @@ void TextureRegionEditor::_region_draw() {
 	}
 	updating_scroll = false;
 
-	float margins[4];
 	if (node_ninepatch || obj_styleBox.is_valid()) {
+		float margins[4];
 		if (node_ninepatch) {
 			margins[0] = node_ninepatch->get_patch_margin(MARGIN_TOP);
 			margins[1] = node_ninepatch->get_patch_margin(MARGIN_BOTTOM);
@@ -204,6 +204,11 @@ void TextureRegionEditor::_region_draw() {
 			margins[1] = obj_styleBox->get_margin_size(MARGIN_BOTTOM);
 			margins[2] = obj_styleBox->get_margin_size(MARGIN_LEFT);
 			margins[3] = obj_styleBox->get_margin_size(MARGIN_RIGHT);
+		} else {
+			margins[0] = 0;
+			margins[1] = 0;
+			margins[2] = 0;
+			margins[3] = 0;
 		}
 		Vector2 pos[4] = {
 			mtx.basis_xform(Vector2(0, margins[0])) + Vector2(0, endpoints[0].y - draw_ofs.y * draw_zoom),

+ 2 - 2
editor/project_settings_editor.cpp

@@ -257,7 +257,7 @@ void ProjectSettingsEditor::_device_input_add() {
 			Ref<InputEventJoypadMotion> jm;
 			jm.instance();
 			jm->set_axis(device_index->get_selected() >> 1);
-			jm->set_axis_value(device_index->get_selected() & 1 ? 1 : -1);
+			jm->set_axis_value((device_index->get_selected() & 1) ? 1 : -1);
 			jm->set_device(_get_current_device());
 
 			for (int i = 0; i < events.size(); i++) {
@@ -483,7 +483,7 @@ void ProjectSettingsEditor::_add_item(int p_item, Ref<InputEvent> p_exiting_even
 			for (int i = 0; i < JOY_AXIS_MAX * 2; i++) {
 
 				String desc = _axis_names[i];
-				device_index->add_item(TTR("Axis") + " " + itos(i / 2) + " " + (i & 1 ? "+" : "-") + desc);
+				device_index->add_item(TTR("Axis") + " " + itos(i / 2) + " " + ((i & 1) ? "+" : "-") + desc);
 			}
 			device_input->popup_centered_minsize(Size2(350, 95) * EDSCALE);
 

+ 0 - 1
editor/scene_tree_dock.cpp

@@ -1493,7 +1493,6 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
 		if (p_nodes.find(validate) != -1) {
 			ERR_EXPLAIN("Selection changed at some point.. can't reparent");
 			ERR_FAIL();
-			return;
 		}
 		validate = validate->get_parent();
 	}

+ 2 - 2
editor/spatial_editor_gizmos.cpp

@@ -147,7 +147,7 @@ void EditorSpatialGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p
 	}
 
 	ERR_FAIL_COND(!gizmo_plugin);
-	return gizmo_plugin->set_handle(this, p_idx, p_camera, p_point);
+	gizmo_plugin->set_handle(this, p_idx, p_camera, p_point);
 }
 
 void EditorSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
@@ -158,7 +158,7 @@ void EditorSpatialGizmo::commit_handle(int p_idx, const Variant &p_restore, bool
 	}
 
 	ERR_FAIL_COND(!gizmo_plugin);
-	return gizmo_plugin->commit_handle(this, p_idx, p_restore, p_cancel);
+	gizmo_plugin->commit_handle(this, p_idx, p_restore, p_cancel);
 }
 
 void EditorSpatialGizmo::set_spatial_node(Spatial *p_node) {

+ 1 - 1
modules/gdscript/gdscript.cpp

@@ -332,7 +332,7 @@ ScriptInstance *GDScript::instance_create(Object *p_this) {
 	}
 
 	Variant::CallError unchecked_error;
-	return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this), unchecked_error);
+	return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this) != NULL, unchecked_error);
 }
 
 PlaceHolderScriptInstance *GDScript::placeholder_instance_create(Object *p_this) {

+ 0 - 2
modules/gdscript/gdscript_compiler.cpp

@@ -1259,8 +1259,6 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
 			ERR_FAIL_V(-1); //unreachable code
 		} break;
 	}
-
-	ERR_FAIL_V(-1); //unreachable code
 }
 
 Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::BlockNode *p_block, int p_stack_level, int p_break_addr, int p_continue_addr) {

+ 1 - 1
modules/mono/csharp_script.cpp

@@ -2701,7 +2701,7 @@ ScriptInstance *CSharpScript::instance_create(Object *p_this) {
 	}
 
 	Variant::CallError unchecked_error;
-	return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this), unchecked_error);
+	return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this) != NULL, unchecked_error);
 }
 
 PlaceHolderScriptInstance *CSharpScript::placeholder_instance_create(Object *p_this) {

+ 0 - 1
scene/2d/navigation_2d.cpp

@@ -92,7 +92,6 @@ void Navigation2D::_navpoly_link(int p_id) {
 		if (!valid) {
 			nm.polygons.pop_back();
 			ERR_CONTINUE(!valid);
-			continue;
 		}
 
 		p.center = center / plen;

+ 1 - 1
scene/3d/audio_stream_player_3d.h

@@ -71,7 +71,7 @@ private:
 	struct Output {
 
 		AudioFilterSW filter;
-		AudioFilterSW::Processor filter_process[6];
+		AudioFilterSW::Processor filter_process[8];
 		AudioFrame vol[4];
 		float filter_gain;
 		float pitch_scale;

+ 0 - 1
scene/3d/navigation.cpp

@@ -90,7 +90,6 @@ void Navigation::_navmesh_link(int p_id) {
 		if (!valid) {
 			nm.polygons.pop_back();
 			ERR_CONTINUE(!valid);
-			continue;
 		}
 
 		p.center = center;

+ 1 - 1
scene/gui/option_button.cpp

@@ -282,7 +282,7 @@ void OptionButton::_set_items(const Array &p_items) {
 
 void OptionButton::get_translatable_strings(List<String> *p_strings) const {
 
-	return popup->get_translatable_strings(p_strings);
+	popup->get_translatable_strings(p_strings);
 }
 
 void OptionButton::_bind_methods() {