summaryrefslogtreecommitdiff
path: root/core/io
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-06-27 01:05:18 +0200
committerGitHub <noreply@github.com>2019-06-27 01:05:18 +0200
commiteaaff9da3178fa515a0f051fda932c1dd04d53db (patch)
tree56173535c376e0324f89baccf4bc14b2580ead23 /core/io
parentd8c96461183f0dc3208c3d624674fa4544212ea5 (diff)
parent4e5310cc60dc17e5ef09e57115ca8236544679e4 (diff)
Merge pull request #29941 from qarmin/redundant_code_and_others
Remove redundant code, possible NULL pointers and others
Diffstat (limited to 'core/io')
-rw-r--r--core/io/file_access_network.cpp1
-rw-r--r--core/io/http_client.cpp2
-rw-r--r--core/io/marshalls.cpp7
-rw-r--r--core/io/multiplayer_api.h2
-rw-r--r--core/io/pck_packer.cpp5
-rw-r--r--core/io/resource_format_binary.cpp4
-rw-r--r--core/io/stream_peer_tcp.cpp1
-rw-r--r--core/io/tcp_server.cpp6
8 files changed, 6 insertions, 22 deletions
diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp
index 5dd167c581..d1c7f5c334 100644
--- a/core/io/file_access_network.cpp
+++ b/core/io/file_access_network.cpp
@@ -435,7 +435,6 @@ int FileAccessNetwork::get_buffer(uint8_t *p_dst, int p_length) const {
_queue_page(page + j);
}
- buff = pages.write[page].buffer.ptrw();
//queue pages
buffer_mutex->unlock();
}
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp
index 891fb7b0ca..c3626bfe31 100644
--- a/core/io/http_client.cpp
+++ b/core/io/http_client.cpp
@@ -775,7 +775,7 @@ Dictionary HTTPClient::_get_response_headers_as_dictionary() {
get_response_headers(&rh);
Dictionary ret;
for (const List<String>::Element *E = rh.front(); E; E = E->next()) {
- String s = E->get();
+ const String &s = E->get();
int sp = s.find(":");
if (sp == -1)
continue;
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 3c9c5bc2bb..17a3f52a65 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -683,8 +683,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
if (r_len)
(*r_len) += adv;
- len -= adv;
- buf += adv;
}
r_variant = varray;
@@ -721,8 +719,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
if (r_len)
(*r_len) += adv;
- len -= adv;
- buf += adv;
}
r_variant = varray;
@@ -760,8 +756,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
if (r_len)
(*r_len) += adv;
- len -= adv;
- buf += adv;
}
r_variant = carray;
@@ -1094,7 +1088,6 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
if (!obj) {
if (buf) {
encode_uint32(0, buf);
- buf += 4;
}
r_len += 4;
diff --git a/core/io/multiplayer_api.h b/core/io/multiplayer_api.h
index 779dd043bd..5258dde5d7 100644
--- a/core/io/multiplayer_api.h
+++ b/core/io/multiplayer_api.h
@@ -77,7 +77,7 @@ protected:
void _process_raw(int p_from, const uint8_t *p_packet, int p_packet_len);
void _send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p_set, const StringName &p_name, const Variant **p_arg, int p_argcount);
- bool _send_confirm_path(NodePath p_path, PathSentCache *psc, int p_from);
+ bool _send_confirm_path(NodePath p_path, PathSentCache *psc, int p_target);
public:
enum NetworkCommands {
diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp
index 8920bbfb81..55685a2d9a 100644
--- a/core/io/pck_packer.cpp
+++ b/core/io/pck_packer.cpp
@@ -109,10 +109,7 @@ Error PCKPacker::add_file(const String &p_file, const String &p_src) {
Error PCKPacker::flush(bool p_verbose) {
- if (!file) {
- ERR_FAIL_COND_V(!file, ERR_INVALID_PARAMETER);
- return ERR_INVALID_PARAMETER;
- };
+ ERR_FAIL_COND_V(!file, ERR_INVALID_PARAMETER);
// write the index
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index aef2dcfff3..688dfc21e5 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -720,7 +720,7 @@ Error ResourceInteractiveLoaderBinary::poll() {
error = ERR_FILE_CORRUPT;
memdelete(obj); //bye
ERR_EXPLAIN(local_path + ":Resource type in resource field not a resource, type is: " + obj->get_class());
- ERR_FAIL_COND_V(!r, ERR_FILE_CORRUPT);
+ ERR_FAIL_V(ERR_FILE_CORRUPT);
}
RES res = RES(r);
@@ -1694,7 +1694,7 @@ void ResourceFormatSaverBinaryInstance::_find_resources(const Variant &p_variant
int len = varray.size();
for (int i = 0; i < len; i++) {
- Variant v = varray.get(i);
+ const Variant &v = varray.get(i);
_find_resources(v);
}
diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp
index 45f3e46e35..bcdae343b8 100644
--- a/core/io/stream_peer_tcp.cpp
+++ b/core/io/stream_peer_tcp.cpp
@@ -352,7 +352,6 @@ void StreamPeerTCP::_bind_methods() {
StreamPeerTCP::StreamPeerTCP() :
_sock(Ref<NetSocket>(NetSocket::create())),
status(STATUS_NONE),
- peer_host(IP_Address()),
peer_port(0) {
}
diff --git a/core/io/tcp_server.cpp b/core/io/tcp_server.cpp
index 6599c4eb5b..be87f47d50 100644
--- a/core/io/tcp_server.cpp
+++ b/core/io/tcp_server.cpp
@@ -83,11 +83,7 @@ bool TCP_Server::is_connection_available() const {
return false;
Error err = _sock->poll(NetSocket::POLL_TYPE_IN, 0);
- if (err != OK) {
- return false;
- }
-
- return true;
+ return (err == OK);
}
Ref<StreamPeerTCP> TCP_Server::take_connection() {