Browse Source

Merge pull request #10846 from hpvb/fix-sign-compare

Fix signed and unsigned comparisons
Rémi Verschelde 8 years ago
parent
commit
dac150108a

+ 1 - 1
core/bind/core_bind.cpp

@@ -1705,7 +1705,7 @@ Variant _File::get_var() const {
 	ERR_FAIL_COND_V(!f, Variant());
 	uint32_t len = get_32();
 	PoolVector<uint8_t> buff = get_buffer(len);
-	ERR_FAIL_COND_V(buff.size() != len, Variant());
+	ERR_FAIL_COND_V((uint32_t)buff.size() != len, Variant());
 
 	PoolVector<uint8_t>::Read r = buff.read();
 

+ 5 - 5
core/io/file_access_compressed.h

@@ -37,11 +37,11 @@ class FileAccessCompressed : public FileAccess {
 
 	Compression::Mode cmode;
 	bool writing;
-	int write_pos;
+	uint32_t write_pos;
 	uint8_t *write_ptr;
-	int write_buffer_size;
-	int write_max;
-	int block_size;
+	uint32_t write_buffer_size;
+	uint32_t write_max;
+	uint32_t block_size;
 	mutable bool read_eof;
 	mutable bool at_end;
 
@@ -57,7 +57,7 @@ class FileAccessCompressed : public FileAccess {
 	mutable int read_block_size;
 	mutable int read_pos;
 	Vector<ReadBlock> read_blocks;
-	int read_total;
+	uint32_t read_total;
 
 	String magic;
 	mutable Vector<uint8_t> buffer;

+ 2 - 2
core/io/file_access_encrypted.cpp

@@ -73,14 +73,14 @@ Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector<uint8
 		length = p_base->get_64();
 		base = p_base->get_pos();
 		ERR_FAIL_COND_V(p_base->get_len() < base + length, ERR_FILE_CORRUPT);
-		int ds = length;
+		uint32_t ds = length;
 		if (ds % 16) {
 			ds += 16 - (ds % 16);
 		}
 
 		data.resize(ds);
 
-		int blen = p_base->get_buffer(data.ptr(), ds);
+		uint32_t blen = p_base->get_buffer(data.ptr(), ds);
 		ERR_FAIL_COND_V(blen != ds, ERR_FILE_CORRUPT);
 
 		aes256_context ctx;

+ 1 - 1
core/io/file_access_encrypted.h

@@ -48,7 +48,7 @@ private:
 	size_t base;
 	size_t length;
 	Vector<uint8_t> data;
-	mutable size_t pos;
+	mutable int pos;
 	mutable bool eofed;
 
 public:

+ 2 - 2
core/io/file_access_network.cpp

@@ -244,14 +244,14 @@ FileAccessNetworkClient::~FileAccessNetworkClient() {
 	memdelete(sem);
 }
 
-void FileAccessNetwork::_set_block(size_t p_offset, const Vector<uint8_t> &p_block) {
+void FileAccessNetwork::_set_block(int p_offset, const Vector<uint8_t> &p_block) {
 
 	int page = p_offset / page_size;
 	ERR_FAIL_INDEX(page, pages.size());
 	if (page < pages.size() - 1) {
 		ERR_FAIL_COND(p_block.size() != page_size);
 	} else {
-		ERR_FAIL_COND((p_block.size() != (total_size % page_size)));
+		ERR_FAIL_COND((p_block.size() != (int)(total_size % page_size)));
 	}
 
 	buffer_mutex->lock();

+ 2 - 2
core/io/file_access_network.h

@@ -97,7 +97,7 @@ class FileAccessNetwork : public FileAccess {
 	mutable int last_page;
 	mutable uint8_t *last_page_buff;
 
-	uint32_t page_size;
+	int page_size;
 	int read_ahead;
 	int max_pages;
 
@@ -121,7 +121,7 @@ class FileAccessNetwork : public FileAccess {
 	friend class FileAccessNetworkClient;
 	void _queue_page(int p_page) const;
 	void _respond(size_t p_len, Error p_status);
-	void _set_block(size_t p_offset, const Vector<uint8_t> &p_block);
+	void _set_block(int p_offset, const Vector<uint8_t> &p_block);
 
 public:
 	enum Command {

+ 5 - 5
core/io/marshalls.cpp

@@ -333,14 +333,14 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
 				len -= 12;
 				buf += 12;
 
-				int total = namecount + subnamecount;
+				uint32_t total = namecount + subnamecount;
 				if (flags & 2)
 					total++;
 
 				if (r_len)
 					(*r_len) += 12;
 
-				for (int i = 0; i < total; i++) {
+				for (uint32_t i = 0; i < total; i++) {
 
 					ERR_FAIL_COND_V((int)len < 4, ERR_INVALID_DATA);
 					strlen = decode_uint32(buf);
@@ -566,7 +566,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
 			if (count) {
 				data.resize(count);
 				PoolVector<uint8_t>::Write w = data.write();
-				for (int i = 0; i < count; i++) {
+				for (uint32_t i = 0; i < count; i++) {
 
 					w[i] = buf[i];
 				}
@@ -597,7 +597,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
 				//const int*rbuf=(const int*)buf;
 				data.resize(count);
 				PoolVector<int>::Write w = data.write();
-				for (int i = 0; i < count; i++) {
+				for (uint32_t i = 0; i < count; i++) {
 
 					w[i] = decode_uint32(&buf[i * 4]);
 				}
@@ -624,7 +624,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
 				//const float*rbuf=(const float*)buf;
 				data.resize(count);
 				PoolVector<float>::Write w = data.write();
-				for (int i = 0; i < count; i++) {
+				for (uint32_t i = 0; i < count; i++) {
 
 					w[i] = decode_float(&buf[i * 4]);
 				}

+ 3 - 3
core/io/resource_format_binary.cpp

@@ -102,7 +102,7 @@ StringName ResourceInteractiveLoaderBinary::_get_string() {
 
 	uint32_t id = f->get_32();
 	if (id & 0x80000000) {
-		uint32_t len = id & 0x7FFFFFFF;
+		int len = id & 0x7FFFFFFF;
 		if (len > str_buf.size()) {
 			str_buf.resize(len);
 		}
@@ -336,9 +336,9 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
 				} break;
 				case OBJECT_EXTERNAL_RESOURCE_INDEX: {
 					//new file format, just refers to an index in the external list
-					uint32_t erindex = f->get_32();
+					int erindex = f->get_32();
 
-					if (erindex >= external_resources.size()) {
+					if (erindex < 0 || erindex >= external_resources.size()) {
 						WARN_PRINT("Broken external resource! (index out of size");
 						r_v = Variant();
 					} else {

+ 1 - 1
core/io/xml_parser.cpp

@@ -385,7 +385,7 @@ void XMLParser::_bind_methods() {
 Error XMLParser::read() {
 
 	// if not end reached, parse the node
-	if (P && (P - data) < length - 1 && *P != 0) {
+	if (P && (P - data) < (int64_t)length - 1 && *P != 0) {
 		_parse_current_node();
 		return OK;
 	}

+ 1 - 1
core/io/xml_parser.h

@@ -67,7 +67,7 @@ public:
 private:
 	char *data;
 	char *P;
-	int length;
+	uint64_t length;
 	void unescape(String &p_str);
 	Vector<String> special_characters;
 	String node_name;

+ 2 - 2
core/math/quick_hull.cpp

@@ -389,8 +389,8 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
 
 		for (int i = 0; i < f.indices.size(); i++) {
 
-			uint32_t a = E->get().indices[i];
-			uint32_t b = E->get().indices[(i + 1) % f.indices.size()];
+			int a = E->get().indices[i];
+			int b = E->get().indices[(i + 1) % f.indices.size()];
 			Edge e(a, b);
 
 			Map<Edge, RetFaceConnect>::Element *F = ret_edges.find(e);

+ 4 - 4
core/packed_data_container.cpp

@@ -61,7 +61,7 @@ Variant PackedDataContainer::_iter_init_ofs(const Array &p_iter, uint32_t p_offs
 Variant PackedDataContainer::_iter_next_ofs(const Array &p_iter, uint32_t p_offset) {
 
 	Array ref = p_iter;
-	uint32_t size = _size(p_offset);
+	int size = _size(p_offset);
 	if (ref.size() != 1)
 		return false;
 	int pos = ref[0];
@@ -74,7 +74,7 @@ Variant PackedDataContainer::_iter_next_ofs(const Array &p_iter, uint32_t p_offs
 
 Variant PackedDataContainer::_iter_get_ofs(const Variant &p_iter, uint32_t p_offset) {
 
-	uint32_t size = _size(p_offset);
+	int size = _size(p_offset);
 	int pos = p_iter;
 	if (pos < 0 || pos >= size)
 		return Variant();
@@ -164,7 +164,7 @@ Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, b
 		if (p_key.is_num()) {
 
 			int idx = p_key;
-			uint32_t len = decode_uint32(r + 4);
+			int len = decode_uint32(r + 4);
 			if (idx < 0 || idx >= len) {
 				err = true;
 				return Variant();
@@ -183,7 +183,7 @@ Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, b
 		uint32_t len = decode_uint32(r + 4);
 
 		bool found = false;
-		for (int i = 0; i < len; i++) {
+		for (uint32_t i = 0; i < len; i++) {
 			uint32_t khash = decode_uint32(r + 8 + i * 12 + 0);
 			if (khash == hash) {
 				Variant key = _get_at_ofs(decode_uint32(r + 8 + i * 12 + 4), rd.ptr(), err);

+ 3 - 3
core/pool_allocator.cpp

@@ -339,9 +339,9 @@ Error PoolAllocator::resize(ID p_mem, int p_new_size) {
 		ERR_FAIL_COND_V(e->lock, ERR_ALREADY_IN_USE);
 	}
 
-	int alloc_size = aligned(p_new_size);
+	uint32_t alloc_size = aligned(p_new_size);
 
-	if (aligned(e->len) == alloc_size) {
+	if ((uint32_t)aligned(e->len) == alloc_size) {
 
 		e->len = p_new_size;
 		mt_unlock();
@@ -374,7 +374,7 @@ Error PoolAllocator::resize(ID p_mem, int p_new_size) {
 	}
 
 	//no need to move stuff around, it fits before the next block
-	int next_pos;
+	uint32_t next_pos;
 	if (entry_indices_pos + 1 == entry_count) {
 		next_pos = pool_size; // - static_area_size;
 	} else {

+ 1 - 1
core/ustring.cpp

@@ -588,7 +588,7 @@ String String::camelcase_to_underscore(bool lowercase) const {
 	const char a = 'a', z = 'z';
 	int start_index = 0;
 
-	for (size_t i = 1; i < this->size(); i++) {
+	for (int i = 1; i < this->size(); i++) {
 		bool is_upper = cstr[i] >= A && cstr[i] <= Z;
 		bool is_number = cstr[i] >= '0' && cstr[i] <= '9';
 		bool are_next_2_lower = false;

+ 6 - 6
drivers/gles3/rasterizer_scene_gles3.cpp

@@ -247,7 +247,7 @@ bool RasterizerSceneGLES3::_shadow_atlas_find_shadow(ShadowAtlas *shadow_atlas,
 
 		int qidx = p_in_quadrants[i];
 
-		if (shadow_atlas->quadrants[qidx].subdivision == p_current_subdiv) {
+		if (shadow_atlas->quadrants[qidx].subdivision == (uint32_t)p_current_subdiv) {
 			return false;
 		}
 
@@ -349,7 +349,7 @@ bool RasterizerSceneGLES3::shadow_atlas_update_light(RID p_atlas, RID p_light_in
 		uint32_t q = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3;
 		uint32_t s = key & ShadowAtlas::SHADOW_INDEX_MASK;
 
-		bool should_realloc = shadow_atlas->quadrants[q].subdivision != best_subdiv && (shadow_atlas->quadrants[q].shadows[s].alloc_tick - tick > shadow_atlas_realloc_tolerance_msec);
+		bool should_realloc = shadow_atlas->quadrants[q].subdivision != (uint32_t)best_subdiv && (shadow_atlas->quadrants[q].shadows[s].alloc_tick - tick > shadow_atlas_realloc_tolerance_msec);
 		bool should_redraw = shadow_atlas->quadrants[q].shadows[s].version != p_light_version;
 
 		if (!should_realloc) {
@@ -554,7 +554,7 @@ void RasterizerSceneGLES3::reflection_atlas_set_subdivision(RID p_ref_atlas, int
 	ReflectionAtlas *reflection_atlas = reflection_atlas_owner.getornull(p_ref_atlas);
 	ERR_FAIL_COND(!reflection_atlas);
 
-	uint32_t subdiv = next_power_of_2(p_subdiv);
+	int subdiv = next_power_of_2(p_subdiv);
 	if (subdiv & 0xaaaaaaaa) { //sqrt(subdiv) must be integer
 		subdiv <<= 1;
 	}
@@ -2702,7 +2702,7 @@ void RasterizerSceneGLES3::_setup_lights(RID *p_light_cull_result, int p_light_c
 					uint32_t quadrant = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3;
 					uint32_t shadow = key & ShadowAtlas::SHADOW_INDEX_MASK;
 
-					ERR_CONTINUE(shadow >= shadow_atlas->quadrants[quadrant].shadows.size());
+					ERR_CONTINUE(shadow >= (uint32_t)shadow_atlas->quadrants[quadrant].shadows.size());
 
 					uint32_t atlas_size = shadow_atlas->size;
 					uint32_t quadrant_size = atlas_size >> 1;
@@ -2789,7 +2789,7 @@ void RasterizerSceneGLES3::_setup_lights(RID *p_light_cull_result, int p_light_c
 					uint32_t quadrant = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3;
 					uint32_t shadow = key & ShadowAtlas::SHADOW_INDEX_MASK;
 
-					ERR_CONTINUE(shadow >= shadow_atlas->quadrants[quadrant].shadows.size());
+					ERR_CONTINUE(shadow >= (uint32_t)shadow_atlas->quadrants[quadrant].shadows.size());
 
 					uint32_t atlas_size = shadow_atlas->size;
 					uint32_t quadrant_size = atlas_size >> 1;
@@ -4469,7 +4469,7 @@ void RasterizerSceneGLES3::render_shadow(RID p_light, RID p_shadow_atlas, int p_
 		uint32_t quadrant = (key >> ShadowAtlas::QUADRANT_SHIFT) & 0x3;
 		uint32_t shadow = key & ShadowAtlas::SHADOW_INDEX_MASK;
 
-		ERR_FAIL_INDEX(shadow, shadow_atlas->quadrants[quadrant].shadows.size());
+		ERR_FAIL_INDEX((int)shadow, shadow_atlas->quadrants[quadrant].shadows.size());
 
 		uint32_t quadrant_size = shadow_atlas->size >> 1;
 

+ 1 - 1
drivers/gles3/rasterizer_scene_gles3.h

@@ -244,7 +244,7 @@ public:
 
 		GLuint fbo_id[6];
 		GLuint cubemap;
-		int size;
+		uint32_t size;
 	};
 
 	Vector<ShadowCubeMap> shadow_cubemaps;

+ 2 - 2
drivers/png/image_loader_png.cpp

@@ -216,8 +216,8 @@ void ImageLoaderPNG::get_recognized_extensions(List<String> *p_extensions) const
 
 struct PNGReadStatus {
 
-	int offset;
-	int size;
+	uint32_t offset;
+	uint32_t size;
 	const unsigned char *image;
 };
 

+ 1 - 1
editor/import/editor_scene_importer_gltf.cpp

@@ -474,7 +474,7 @@ Error EditorSceneImporterGLTF::_decode_buffer_view(GLTFState &state, int p_buffe
 	int buffer_end = (stride * (count - 1)) + element_size;
 	ERR_FAIL_COND_V(buffer_end > bv.byte_length, ERR_PARSE_ERROR);
 
-	ERR_FAIL_COND_V((offset + buffer_end) > buffer.size(), ERR_PARSE_ERROR);
+	ERR_FAIL_COND_V((int)(offset + buffer_end) > buffer.size(), ERR_PARSE_ERROR);
 
 	//fill everything as doubles
 

+ 1 - 1
editor/plugins/canvas_item_editor_plugin.cpp

@@ -409,7 +409,7 @@ bool CanvasItemEditor::_is_part_of_subscene(CanvasItem *p_item) {
 	return item_owner && item_owner != scene_node && p_item != scene_node && item_owner->get_filename() != "";
 }
 
-void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, Vector<_SelectResult> &r_items, unsigned int limit) {
+void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, Vector<_SelectResult> &r_items, int limit) {
 	if (!p_node)
 		return;
 	if (Object::cast_to<Viewport>(p_node))

+ 1 - 1
editor/plugins/canvas_item_editor_plugin.h

@@ -291,7 +291,7 @@ class CanvasItemEditor : public VBoxContainer {
 
 	int handle_len;
 	bool _is_part_of_subscene(CanvasItem *p_item);
-	void _find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, Vector<_SelectResult> &r_items, unsigned int limit = 0);
+	void _find_canvas_items_at_pos(const Point2 &p_pos, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, Vector<_SelectResult> &r_items, int limit = 0);
 	void _find_canvas_items_at_rect(const Rect2 &p_rect, Node *p_node, const Transform2D &p_parent_xform, const Transform2D &p_canvas_xform, List<CanvasItem *> *r_items);
 
 	void _select_click_on_empty_area(Point2 p_click_pos, bool p_append, bool p_box_selection);

+ 1 - 1
editor/plugins/line_2d_editor_plugin.cpp

@@ -211,7 +211,7 @@ void Line2DEditor::_bind_methods() {
 }
 
 void Line2DEditor::_mode_selected(int p_mode) {
-	for (unsigned int i = 0; i < _MODE_COUNT; ++i) {
+	for (int i = 0; i < _MODE_COUNT; ++i) {
 		toolbar_buttons[i]->set_pressed(i == p_mode);
 	}
 	mode = Mode(p_mode);

+ 8 - 8
editor/plugins/spatial_editor_plugin.cpp

@@ -2958,7 +2958,7 @@ void SpatialEditor::update_transform_gizmo() {
 	gizmo.transform.origin = pcenter;
 	gizmo.transform.basis = gizmo_basis;
 
-	for (int i = 0; i < VIEWPORTS_COUNT; i++) {
+	for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
 		viewports[i]->update_transform_gizmo_view();
 	}
 }
@@ -3108,7 +3108,7 @@ void SpatialEditor::set_state(const Dictionary &p_state) {
 		Array vp = d["viewports"];
 		ERR_FAIL_COND(vp.size() > 4);
 
-		for (int i = 0; i < VIEWPORTS_COUNT; i++) {
+		for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
 			viewports[i]->set_state(vp[i]);
 		}
 	}
@@ -3852,15 +3852,15 @@ void SpatialEditor::_toggle_maximize_view(Object *p_viewport) {
 
 	if (!maximized) {
 
-		for (int i = 0; i < VIEWPORTS_COUNT; i++) {
-			if (i == index)
+		for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
+			if (i == (uint32_t)index)
 				viewports[i]->set_area_as_parent_rect();
 			else
 				viewports[i]->hide();
 		}
 	} else {
 
-		for (int i = 0; i < VIEWPORTS_COUNT; i++)
+		for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++)
 			viewports[i]->show();
 
 		if (view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(MENU_VIEW_USE_1_VIEWPORT)))
@@ -3904,7 +3904,7 @@ void SpatialEditor::clear() {
 	settings_znear->set_value(EDITOR_DEF("editors/3d/default_z_near", 0.1));
 	settings_zfar->set_value(EDITOR_DEF("editors/3d/default_z_far", 1500.0));
 
-	for (int i = 0; i < VIEWPORTS_COUNT; i++) {
+	for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
 		viewports[i]->reset();
 	}
 
@@ -3917,7 +3917,7 @@ void SpatialEditor::clear() {
 		}
 	}
 
-	for (int i = 0; i < VIEWPORTS_COUNT; i++) {
+	for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
 
 		viewports[i]->view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(SpatialEditorViewport::VIEW_AUDIO_LISTENER), i == 0);
 		viewports[i]->viewport->set_as_audio_listener(i == 0);
@@ -4074,7 +4074,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
 	viewport_base = memnew(SpatialEditorViewportContainer);
 	shader_split->add_child(viewport_base);
 	viewport_base->set_v_size_flags(SIZE_EXPAND_FILL);
-	for (int i = 0; i < VIEWPORTS_COUNT; i++) {
+	for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) {
 
 		viewports[i] = memnew(SpatialEditorViewport(this, editor, i));
 		viewports[i]->connect("toggle_maximize_view", this, "_toggle_maximize_view");

+ 1 - 1
modules/etc/image_etc.cpp

@@ -117,7 +117,7 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f
 		return;
 	}
 
-	int imgw = p_img->get_width(), imgh = p_img->get_height();
+	uint32_t imgw = p_img->get_width(), imgh = p_img->get_height();
 	ERR_FAIL_COND(next_power_of_2(imgw) != imgw || next_power_of_2(imgh) != imgh);
 
 	Image::Format etc_format = force_etc1_format ? Image::FORMAT_ETC : _get_etc2_mode(detected_channels);

+ 7 - 7
modules/gdnative/godot/array.cpp

@@ -61,7 +61,7 @@ void GDAPI godot_array_new_pool_color_array(godot_array *r_dest, const godot_poo
 	memnew_placement(dest, Array);
 	dest->resize(pca->size());
 
-	for (size_t i = 0; i < dest->size(); i++) {
+	for (int i = 0; i < dest->size(); i++) {
 		Variant v = pca->operator[](i);
 		dest->operator[](i) = v;
 	}
@@ -73,7 +73,7 @@ void GDAPI godot_array_new_pool_vector3_array(godot_array *r_dest, const godot_p
 	memnew_placement(dest, Array);
 	dest->resize(pca->size());
 
-	for (size_t i = 0; i < dest->size(); i++) {
+	for (int i = 0; i < dest->size(); i++) {
 		Variant v = pca->operator[](i);
 		dest->operator[](i) = v;
 	}
@@ -85,7 +85,7 @@ void GDAPI godot_array_new_pool_vector2_array(godot_array *r_dest, const godot_p
 	memnew_placement(dest, Array);
 	dest->resize(pca->size());
 
-	for (size_t i = 0; i < dest->size(); i++) {
+	for (int i = 0; i < dest->size(); i++) {
 		Variant v = pca->operator[](i);
 		dest->operator[](i) = v;
 	}
@@ -97,7 +97,7 @@ void GDAPI godot_array_new_pool_string_array(godot_array *r_dest, const godot_po
 	memnew_placement(dest, Array);
 	dest->resize(pca->size());
 
-	for (size_t i = 0; i < dest->size(); i++) {
+	for (int i = 0; i < dest->size(); i++) {
 		Variant v = pca->operator[](i);
 		dest->operator[](i) = v;
 	}
@@ -109,7 +109,7 @@ void GDAPI godot_array_new_pool_real_array(godot_array *r_dest, const godot_pool
 	memnew_placement(dest, Array);
 	dest->resize(pca->size());
 
-	for (size_t i = 0; i < dest->size(); i++) {
+	for (int i = 0; i < dest->size(); i++) {
 		Variant v = pca->operator[](i);
 		dest->operator[](i) = v;
 	}
@@ -121,7 +121,7 @@ void GDAPI godot_array_new_pool_int_array(godot_array *r_dest, const godot_pool_
 	memnew_placement(dest, Array);
 	dest->resize(pca->size());
 
-	for (size_t i = 0; i < dest->size(); i++) {
+	for (int i = 0; i < dest->size(); i++) {
 		Variant v = pca->operator[](i);
 		dest->operator[](i) = v;
 	}
@@ -133,7 +133,7 @@ void GDAPI godot_array_new_pool_byte_array(godot_array *r_dest, const godot_pool
 	memnew_placement(dest, Array);
 	dest->resize(pca->size());
 
-	for (size_t i = 0; i < dest->size(); i++) {
+	for (int i = 0; i < dest->size(); i++) {
 		Variant v = pca->operator[](i);
 		dest->operator[](i) = v;
 	}

+ 7 - 7
modules/gdnative/godot/pool_arrays.cpp

@@ -65,7 +65,7 @@ void GDAPI godot_pool_byte_array_new_with_array(godot_pool_byte_array *r_dest, c
 	memnew_placement(dest, PoolVector<uint8_t>);
 
 	dest->resize(a->size());
-	for (size_t i = 0; i < a->size(); i++) {
+	for (int i = 0; i < a->size(); i++) {
 		dest->set(i, (*a)[i]);
 	}
 }
@@ -144,7 +144,7 @@ void GDAPI godot_pool_int_array_new_with_array(godot_pool_int_array *r_dest, con
 	memnew_placement(dest, PoolVector<godot_int>);
 
 	dest->resize(a->size());
-	for (size_t i = 0; i < a->size(); i++) {
+	for (int i = 0; i < a->size(); i++) {
 		dest->set(i, (*a)[i]);
 	}
 }
@@ -223,7 +223,7 @@ void GDAPI godot_pool_real_array_new_with_array(godot_pool_real_array *r_dest, c
 	memnew_placement(dest, PoolVector<godot_real>);
 
 	dest->resize(a->size());
-	for (size_t i = 0; i < a->size(); i++) {
+	for (int i = 0; i < a->size(); i++) {
 		dest->set(i, (*a)[i]);
 	}
 }
@@ -302,7 +302,7 @@ void GDAPI godot_pool_string_array_new_with_array(godot_pool_string_array *r_des
 	memnew_placement(dest, PoolVector<String>);
 
 	dest->resize(a->size());
-	for (size_t i = 0; i < a->size(); i++) {
+	for (int i = 0; i < a->size(); i++) {
 		dest->set(i, (*a)[i]);
 	}
 }
@@ -389,7 +389,7 @@ void GDAPI godot_pool_vector2_array_new_with_array(godot_pool_vector2_array *r_d
 	memnew_placement(dest, PoolVector<Vector2>);
 
 	dest->resize(a->size());
-	for (size_t i = 0; i < a->size(); i++) {
+	for (int i = 0; i < a->size(); i++) {
 		dest->set(i, (*a)[i]);
 	}
 }
@@ -475,7 +475,7 @@ void GDAPI godot_pool_vector3_array_new_with_array(godot_pool_vector3_array *r_d
 	memnew_placement(dest, PoolVector<Vector3>);
 
 	dest->resize(a->size());
-	for (size_t i = 0; i < a->size(); i++) {
+	for (int i = 0; i < a->size(); i++) {
 		dest->set(i, (*a)[i]);
 	}
 }
@@ -561,7 +561,7 @@ void GDAPI godot_pool_color_array_new_with_array(godot_pool_color_array *r_dest,
 	memnew_placement(dest, PoolVector<Color>);
 
 	dest->resize(a->size());
-	for (size_t i = 0; i < a->size(); i++) {
+	for (int i = 0; i < a->size(); i++) {
 		dest->set(i, (*a)[i]);
 	}
 }

+ 3 - 3
modules/regex/regex.cpp

@@ -309,7 +309,7 @@ Ref<RegExMatch> RegEx::search(const String &p_subject, int p_offset, int p_end)
 	_pattern_info(PCRE2_INFO_NAMETABLE, &table);
 	_pattern_info(PCRE2_INFO_NAMEENTRYSIZE, &entry_size);
 
-	for (int i = 0; i < count; i++) {
+	for (uint32_t i = 0; i < count; i++) {
 
 		CharType id = table[i * entry_size];
 		if (result->data[id].start == -1)
@@ -338,7 +338,7 @@ String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_a
 	PCRE2_SIZE olength = output.length();
 
 	PCRE2_SIZE length = p_subject.length();
-	if (p_end >= 0 && p_end < length)
+	if (p_end >= 0 && (uint32_t)p_end < length)
 		length = p_end;
 
 	if (sizeof(CharType) == 2) {
@@ -430,7 +430,7 @@ Array RegEx::get_names() const {
 	_pattern_info(PCRE2_INFO_NAMETABLE, &table);
 	_pattern_info(PCRE2_INFO_NAMEENTRYSIZE, &entry_size);
 
-	for (int i = 0; i < count; i++) {
+	for (uint32_t i = 0; i < count; i++) {
 
 		String name = &table[i * entry_size + 1];
 		if (result.find(name) < 0) {

+ 5 - 5
modules/tga/image_loader_tga.cpp

@@ -53,19 +53,19 @@ Error ImageLoaderTGA::decode_tga_rle(const uint8_t *p_compressed_buffer, size_t
 		count = (c & 0x7f) + 1;
 
 		if (c & 0x80) {
-			for (int i = 0; i < p_pixel_size; i++) {
+			for (size_t i = 0; i < p_pixel_size; i++) {
 				pixels_w.ptr()[i] = p_compressed_buffer[compressed_pos];
 				compressed_pos += 1;
 			}
-			for (int i = 0; i < count; i++) {
-				for (int j = 0; j < p_pixel_size; j++) {
+			for (size_t i = 0; i < count; i++) {
+				for (size_t j = 0; j < p_pixel_size; j++) {
 					p_uncompressed_buffer[output_pos + j] = pixels_w.ptr()[j];
 				}
 				output_pos += p_pixel_size;
 			}
 		} else {
 			count *= p_pixel_size;
-			for (int i = 0; i < count; i++) {
+			for (size_t i = 0; i < count; i++) {
 				p_uncompressed_buffer[output_pos] = p_compressed_buffer[compressed_pos];
 				compressed_pos += 1;
 				output_pos += 1;
@@ -208,7 +208,7 @@ Error ImageLoaderTGA::load_image(Ref<Image> p_image, FileAccess *f, bool p_force
 	PoolVector<uint8_t> src_image;
 	int src_image_len = f->get_len();
 	ERR_FAIL_COND_V(src_image_len == 0, ERR_FILE_CORRUPT);
-	ERR_FAIL_COND_V(src_image_len < sizeof(tga_header_s), ERR_FILE_CORRUPT);
+	ERR_FAIL_COND_V(src_image_len < (int)sizeof(tga_header_s), ERR_FILE_CORRUPT);
 	src_image.resize(src_image_len);
 
 	Error err = OK;

+ 4 - 4
platform/uwp/export/export.cpp

@@ -501,7 +501,7 @@ void AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t
 
 		size_t block_size = (p_len - step) > BLOCK_SIZE ? BLOCK_SIZE : (p_len - step);
 
-		for (int i = 0; i < block_size; i++) {
+		for (uint32_t i = 0; i < block_size; i++) {
 			strm_in[i] = p_buffer[step + i];
 		}
 
@@ -523,14 +523,14 @@ void AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t
 			//package->store_buffer(strm_out.ptr(), strm.total_out - total_out_before);
 			int start = file_buffer.size();
 			file_buffer.resize(file_buffer.size() + bh.compressed_size);
-			for (int i = 0; i < bh.compressed_size; i++)
+			for (uint32_t i = 0; i < bh.compressed_size; i++)
 				file_buffer[start + i] = strm_out[i];
 		} else {
 			bh.compressed_size = block_size;
 			//package->store_buffer(strm_in.ptr(), block_size);
 			int start = file_buffer.size();
 			file_buffer.resize(file_buffer.size() + block_size);
-			for (int i = 0; i < bh.compressed_size; i++)
+			for (uint32_t i = 0; i < bh.compressed_size; i++)
 				file_buffer[start + i] = strm_in[i];
 		}
 
@@ -553,7 +553,7 @@ void AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t
 		//package->store_buffer(strm_out.ptr(), strm.total_out - total_out_before);
 		int start = file_buffer.size();
 		file_buffer.resize(file_buffer.size() + (strm.total_out - total_out_before));
-		for (int i = 0; i < (strm.total_out - total_out_before); i++)
+		for (uint32_t i = 0; i < (strm.total_out - total_out_before); i++)
 			file_buffer[start + i] = strm_out[i];
 
 		deflateEnd(&strm);

+ 2 - 2
scene/gui/item_list.cpp

@@ -534,7 +534,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
 				uint64_t now = OS::get_singleton()->get_ticks_msec();
 				uint64_t diff = now - search_time_msec;
 
-				if (diff < int(ProjectSettings::get_singleton()->get("gui/timers/incremental_search_max_interval_msec")) * 2) {
+				if (diff < uint64_t(ProjectSettings::get_singleton()->get("gui/timers/incremental_search_max_interval_msec")) * 2) {
 
 					for (int i = current - 1; i >= 0; i--) {
 
@@ -569,7 +569,7 @@ void ItemList::_gui_input(const Ref<InputEvent> &p_event) {
 				uint64_t now = OS::get_singleton()->get_ticks_msec();
 				uint64_t diff = now - search_time_msec;
 
-				if (diff < int(ProjectSettings::get_singleton()->get("gui/timers/incremental_search_max_interval_msec")) * 2) {
+				if (diff < uint64_t(ProjectSettings::get_singleton()->get("gui/timers/incremental_search_max_interval_msec")) * 2) {
 
 					for (int i = current + 1; i < items.size(); i++) {
 

+ 2 - 2
scene/resources/texture.cpp

@@ -501,9 +501,9 @@ Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &fla
 		Vector<Ref<Image> > mipmap_images;
 		int total_size = 0;
 
-		for (int i = 0; i < mipmaps; i++) {
+		for (uint32_t i = 0; i < mipmaps; i++) {
 
-			if (i > 0) {
+			if (i) {
 				size = f->get_32();
 			}
 

+ 4 - 4
servers/audio/audio_rb_resampler.cpp

@@ -176,7 +176,7 @@ bool AudioRBResampler::mix(int32_t *p_dest, int p_frames) {
 
 	{
 
-		uint32_t read = 0;
+		int read = 0;
 		switch (channels) {
 			case 1: read = _resample<1>(p_dest, todo, increment); break;
 			case 2: read = _resample<2>(p_dest, todo, increment); break;
@@ -189,7 +189,7 @@ bool AudioRBResampler::mix(int32_t *p_dest, int p_frames) {
 		if (remaining && todo > 0) {
 
 			//print_line("fadeout");
-			for (int c = 0; c < channels; c++) {
+			for (uint32_t c = 0; c < channels; c++) {
 
 				for (int i = 0; i < todo; i++) {
 
@@ -202,7 +202,7 @@ bool AudioRBResampler::mix(int32_t *p_dest, int p_frames) {
 		}
 
 		//zero out what remains there to avoid glitches
-		for (int i = todo * channels; i < int(p_frames) * channels; i++) {
+		for (uint32_t i = todo * channels; i < int(p_frames) * channels; i++) {
 
 			p_dest[i] = 0;
 		}
@@ -250,7 +250,7 @@ Error AudioRBResampler::setup(int p_channels, int p_src_mix_rate, int p_target_m
 	rb_write_pos = 0;
 
 	//avoid maybe strange noises upon load
-	for (int i = 0; i < (rb_len * channels); i++) {
+	for (unsigned int i = 0; i < (rb_len * channels); i++) {
 
 		rb[i] = 0;
 		read_buf[i] = 0;

+ 1 - 1
servers/audio/effects/audio_effect_chorus.cpp

@@ -78,7 +78,7 @@ void AudioEffectChorusInstance::_process_chunk(const AudioFrame *p_src_frames, A
 		uint64_t increment = llrint(cycles_to_mix / (double)p_frame_count * (double)(1 << AudioEffectChorus::CYCLES_FRAC));
 
 		//check the LFO doesn't read ahead of the write pos
-		if ((((int)max_depth_frames) + 10) > delay_frames) { //10 as some threshold to avoid precision stuff
+		if ((((unsigned int)max_depth_frames) + 10) > delay_frames) { //10 as some threshold to avoid precision stuff
 			delay_frames += (int)max_depth_frames - delay_frames;
 			delay_frames += 10; //threshold to avoid precision stuff
 		}

+ 2 - 2
servers/physics_2d/broad_phase_2d_hash_grid.cpp

@@ -640,7 +640,7 @@ BroadPhase2DHashGrid::BroadPhase2DHashGrid() {
 	cell_size = GLOBAL_DEF("physics/2d/cell_size", 128);
 	large_object_min_surface = GLOBAL_DEF("physics/2d/large_object_surface_threshold_in_cells", 512);
 
-	for (int i = 0; i < hash_table_size; i++)
+	for (uint32_t i = 0; i < hash_table_size; i++)
 		hash_table[i] = NULL;
 	pass = 1;
 
@@ -649,7 +649,7 @@ BroadPhase2DHashGrid::BroadPhase2DHashGrid() {
 
 BroadPhase2DHashGrid::~BroadPhase2DHashGrid() {
 
-	for (int i = 0; i < hash_table_size; i++) {
+	for (uint32_t i = 0; i < hash_table_size; i++) {
 		while (hash_table[i]) {
 			PosBin *pb = hash_table[i];
 			hash_table[i] = pb->next;

+ 13 - 13
servers/visual/visual_server_scene.cpp

@@ -1687,7 +1687,7 @@ bool VisualServerScene::_render_reflection_probe_step(Instance *p_instance, int
 
 void VisualServerScene::_gi_probe_fill_local_data(int p_idx, int p_level, int p_x, int p_y, int p_z, const GIProbeDataCell *p_cell, const GIProbeDataHeader *p_header, InstanceGIProbeData::LocalData *p_local_data, Vector<uint32_t> *prev_cell) {
 
-	if (p_level == p_header->cell_subdiv - 1) {
+	if ((uint32_t)p_level == p_header->cell_subdiv - 1) {
 
 		Vector3 emission;
 		emission.x = (p_cell[p_idx].emission >> 24) / 255.0;
@@ -1798,9 +1798,9 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) {
 	}
 	for (int i = 0; i < (int)header->cell_subdiv; i++) {
 
-		uint32_t x = header->width >> i;
-		uint32_t y = header->height >> i;
-		uint32_t z = header->depth >> i;
+		int x = header->width >> i;
+		int y = header->height >> i;
+		int z = header->depth >> i;
 
 		//create and clear mipmap
 		PoolVector<uint8_t> mipmap;
@@ -1896,7 +1896,7 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) {
 
 				uint8_t alpha_block[4][4] = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } };
 
-				for (int j = 0; j < k.source_count; j++) {
+				for (uint32_t j = 0; j < k.source_count; j++) {
 
 					int alpha = (cells[k.sources[j]].level_alpha >> 8) & 0xFF;
 					if (alpha < min_alpha)
@@ -2389,7 +2389,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
 
 				Vector3 colors[16];
 
-				for (int j = 0; j < b.source_count; j++) {
+				for (uint32_t j = 0; j < b.source_count; j++) {
 
 					colors[j].x = (local_data[b.sources[j]].energy[0] / float(probe_data->dynamic.bake_dynamic_range)) / 1024.0;
 					colors[j].y = (local_data[b.sources[j]].energy[1] / float(probe_data->dynamic.bake_dynamic_range)) / 1024.0;
@@ -2403,8 +2403,8 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
 				if (b.source_count == 16) {
 					//all cells are used so, find minmax between them
 					int further_apart[2] = { 0, 0 };
-					for (int j = 0; j < b.source_count; j++) {
-						for (int k = j + 1; k < b.source_count; k++) {
+					for (uint32_t j = 0; j < b.source_count; j++) {
+						for (uint32_t k = j + 1; k < b.source_count; k++) {
 							float d = colors[j].distance_squared_to(colors[k]);
 							if (d > distance) {
 								distance = d;
@@ -2424,12 +2424,12 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
 					//average all colors first
 					Vector3 average;
 
-					for (int j = 0; j < b.source_count; j++) {
+					for (uint32_t j = 0; j < b.source_count; j++) {
 						average += colors[j];
 					}
 					average.normalize();
 					//find max distance in normal from average
-					for (int j = 0; j < b.source_count; j++) {
+					for (uint32_t j = 0; j < b.source_count; j++) {
 						float d = average.dot(colors[j]);
 						distance = MAX(d, distance);
 					}
@@ -2459,7 +2459,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
 
 					Vector3 dir = (to - from).normalized();
 
-					for (int j = 0; j < b.source_count; j++) {
+					for (uint32_t j = 0; j < b.source_count; j++) {
 
 						float d = (colors[j] - from).dot(dir) / distance;
 						indices[j] = int(d * 3 + 0.5);
@@ -2469,7 +2469,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
 						indices[j] = index_swap[CLAMP(indices[j], 0, 3)];
 					}
 				} else {
-					for (int j = 0; j < b.source_count; j++) {
+					for (uint32_t j = 0; j < b.source_count; j++) {
 						indices[j] = 0;
 					}
 				}
@@ -2478,7 +2478,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) {
 
 				uint32_t index_block[16] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
 
-				for (int j = 0; j < b.source_count; j++) {
+				for (uint32_t j = 0; j < b.source_count; j++) {
 
 					int x = local_data[b.sources[j]].pos[0] % 4;
 					int y = local_data[b.sources[j]].pos[1] % 4;