summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorHein-Pieter van Braam <hp@tmm.cx>2017-08-31 23:30:35 +0200
committerHein-Pieter van Braam <hp@tmm.cx>2017-09-01 08:13:12 +0200
commitf9467ec1ea6c0dac2ea513b7dfe58d0349788e02 (patch)
tree05421200fdd55c97b3b60895597f487d8ac51afa /modules
parent51ae90d7893fd392dd8938cc41c52081e5065794 (diff)
Fix signed and unsigned comparisons
The first in my quest to make Godot 3.x compile with -Werror on GCC7
Diffstat (limited to 'modules')
-rw-r--r--modules/etc/image_etc.cpp2
-rw-r--r--modules/gdnative/godot/array.cpp14
-rw-r--r--modules/gdnative/godot/pool_arrays.cpp14
-rw-r--r--modules/regex/regex.cpp6
-rw-r--r--modules/tga/image_loader_tga.cpp10
5 files changed, 23 insertions, 23 deletions
diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp
index 9a15beb6eb..e86fd06d81 100644
--- a/modules/etc/image_etc.cpp
+++ b/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);
diff --git a/modules/gdnative/godot/array.cpp b/modules/gdnative/godot/array.cpp
index c15ba30ca2..c3fde0e954 100644
--- a/modules/gdnative/godot/array.cpp
+++ b/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;
}
diff --git a/modules/gdnative/godot/pool_arrays.cpp b/modules/gdnative/godot/pool_arrays.cpp
index 2e533077f6..49bf851051 100644
--- a/modules/gdnative/godot/pool_arrays.cpp
+++ b/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]);
}
}
diff --git a/modules/regex/regex.cpp b/modules/regex/regex.cpp
index 8afd01e20b..00e8ce0f54 100644
--- a/modules/regex/regex.cpp
+++ b/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) {
diff --git a/modules/tga/image_loader_tga.cpp b/modules/tga/image_loader_tga.cpp
index 379c894550..8b1d422ce2 100644
--- a/modules/tga/image_loader_tga.cpp
+++ b/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;