diff options
author | marxin <mliska@suse.cz> | 2019-02-21 20:57:39 +0100 |
---|---|---|
committer | marxin <mliska@suse.cz> | 2019-02-27 07:45:57 +0100 |
commit | e5f665c7187b6934a71169cab5075f899150f17a (patch) | |
tree | a42da38f0076409975980452e8264a60d94f747d /modules | |
parent | ce114e35dda4b3f282abb458f8409db2369b279e (diff) |
Fix -Wsign-compare warnings.
I decided to modify code in a defensive way. Ideally functions
like size() or length() should return an unsigned type.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdnative/videodecoder/video_stream_gdnative.cpp | 4 | ||||
-rw-r--r-- | modules/gdscript/gdscript_tokenizer.cpp | 4 | ||||
-rw-r--r-- | modules/mono/csharp_script.cpp | 4 | ||||
-rw-r--r-- | modules/mono/glue/collections_glue.cpp | 4 | ||||
-rw-r--r-- | modules/mono/mono_gd/gd_mono.cpp | 4 | ||||
-rw-r--r-- | modules/pvr/texture_loader_pvr.cpp | 2 | ||||
-rw-r--r-- | modules/visual_script/visual_script_property_selector.cpp | 2 | ||||
-rw-r--r-- | modules/websocket/packet_buffer.h | 6 | ||||
-rw-r--r-- | modules/websocket/websocket_multiplayer_peer.cpp | 6 | ||||
-rw-r--r-- | modules/xatlas_unwrap/register_types.cpp | 4 |
10 files changed, 20 insertions, 20 deletions
diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.cpp b/modules/gdnative/videodecoder/video_stream_gdnative.cpp index 8c2a84f60b..d1794b6c36 100644 --- a/modules/gdnative/videodecoder/video_stream_gdnative.cpp +++ b/modules/gdnative/videodecoder/video_stream_gdnative.cpp @@ -76,7 +76,7 @@ int64_t GDAPI godot_videodecoder_file_seek(void *ptr, int64_t pos, int whence) { } break; case SEEK_CUR: { // Just in case it doesn't exist - if (pos < 0 && -pos > file->get_position()) { + if (pos < 0 && (size_t)-pos > file->get_position()) { return -1; } pos = pos + static_cast<int>(file->get_position()); @@ -86,7 +86,7 @@ int64_t GDAPI godot_videodecoder_file_seek(void *ptr, int64_t pos, int whence) { } break; case SEEK_END: { // Just in case something goes wrong - if (-pos > len) { + if ((size_t)-pos > len) { return -1; } file->seek_end(pos); diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp index 480bf0fa3c..8b22d6f085 100644 --- a/modules/gdscript/gdscript_tokenizer.cpp +++ b/modules/gdscript/gdscript_tokenizer.cpp @@ -1417,7 +1417,7 @@ StringName GDScriptTokenizerBuffer::get_token_identifier(int p_offset) const { ERR_FAIL_INDEX_V(offset, tokens.size(), StringName()); uint32_t identifier = tokens[offset] >> TOKEN_BITS; - ERR_FAIL_UNSIGNED_INDEX_V(identifier, identifiers.size(), StringName()); + ERR_FAIL_UNSIGNED_INDEX_V(identifier, (uint32_t)identifiers.size(), StringName()); return identifiers[identifier]; } @@ -1473,7 +1473,7 @@ const Variant &GDScriptTokenizerBuffer::get_token_constant(int p_offset) const { int offset = token + p_offset; ERR_FAIL_INDEX_V(offset, tokens.size(), nil); uint32_t constant = tokens[offset] >> TOKEN_BITS; - ERR_FAIL_UNSIGNED_INDEX_V(constant, constants.size(), nil); + ERR_FAIL_UNSIGNED_INDEX_V(constant, (uint32_t)constants.size(), nil); return constants[constant]; } String GDScriptTokenizerBuffer::get_token_error(int p_offset) const { diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 51615df64e..a7ac7f46c5 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -449,7 +449,7 @@ static String variant_type_to_managed_name(const String &p_var_type_name) { Variant::_RID }; - for (int i = 0; i < sizeof(var_types) / sizeof(Variant::Type); i++) { + for (unsigned int i = 0; i < sizeof(var_types) / sizeof(Variant::Type); i++) { if (p_var_type_name == Variant::get_type_name(var_types[i])) return p_var_type_name; } @@ -2172,7 +2172,7 @@ bool CSharpScript::_get_member_export(GDMonoClass *p_class, IMonoClassMember *p_ return false; } - if (val != i) { + if (val != (unsigned int)i) { uses_default_values = false; } diff --git a/modules/mono/glue/collections_glue.cpp b/modules/mono/glue/collections_glue.cpp index 0e5747a014..d905810d66 100644 --- a/modules/mono/glue/collections_glue.cpp +++ b/modules/mono/glue/collections_glue.cpp @@ -86,7 +86,7 @@ bool godot_icall_Array_Contains(Array *ptr, MonoObject *item) { } void godot_icall_Array_CopyTo(Array *ptr, MonoArray *array, int array_index) { - int count = ptr->size(); + unsigned int count = ptr->size(); if (mono_array_length(array) < (array_index + count)) { MonoException *exc = mono_get_exception_argument("", "Destination array was not long enough. Check destIndex and length, and the array's lower bounds."); @@ -94,7 +94,7 @@ void godot_icall_Array_CopyTo(Array *ptr, MonoArray *array, int array_index) { return; } - for (int i = 0; i < count; i++) { + for (unsigned int i = 0; i < count; i++) { MonoObject *boxed = GDMonoMarshal::variant_to_mono_object(ptr->operator[](i)); mono_array_setref(array, array_index, boxed); array_index++; diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index bba8b1050f..dfabfddd64 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -91,7 +91,7 @@ static bool _wait_for_debugger_msecs(uint32_t p_msecs) { OS::get_singleton()->delay_usec((p_msecs < 25 ? p_msecs : 25) * 1000); - int tdiff = OS::get_singleton()->get_ticks_msec() - last_tick; + uint32_t tdiff = OS::get_singleton()->get_ticks_msec() - last_tick; if (tdiff > p_msecs) { p_msecs = 0; @@ -864,7 +864,7 @@ Error GDMono::reload_scripts_domain() { metadata_set_api_assembly_invalidated(APIAssembly::API_EDITOR, true); } - Error err = _unload_scripts_domain(); + err = _unload_scripts_domain(); if (err != OK) { WARN_PRINT("Mono: Failed to unload scripts domain"); } diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp index 01e011e64c..82f323e8cf 100644 --- a/modules/pvr/texture_loader_pvr.cpp +++ b/modules/pvr/texture_loader_pvr.cpp @@ -216,7 +216,7 @@ static void _compress_pvrtc4(Image *p_img) { int ofs, size, w, h; img->get_mipmap_offset_size_and_dimensions(i, ofs, size, w, h); Javelin::RgbaBitmap bm(w, h); - for (unsigned j = 0; j < size / 4; j++) { + for (int j = 0; j < size / 4; j++) { Javelin::ColorRgba<unsigned char> *dp = bm.GetData(); /* red and Green colors are swapped. */ new (dp) Javelin::ColorRgba<unsigned char>(r[ofs + 4 * j + 2], r[ofs + 4 * j + 1], r[ofs + 4 * j], r[ofs + 4 * j + 3]); diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp index fa7b13bf5b..ac5f73d113 100644 --- a/modules/visual_script/visual_script_property_selector.cpp +++ b/modules/visual_script/visual_script_property_selector.cpp @@ -421,7 +421,7 @@ void VisualScriptPropertySelector::get_visual_node_names(const String &root_filt } Vector<String> desc = path[path.size() - 1].replace("(", "( ").replace(")", " )").replace(",", ", ").split(" "); - for (size_t i = 0; i < desc.size(); i++) { + for (int i = 0; i < desc.size(); i++) { desc.write[i] = desc[i].capitalize(); if (desc[i].ends_with(",")) { desc.write[i] = desc[i].replace(",", ", "); diff --git a/modules/websocket/packet_buffer.h b/modules/websocket/packet_buffer.h index 5794288c2b..47786a87a6 100644 --- a/modules/websocket/packet_buffer.h +++ b/modules/websocket/packet_buffer.h @@ -50,7 +50,7 @@ public: Error write_packet(const uint8_t *p_payload, uint32_t p_size, const T *p_info) { #ifdef TOOLS_ENABLED // Verbose buffer warnings - if (p_payload && _payload.space_left() < p_size) { + if (p_payload && _payload.space_left() < (int32_t)p_size) { ERR_PRINT("Buffer payload full! Dropping data."); ERR_FAIL_V(ERR_OUT_OF_MEMORY); } @@ -83,8 +83,8 @@ public: ERR_FAIL_COND_V(_packets.data_left() < 1, ERR_UNAVAILABLE); _Packet p; _packets.read(&p, 1); - ERR_FAIL_COND_V(_payload.data_left() < p.size, ERR_BUG); - ERR_FAIL_COND_V(p_bytes < p.size, ERR_OUT_OF_MEMORY); + ERR_FAIL_COND_V(_payload.data_left() < (int)p.size, ERR_BUG); + ERR_FAIL_COND_V(p_bytes < (int)p.size, ERR_OUT_OF_MEMORY); r_read = p.size; copymem(r_info, &p.info, sizeof(T)); diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp index a48738b6a4..6aab8a7e81 100644 --- a/modules/websocket/websocket_multiplayer_peer.cpp +++ b/modules/websocket/websocket_multiplayer_peer.cpp @@ -213,7 +213,7 @@ void WebSocketMultiplayerPeer::_send_add(int32_t p_peer_id) { _send_sys(get_peer(p_peer_id), SYS_ADD, 1); for (Map<int, Ref<WebSocketPeer> >::Element *E = _peer_map.front(); E; E = E->next()) { - uint32_t id = E->key(); + int32_t id = E->key(); if (p_peer_id == id) continue; // Skip the newwly added peer (already confirmed) @@ -226,7 +226,7 @@ void WebSocketMultiplayerPeer::_send_add(int32_t p_peer_id) { void WebSocketMultiplayerPeer::_send_del(int32_t p_peer_id) { for (Map<int, Ref<WebSocketPeer> >::Element *E = _peer_map.front(); E; E = E->next()) { - uint32_t id = E->key(); + int32_t id = E->key(); if (p_peer_id != id) _send_sys(get_peer(id), SYS_DEL, p_peer_id); } @@ -288,7 +288,7 @@ void WebSocketMultiplayerPeer::_process_multiplayer(Ref<WebSocketPeer> p_peer, u data_size = size - PROTO_SIZE; uint8_t type = 0; - int32_t from = 0; + uint32_t from = 0; int32_t to = 0; copymem(&type, in_buffer, 1); copymem(&from, &in_buffer[1], 4); diff --git a/modules/xatlas_unwrap/register_types.cpp b/modules/xatlas_unwrap/register_types.cpp index 840dd371ac..903b57f017 100644 --- a/modules/xatlas_unwrap/register_types.cpp +++ b/modules/xatlas_unwrap/register_types.cpp @@ -108,7 +108,7 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver float max_x = 0; float max_y = 0; - for (int i = 0; i < output->vertexCount; i++) { + for (uint32_t i = 0; i < output->vertexCount; i++) { (*r_vertex)[i] = output->vertexArray[i].xref; (*r_uv)[i * 2 + 0] = output->vertexArray[i].uv[0] / w; (*r_uv)[i * 2 + 1] = output->vertexArray[i].uv[1] / h; @@ -119,7 +119,7 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver printf("final texsize: %f,%f - max %f,%f\n", w, h, max_x, max_y); *r_vertex_count = output->vertexCount; - for (int i = 0; i < output->indexCount; i++) { + for (uint32_t i = 0; i < output->indexCount; i++) { (*r_index)[i] = output->indexArray[i]; } |