summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorypostolov <ypostolov@luxoft.com>2020-01-09 19:55:14 +0200
committeryurii <ypostolov>2020-03-26 15:02:49 +0200
commit995cf8265b9483d99fae5cf7d73ba70a2a310ceb (patch)
tree88f8423976086eb035c434aec0a0ba53f6db7071
parent7a9b3deb055506341454bf9af35fd67f9f8aee3a (diff)
downloadsdl_core-995cf8265b9483d99fae5cf7d73ba70a2a310ceb.tar.gz
fix cppcheck issues in component protocol_handler
-rw-r--r--src/components/protocol_handler/src/incoming_data_handler.cc2
-rw-r--r--src/components/protocol_handler/src/protocol_handler_impl.cc6
-rw-r--r--src/components/protocol_handler/src/protocol_payload.cc1
-rw-r--r--src/components/protocol_handler/test/incoming_data_handler_test.cc1
-rw-r--r--src/components/protocol_handler/test/multiframe_builder_test.cc1
-rw-r--r--src/components/protocol_handler/test/protocol_handler_tm_test.cc1
-rw-r--r--src/components/protocol_handler/test/protocol_header_validator_test.cc1
-rw-r--r--src/components/protocol_handler/test/protocol_packet_test.cc1
-rw-r--r--src/components/protocol_handler/test/protocol_payload_test.cc1
-rw-r--r--src/components/protocol_handler/test/service_status_update_handler_test.cc1
10 files changed, 12 insertions, 4 deletions
diff --git a/src/components/protocol_handler/src/incoming_data_handler.cc b/src/components/protocol_handler/src/incoming_data_handler.cc
index 566b36f46d..568d3e65fd 100644
--- a/src/components/protocol_handler/src/incoming_data_handler.cc
+++ b/src/components/protocol_handler/src/incoming_data_handler.cc
@@ -167,7 +167,7 @@ RESULT_CODE IncomingDataHandler::CreateFrame(
}
LOG4CXX_DEBUG(logger_, "Payload size " << header_.dataSize);
const uint32_t packet_size = GetPacketSize(header_);
- if (packet_size <= 0) {
+ if (packet_size == 0) {
LOG4CXX_WARN(logger_, "Null packet size");
++data_it;
--data_size;
diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc
index 04c1529573..32f8437d92 100644
--- a/src/components/protocol_handler/src/protocol_handler_impl.cc
+++ b/src/components/protocol_handler/src/protocol_handler_impl.cc
@@ -1214,7 +1214,7 @@ void ProtocolHandlerImpl::OnTransportConfigUpdated(
if (st.secondary_transport != kDisabledSecondary) {
SendTransportUpdateEvent(st.primary_transport, itr->first);
}
- itr++;
+ ++itr;
}
}
@@ -2553,7 +2553,7 @@ void ProtocolHandlerImpl::GenerateSecondaryTransportsForStartSessionAck(
secondaryTransports.push_back("TCP_WIFI");
}
- it++;
+ ++it;
}
}
@@ -2580,7 +2580,7 @@ void ProtocolHandlerImpl::GenerateServiceTransportsForStartSessionAck(
bool fPrimaryAdded = false;
bool fSecondaryAdded = false;
std::vector<std::string>::const_iterator it = service_transports.begin();
- for (; it != service_transports.end(); it++) {
+ for (; it != service_transports.end(); ++it) {
const utils::custom_string::CustomString transport(*it);
LOG4CXX_TRACE(
logger_,
diff --git a/src/components/protocol_handler/src/protocol_payload.cc b/src/components/protocol_handler/src/protocol_payload.cc
index 8916fe91b0..8b25185715 100644
--- a/src/components/protocol_handler/src/protocol_payload.cc
+++ b/src/components/protocol_handler/src/protocol_payload.cc
@@ -93,6 +93,7 @@ std::ostream& operator<<(std::ostream& os, const ProtocolPayloadV2& payload) {
<< ", data (bytes): " << payload.data.size() << ")";
}
+// cppcheck-suppress unusedFunction
size_t ProtocolPayloadV2SizeBits() {
return PayloadHeaderBits;
}
diff --git a/src/components/protocol_handler/test/incoming_data_handler_test.cc b/src/components/protocol_handler/test/incoming_data_handler_test.cc
index a187fe6cb5..103ebb4297 100644
--- a/src/components/protocol_handler/test/incoming_data_handler_test.cc
+++ b/src/components/protocol_handler/test/incoming_data_handler_test.cc
@@ -102,6 +102,7 @@ class IncomingDataHandlerTest : public ::testing::Test {
std::vector<uint8_t> payload_bigger_mtu;
};
+// cppcheck-suppress syntaxError
TEST_F(IncomingDataHandlerTest, NullData) {
ProcessData(uid1, NULL, 0);
EXPECT_EQ(RESULT_FAIL, result_code);
diff --git a/src/components/protocol_handler/test/multiframe_builder_test.cc b/src/components/protocol_handler/test/multiframe_builder_test.cc
index 2859aeb8ae..bc75e816d0 100644
--- a/src/components/protocol_handler/test/multiframe_builder_test.cc
+++ b/src/components/protocol_handler/test/multiframe_builder_test.cc
@@ -264,6 +264,7 @@ class MultiFrameBuilderTest : public ::testing::Test {
size_t MultiFrameBuilderTest::mtu_ = 10;
+// cppcheck-suppress syntaxError
TEST_F(MultiFrameBuilderTest, Pop_Frames_From_Empty_builder) {
EXPECT_EQ(ProtocolFramePtrList(), multiframe_builder_.PopMultiframes());
}
diff --git a/src/components/protocol_handler/test/protocol_handler_tm_test.cc b/src/components/protocol_handler/test/protocol_handler_tm_test.cc
index 07b562f3a2..1697301e4f 100644
--- a/src/components/protocol_handler/test/protocol_handler_tm_test.cc
+++ b/src/components/protocol_handler/test/protocol_handler_tm_test.cc
@@ -146,6 +146,7 @@ typedef std::shared_ptr<
MockServiceStatusUpdateHandlerListenerPtr;
// custom action to call a member function with 6 arguments
+// cppcheck-suppress syntaxError
ACTION_P4(InvokeMemberFuncWithArg2, ptr, memberFunc, a, b) {
(ptr->*memberFunc)(a, b);
}
diff --git a/src/components/protocol_handler/test/protocol_header_validator_test.cc b/src/components/protocol_handler/test/protocol_header_validator_test.cc
index ee48d2eb3d..dd8acd3c98 100644
--- a/src/components/protocol_handler/test/protocol_header_validator_test.cc
+++ b/src/components/protocol_handler/test/protocol_header_validator_test.cc
@@ -58,6 +58,7 @@ class ProtocolHeaderValidatorTest : public ::testing::Test {
};
// Protocol version shall be from 1 to 5
+// cppcheck-suppress syntaxError
TEST_F(ProtocolHeaderValidatorTest, MaxPayloadSizeSetGet) {
EXPECT_EQ(std::numeric_limits<size_t>::max(),
header_validator.max_payload_size());
diff --git a/src/components/protocol_handler/test/protocol_packet_test.cc b/src/components/protocol_handler/test/protocol_packet_test.cc
index e4ea4be61f..f787e5c62b 100644
--- a/src/components/protocol_handler/test/protocol_packet_test.cc
+++ b/src/components/protocol_handler/test/protocol_packet_test.cc
@@ -97,6 +97,7 @@ class ProtocolPacketTest : public ::testing::Test {
ConnectionID some_connection_id_;
};
+// cppcheck-suppress syntaxError
TEST_F(ProtocolPacketTest, SerializePacketWithDiffVersions) {
uint8_t version = PROTOCOL_VERSION_1;
for (; version <= PROTOCOL_VERSION_MAX; ++version) {
diff --git a/src/components/protocol_handler/test/protocol_payload_test.cc b/src/components/protocol_handler/test/protocol_payload_test.cc
index e89e6c7395..dedde15097 100644
--- a/src/components/protocol_handler/test/protocol_payload_test.cc
+++ b/src/components/protocol_handler/test/protocol_payload_test.cc
@@ -82,6 +82,7 @@ void prepare_data(uint8_t* data_for_sending, ProtocolPayloadV2& message) {
}
}
+// cppcheck-suppress syntaxError
TEST(ProtocolPayloadTest, ExtractProtocolWithOnlyHeader) {
ProtocolPayloadV2 prot_payload_test;
diff --git a/src/components/protocol_handler/test/service_status_update_handler_test.cc b/src/components/protocol_handler/test/service_status_update_handler_test.cc
index 7d4516a7ff..882ea05727 100644
--- a/src/components/protocol_handler/test/service_status_update_handler_test.cc
+++ b/src/components/protocol_handler/test/service_status_update_handler_test.cc
@@ -198,6 +198,7 @@ INSTANTIATE_TEST_CASE_P(
ServiceStatus::PROTECTION_DISABLED),
ServiceUpdate(ServiceType::kRpc, ServiceStatus::PROTECTION_DISABLED)));
+// cppcheck-suppress syntaxError
TEST_P(ServiceStatusUpdateHandlerTest, OnServiceUpdate) {
auto service_event_ = GetServiceEvent(GetParam().service_status_);
auto reason_ = GetUpdateReason(GetParam().service_status_);