summaryrefslogtreecommitdiff
path: root/core/io
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 /core/io
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 'core/io')
-rw-r--r--core/io/file_access_compressed.h10
-rw-r--r--core/io/file_access_encrypted.cpp4
-rw-r--r--core/io/file_access_encrypted.h2
-rw-r--r--core/io/file_access_network.cpp4
-rw-r--r--core/io/file_access_network.h4
-rw-r--r--core/io/marshalls.cpp10
-rw-r--r--core/io/resource_format_binary.cpp6
-rw-r--r--core/io/xml_parser.cpp2
-rw-r--r--core/io/xml_parser.h2
9 files changed, 22 insertions, 22 deletions
diff --git a/core/io/file_access_compressed.h b/core/io/file_access_compressed.h
index 2fe1428752..ba84c9767c 100644
--- a/core/io/file_access_compressed.h
+++ b/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;
diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp
index cf82d04ac5..12503f3be4 100644
--- a/core/io/file_access_encrypted.cpp
+++ b/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;
diff --git a/core/io/file_access_encrypted.h b/core/io/file_access_encrypted.h
index 3df2806a7a..74d00a5a8f 100644
--- a/core/io/file_access_encrypted.h
+++ b/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:
diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp
index be31076557..d8b8c8c200 100644
--- a/core/io/file_access_network.cpp
+++ b/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();
diff --git a/core/io/file_access_network.h b/core/io/file_access_network.h
index d6010cdbac..cd5046f007 100644
--- a/core/io/file_access_network.h
+++ b/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 {
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index af7db904e9..0834d6c321 100644
--- a/core/io/marshalls.cpp
+++ b/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]);
}
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index f44492248e..d090d7a20b 100644
--- a/core/io/resource_format_binary.cpp
+++ b/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 {
diff --git a/core/io/xml_parser.cpp b/core/io/xml_parser.cpp
index 62110bfe24..3a4be7cd13 100644
--- a/core/io/xml_parser.cpp
+++ b/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;
}
diff --git a/core/io/xml_parser.h b/core/io/xml_parser.h
index 28c57b567f..26616ed94a 100644
--- a/core/io/xml_parser.h
+++ b/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;