summaryrefslogtreecommitdiff
path: root/core/io
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2022-09-29 12:53:28 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2022-10-07 11:32:33 +0300
commit0103af1ddda6a2aa31227965141dd7d3a513e081 (patch)
treeb0965bb65919bc1495ee02204a91e5ed3a9b56a7 /core/io
parent5b7f62af55b7f322192f95258d825b163cbf9dc1 (diff)
Fix MSVC warnings, rename shadowed variables, fix uninitialized values, change warnings=all to use /W4.
Diffstat (limited to 'core/io')
-rw-r--r--core/io/file_access_encrypted.cpp8
-rw-r--r--core/io/file_access_network.cpp8
-rw-r--r--core/io/http_client_tcp.cpp20
-rw-r--r--core/io/image.cpp10
-rw-r--r--core/io/image_loader.cpp2
-rw-r--r--core/io/resource_format_binary.cpp20
-rw-r--r--core/io/resource_importer.cpp4
-rw-r--r--core/io/resource_loader.cpp8
-rw-r--r--core/io/resource_saver.cpp4
-rw-r--r--core/io/stream_peer_tcp.cpp4
-rw-r--r--core/io/stream_peer_tcp.h2
11 files changed, 44 insertions, 46 deletions
diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp
index be502dacd9..e7b2a2dfee 100644
--- a/core/io/file_access_encrypted.cpp
+++ b/core/io/file_access_encrypted.cpp
@@ -102,13 +102,13 @@ Error FileAccessEncrypted::open_and_parse(Ref<FileAccess> p_base, const Vector<u
Error FileAccessEncrypted::open_and_parse_password(Ref<FileAccess> p_base, const String &p_key, Mode p_mode) {
String cs = p_key.md5_text();
ERR_FAIL_COND_V(cs.length() != 32, ERR_INVALID_PARAMETER);
- Vector<uint8_t> key;
- key.resize(32);
+ Vector<uint8_t> key_md5;
+ key_md5.resize(32);
for (int i = 0; i < 32; i++) {
- key.write[i] = cs[i];
+ key_md5.write[i] = cs[i];
}
- return open_and_parse(p_base, key, p_mode);
+ return open_and_parse(p_base, key_md5, p_mode);
}
Error FileAccessEncrypted::open_internal(const String &p_path, int p_mode_flags) {
diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp
index 13730518bf..87f3f66597 100644
--- a/core/io/file_access_network.cpp
+++ b/core/io/file_access_network.cpp
@@ -137,12 +137,12 @@ void FileAccessNetworkClient::_thread_func() {
int64_t offset = get_64();
int32_t len = get_32();
- Vector<uint8_t> block;
- block.resize(len);
- client->get_data(block.ptrw(), len);
+ Vector<uint8_t> resp_block;
+ resp_block.resize(len);
+ client->get_data(resp_block.ptrw(), len);
if (fa) { //may have been queued
- fa->_set_block(offset, block);
+ fa->_set_block(offset, resp_block);
}
} break;
diff --git a/core/io/http_client_tcp.cpp b/core/io/http_client_tcp.cpp
index 5c1d00a330..aff79320ca 100644
--- a/core/io/http_client_tcp.cpp
+++ b/core/io/http_client_tcp.cpp
@@ -358,38 +358,38 @@ Error HTTPClientTCP::poll() {
} break;
}
} else if (tls) {
- Ref<StreamPeerTLS> tls;
+ Ref<StreamPeerTLS> tls_conn;
if (!handshaking) {
// Connect the StreamPeerTLS and start handshaking.
- tls = Ref<StreamPeerTLS>(StreamPeerTLS::create());
- tls->set_blocking_handshake_enabled(false);
- Error err = tls->connect_to_stream(tcp_connection, tls_verify_host, conn_host);
+ tls_conn = Ref<StreamPeerTLS>(StreamPeerTLS::create());
+ tls_conn->set_blocking_handshake_enabled(false);
+ Error err = tls_conn->connect_to_stream(tcp_connection, tls_verify_host, conn_host);
if (err != OK) {
close();
status = STATUS_TLS_HANDSHAKE_ERROR;
return ERR_CANT_CONNECT;
}
- connection = tls;
+ connection = tls_conn;
handshaking = true;
} else {
// We are already handshaking, which means we can use your already active TLS connection.
- tls = static_cast<Ref<StreamPeerTLS>>(connection);
- if (tls.is_null()) {
+ tls_conn = static_cast<Ref<StreamPeerTLS>>(connection);
+ if (tls_conn.is_null()) {
close();
status = STATUS_TLS_HANDSHAKE_ERROR;
return ERR_CANT_CONNECT;
}
- tls->poll(); // Try to finish the handshake.
+ tls_conn->poll(); // Try to finish the handshake.
}
- if (tls->get_status() == StreamPeerTLS::STATUS_CONNECTED) {
+ if (tls_conn->get_status() == StreamPeerTLS::STATUS_CONNECTED) {
// Handshake has been successful.
handshaking = false;
ip_candidates.clear();
status = STATUS_CONNECTED;
return OK;
- } else if (tls->get_status() != StreamPeerTLS::STATUS_HANDSHAKING) {
+ } else if (tls_conn->get_status() != StreamPeerTLS::STATUS_HANDSHAKING) {
// Handshake has failed.
close();
status = STATUS_TLS_HANDSHAKE_ERROR;
diff --git a/core/io/image.cpp b/core/io/image.cpp
index 56c05bf042..4be624a5a8 100644
--- a/core/io/image.cpp
+++ b/core/io/image.cpp
@@ -3869,15 +3869,15 @@ Dictionary Image::compute_image_metrics(const Ref<Image> p_compared_image, bool
double image_metric_max, image_metric_mean, image_metric_mean_squared, image_metric_root_mean_squared, image_metric_peak_snr = 0.0;
const bool average_component_error = true;
- const uint32_t width = MIN(compared_image->get_width(), source_image->get_width());
- const uint32_t height = MIN(compared_image->get_height(), source_image->get_height());
+ const uint32_t w = MIN(compared_image->get_width(), source_image->get_width());
+ const uint32_t h = MIN(compared_image->get_height(), source_image->get_height());
// Histogram approach originally due to Charles Bloom.
double hist[256];
memset(hist, 0, sizeof(hist));
- for (uint32_t y = 0; y < height; y++) {
- for (uint32_t x = 0; x < width; x++) {
+ for (uint32_t y = 0; y < h; y++) {
+ for (uint32_t x = 0; x < w; x++) {
const Color color_a = compared_image->get_pixel(x, y);
const Color color_b = source_image->get_pixel(x, y);
@@ -3922,7 +3922,7 @@ Dictionary Image::compute_image_metrics(const Ref<Image> p_compared_image, bool
}
// See http://richg42.blogspot.com/2016/09/how-to-compute-psnr-from-old-berkeley.html
- double total_values = width * height;
+ double total_values = w * h;
if (average_component_error) {
total_values *= 4;
diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp
index d6854666c0..397984a2ab 100644
--- a/core/io/image_loader.cpp
+++ b/core/io/image_loader.cpp
@@ -51,7 +51,7 @@ bool ImageFormatLoader::recognize(const String &p_extension) const {
}
Error ImageFormatLoaderExtension::load_image(Ref<Image> p_image, Ref<FileAccess> p_fileaccess, BitField<ImageFormatLoader::LoaderFlags> p_flags, float p_scale) {
- Error err;
+ Error err = ERR_UNAVAILABLE;
if (GDVIRTUAL_CALL(_load_image, p_image, p_fileaccess, p_flags, p_scale, err)) {
return err;
}
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 9ab45f85b8..2a79067e02 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -169,10 +169,10 @@ StringName ResourceLoaderBinary::_get_string() {
}
Error ResourceLoaderBinary::parse_variant(Variant &r_v) {
- uint32_t type = f->get_32();
- print_bl("find property of type: " + itos(type));
+ uint32_t prop_type = f->get_32();
+ print_bl("find property of type: " + itos(prop_type));
- switch (type) {
+ switch (prop_type) {
case VARIANT_NIL: {
r_v = Variant();
} break;
@@ -1100,16 +1100,14 @@ String ResourceLoaderBinary::recognize(Ref<FileAccess> p_f) {
uint32_t ver_major = f->get_32();
f->get_32(); // ver_minor
- uint32_t ver_format = f->get_32();
+ uint32_t ver_fmt = f->get_32();
- if (ver_format > FORMAT_VERSION || ver_major > VERSION_MAJOR) {
+ if (ver_fmt > FORMAT_VERSION || ver_major > VERSION_MAJOR) {
f.unref();
return "";
}
- String type = get_unicode_string();
-
- return type;
+ return get_unicode_string();
}
Ref<Resource> ResourceFormatLoaderBinary::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) {
@@ -2118,9 +2116,9 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const Ref<Re
for (int i = 0; i < save_order.size(); i++) {
save_unicode_string(f, save_order[i]->get_save_class());
- String path = save_order[i]->get_path();
- path = relative_paths ? local_path.path_to_file(path) : path;
- save_unicode_string(f, path);
+ String res_path = save_order[i]->get_path();
+ res_path = relative_paths ? local_path.path_to_file(res_path) : res_path;
+ save_unicode_string(f, res_path);
ResourceUID::ID ruid = ResourceSaver::get_resource_id_for_path(save_order[i]->get_path(), false);
f->store_64(ruid);
}
diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp
index d923522317..564b37e662 100644
--- a/core/io/resource_importer.cpp
+++ b/core/io/resource_importer.cpp
@@ -110,8 +110,8 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy
#ifdef TOOLS_ENABLED
if (r_path_and_type.metadata && !r_path_and_type.path.is_empty()) {
- Dictionary metadata = r_path_and_type.metadata;
- if (metadata.has("has_editor_variant")) {
+ Dictionary meta = r_path_and_type.metadata;
+ if (meta.has("has_editor_variant")) {
r_path_and_type.path = r_path_and_type.path.get_basename() + ".editor." + r_path_and_type.path.get_extension();
}
}
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index eccb397e2e..a018221b7f 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -68,7 +68,7 @@ bool ResourceFormatLoader::recognize_path(const String &p_path, const String &p_
}
bool ResourceFormatLoader::handles_type(const String &p_type) const {
- bool success;
+ bool success = false;
if (GDVIRTUAL_CALL(_handles_type, p_type, success)) {
return success;
}
@@ -102,7 +102,7 @@ String ResourceFormatLoader::get_resource_type(const String &p_path) const {
}
ResourceUID::ID ResourceFormatLoader::get_resource_uid(const String &p_path) const {
- int64_t uid;
+ int64_t uid = ResourceUID::INVALID_ID;
if (GDVIRTUAL_CALL(_get_resource_uid, p_path, uid)) {
return uid;
}
@@ -123,7 +123,7 @@ void ResourceLoader::get_recognized_extensions_for_type(const String &p_type, Li
}
bool ResourceFormatLoader::exists(const String &p_path) const {
- bool success;
+ bool success = false;
if (GDVIRTUAL_CALL(_exists, p_path, success)) {
return success;
}
@@ -175,7 +175,7 @@ Error ResourceFormatLoader::rename_dependencies(const String &p_path, const Hash
deps_dict[E.key] = E.value;
}
- int64_t err;
+ int64_t err = OK;
if (GDVIRTUAL_CALL(_rename_dependencies, p_path, deps_dict, err)) {
return (Error)err;
}
diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp
index 386ccb78e9..2f863baaac 100644
--- a/core/io/resource_saver.cpp
+++ b/core/io/resource_saver.cpp
@@ -42,7 +42,7 @@ ResourceSavedCallback ResourceSaver::save_callback = nullptr;
ResourceSaverGetResourceIDForPath ResourceSaver::save_get_id_for_path = nullptr;
Error ResourceFormatSaver::save(const Ref<Resource> &p_resource, const String &p_path, uint32_t p_flags) {
- int64_t res;
+ int64_t res = ERR_METHOD_NOT_FOUND;
if (GDVIRTUAL_CALL(_save, p_resource, p_path, p_flags, res)) {
return (Error)res;
}
@@ -51,7 +51,7 @@ Error ResourceFormatSaver::save(const Ref<Resource> &p_resource, const String &p
}
bool ResourceFormatSaver::recognize(const Ref<Resource> &p_resource) const {
- bool success;
+ bool success = false;
if (GDVIRTUAL_CALL(_recognize, p_resource, success)) {
return success;
}
diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp
index ba79590c19..e035e1b613 100644
--- a/core/io/stream_peer_tcp.cpp
+++ b/core/io/stream_peer_tcp.cpp
@@ -256,9 +256,9 @@ void StreamPeerTCP::disconnect_from_host() {
peer_port = 0;
}
-Error StreamPeerTCP::wait(NetSocket::PollType p_type, int timeout) {
+Error StreamPeerTCP::wait(NetSocket::PollType p_type, int p_timeout) {
ERR_FAIL_COND_V(_sock.is_null() || !_sock->is_open(), ERR_UNAVAILABLE);
- return _sock->poll(p_type, timeout);
+ return _sock->poll(p_type, p_timeout);
}
Error StreamPeerTCP::put_data(const uint8_t *p_data, int p_bytes) {
diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h
index 39c2e84346..778fb83374 100644
--- a/core/io/stream_peer_tcp.h
+++ b/core/io/stream_peer_tcp.h
@@ -79,7 +79,7 @@ public:
Error poll();
// Wait or check for writable, readable.
- Error wait(NetSocket::PollType p_type, int timeout = 0);
+ Error wait(NetSocket::PollType p_type, int p_timeout = 0);
// Read/Write from StreamPeer
Error put_data(const uint8_t *p_data, int p_bytes) override;