From f50488a36188d5975bfa8554687a1acdd394d6a9 Mon Sep 17 00:00:00 2001 From: Thaer Razeq Date: Thu, 23 Feb 2017 02:28:09 -0600 Subject: Various fixes detected using PVS-Studio static analyzer. - Add FIXME tags comments to some unfixed potential bugs - Remove some checks (always false: unsigned never < 0) - Fix some if statements based on reviews. - Bunch of missing `else` statements --- core/io/http_client.cpp | 2 +- core/io/marshalls.cpp | 4 ---- core/io/stream_peer.cpp | 2 ++ 3 files changed, 3 insertions(+), 5 deletions(-) (limited to 'core/io') diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 5c54f16f13..ae14f8fa38 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -340,7 +340,7 @@ Error HTTPClient::poll(){ int rs = response_str.size(); if ( (rs>=2 && response_str[rs-2]=='\n' && response_str[rs-1]=='\n') || - (rs>=4 && response_str[rs-4]=='\r' && response_str[rs-3]=='\n' && rs>=4 && response_str[rs-2]=='\r' && response_str[rs-1]=='\n') + (rs>=4 && response_str[rs-4]=='\r' && response_str[rs-3]=='\n' && response_str[rs-2]=='\r' && response_str[rs-1]=='\n') ) { diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index e958edc93e..a8c1cd0a10 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -641,7 +641,6 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int * ERR_FAIL_COND_V(len<4,ERR_INVALID_DATA); uint32_t count = decode_uint32(buf); - ERR_FAIL_COND_V(count<0,ERR_INVALID_DATA); PoolVector strings; buf+=4; @@ -691,7 +690,6 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int * ERR_FAIL_COND_V(len<4,ERR_INVALID_DATA); uint32_t count = decode_uint32(buf); - ERR_FAIL_COND_V(count<0,ERR_INVALID_DATA); buf+=4; len-=4; @@ -729,7 +727,6 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int * ERR_FAIL_COND_V(len<4,ERR_INVALID_DATA); uint32_t count = decode_uint32(buf); - ERR_FAIL_COND_V(count<0,ERR_INVALID_DATA); buf+=4; len-=4; @@ -768,7 +765,6 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int * ERR_FAIL_COND_V(len<4,ERR_INVALID_DATA); uint32_t count = decode_uint32(buf); - ERR_FAIL_COND_V(count<0,ERR_INVALID_DATA); buf+=4; len-=4; diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp index a64ebf21fb..3c4719269f 100644 --- a/core/io/stream_peer.cpp +++ b/core/io/stream_peer.cpp @@ -492,6 +492,8 @@ Error StreamPeerBuffer::get_partial_data(uint8_t* p_buffer, int p_bytes,int &r_r PoolVector::Read r = data.read(); copymem(p_buffer,r.ptr(),r_received); + + // FIXME: return what? OK or ERR_* } int StreamPeerBuffer::get_available_bytes() const { -- cgit v1.2.3