summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2019-03-26 10:05:25 -0400
committerGitHub <noreply@github.com>2019-03-26 10:05:25 -0400
commit7bdc752cb8a1e6132d3319216170fed507dbabbc (patch)
tree9c3147982897114c3b5a54796e90600c120efb1e
parent65ed7ed46b8470e0aebab1464fff28cf686d04b5 (diff)
downloadsdl_core-7bdc752cb8a1e6132d3319216170fed507dbabbc.tar.gz
Coverity 5.1 Fixes (#2854)
* Coverity 5.1 Fixes - Check return values - Pass struct by reference - Cast value to match return type * Coverity: Unchecked dynamic cast * Fix missing not typo * Address comments * Address comment
-rw-r--r--src/components/application_manager/include/application_manager/event_engine/event.h24
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc26
-rw-r--r--src/components/include/test/transport_manager/mock_transport_manager.h2
-rw-r--r--src/components/include/transport_manager/transport_manager.h2
-rw-r--r--src/components/policy/policy_regular/src/sql_pt_representation.cc10
-rw-r--r--src/components/transport_manager/include/transport_manager/transport_manager_impl.h2
-rw-r--r--src/components/transport_manager/src/cloud/cloud_device.cc4
-rw-r--r--src/components/transport_manager/src/transport_manager_impl.cc2
8 files changed, 45 insertions, 27 deletions
diff --git a/src/components/application_manager/include/application_manager/event_engine/event.h b/src/components/application_manager/include/application_manager/event_engine/event.h
index cfd6e95693..14595cd293 100644
--- a/src/components/application_manager/include/application_manager/event_engine/event.h
+++ b/src/components/application_manager/include/application_manager/event_engine/event.h
@@ -131,9 +131,9 @@ int32_t Event::smart_object_function_id() const {
}
int32_t Event::smart_object_correlation_id() const {
- return response_so_.getElement(strings::params)
- .getElement(strings::correlation_id)
- .asInt();
+ return static_cast<int32_t>(response_so_.getElement(strings::params)
+ .getElement(strings::correlation_id)
+ .asInt());
}
int32_t Event::smart_object_type() const {
@@ -223,21 +223,21 @@ const smart_objects::SmartObject& MobileEvent::smart_object() const {
}
int32_t MobileEvent::smart_object_function_id() const {
- return response_so_.getElement(strings::params)
- .getElement(strings::function_id)
- .asInt();
+ return static_cast<int32_t>(response_so_.getElement(strings::params)
+ .getElement(strings::function_id)
+ .asInt());
}
int32_t MobileEvent::smart_object_correlation_id() const {
- return response_so_.getElement(strings::params)
- .getElement(strings::correlation_id)
- .asInt();
+ return static_cast<int32_t>(response_so_.getElement(strings::params)
+ .getElement(strings::correlation_id)
+ .asInt());
}
int32_t MobileEvent::smart_object_type() const {
- return response_so_.getElement(strings::params)
- .getElement(strings::message_type)
- .asInt();
+ return static_cast<int32_t>(response_so_.getElement(strings::params)
+ .getElement(strings::message_type)
+ .asInt());
}
} // namespace event_engine
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index 8a8671c167..51c10f6cc5 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -2942,9 +2942,9 @@ void ApplicationManagerImpl::UnregisterApplication(
auto it_app = applications_.begin();
while (applications_.end() != it_app) {
if (app_id == (*it_app)->app_id()) {
- connection_handler().GetDeviceID((*it_app)->mac_address(), &handle);
app_to_remove = *it_app;
applications_.erase(it_app++);
+ break;
} else {
++it_app;
}
@@ -2968,15 +2968,23 @@ void ApplicationManagerImpl::UnregisterApplication(
(hmi_capabilities_->get_hmi_language_handler())
.OnUnregisterApplication(app_id);
- AppV4DevicePredicate finder(handle);
- ApplicationSharedPtr app = FindApp(applications(), finder);
- if (!app) {
- LOG4CXX_DEBUG(
- logger_, "There is no more SDL4 apps with device handle: " << handle);
- RemoveAppsWaitingForRegistration(handle);
- RefreshCloudAppInformation();
- SendUpdateAppList();
+ if (connection_handler().GetDeviceID(app_to_remove->mac_address(),
+ &handle)) {
+ AppV4DevicePredicate finder(handle);
+ ApplicationSharedPtr app = FindApp(applications(), finder);
+ if (!app) {
+ LOG4CXX_DEBUG(
+ logger_,
+ "There is no more SDL4 apps with device handle: " << handle);
+
+ RemoveAppsWaitingForRegistration(handle);
+ RefreshCloudAppInformation();
+ SendUpdateAppList();
+ } else if (app_to_remove->is_cloud_app()) {
+ RefreshCloudAppInformation();
+ SendUpdateAppList();
+ }
}
}
diff --git a/src/components/include/test/transport_manager/mock_transport_manager.h b/src/components/include/test/transport_manager/mock_transport_manager.h
index 0581d4f375..2ef79f930c 100644
--- a/src/components/include/test/transport_manager/mock_transport_manager.h
+++ b/src/components/include/test/transport_manager/mock_transport_manager.h
@@ -61,7 +61,7 @@ class MockTransportManager : public ::transport_manager::TransportManager,
MOCK_METHOD0(SearchDevices, int());
MOCK_METHOD1(
AddCloudDevice,
- void(const transport_manager::transport_adapter::CloudAppProperties));
+ void(const transport_manager::transport_adapter::CloudAppProperties&));
MOCK_METHOD1(RemoveCloudDevice, void(const DeviceHandle device_id));
MOCK_METHOD1(ConnectDevice, int(const DeviceHandle));
MOCK_CONST_METHOD1(
diff --git a/src/components/include/transport_manager/transport_manager.h b/src/components/include/transport_manager/transport_manager.h
index 4ccc78cd1b..eabb4f7028 100644
--- a/src/components/include/transport_manager/transport_manager.h
+++ b/src/components/include/transport_manager/transport_manager.h
@@ -76,7 +76,7 @@ class TransportManager {
virtual int SearchDevices() = 0;
virtual void AddCloudDevice(
- const transport_manager::transport_adapter::CloudAppProperties
+ const transport_manager::transport_adapter::CloudAppProperties&
cloud_properties) = 0;
virtual void RemoveCloudDevice(const DeviceHandle device_id) = 0;
diff --git a/src/components/policy/policy_regular/src/sql_pt_representation.cc b/src/components/policy/policy_regular/src/sql_pt_representation.cc
index 19133a45f8..604e69f6fa 100644
--- a/src/components/policy/policy_regular/src/sql_pt_representation.cc
+++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc
@@ -1800,8 +1800,14 @@ bool SQLPTRepresentation::GatherAppServiceParameters(
handled_rpc);
}
- service_name_query.Reset();
- handled_rpcs_query.Reset();
+ if (!service_name_query.Reset()) {
+ LOG4CXX_ERROR(logger_, "Could not reset service_name query");
+ return false;
+ }
+ if (!handled_rpcs_query.Reset()) {
+ LOG4CXX_ERROR(logger_, "Could not reset handled_rpcs query");
+ return false;
+ }
}
return true;
diff --git a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h
index 118439bd4a..60303c1bca 100644
--- a/src/components/transport_manager/include/transport_manager/transport_manager_impl.h
+++ b/src/components/transport_manager/include/transport_manager/transport_manager_impl.h
@@ -140,7 +140,7 @@ class TransportManagerImpl
int SearchDevices() OVERRIDE;
void AddCloudDevice(
- const transport_manager::transport_adapter::CloudAppProperties
+ const transport_manager::transport_adapter::CloudAppProperties&
cloud_properties) OVERRIDE;
void RemoveCloudDevice(const DeviceHandle device_id) OVERRIDE;
diff --git a/src/components/transport_manager/src/cloud/cloud_device.cc b/src/components/transport_manager/src/cloud/cloud_device.cc
index 184fcc10cc..35510f4cf8 100644
--- a/src/components/transport_manager/src/cloud/cloud_device.cc
+++ b/src/components/transport_manager/src/cloud/cloud_device.cc
@@ -50,6 +50,10 @@ bool CloudDevice::IsSameAs(const Device* other) const {
const CloudDevice* other_cloud_device =
dynamic_cast<const CloudDevice*>(other);
+ if (!other_cloud_device) {
+ return false;
+ }
+
if (host_ != other_cloud_device->GetHost()) {
return false;
}
diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc
index d197882120..a74ddb700e 100644
--- a/src/components/transport_manager/src/transport_manager_impl.cc
+++ b/src/components/transport_manager/src/transport_manager_impl.cc
@@ -131,7 +131,7 @@ void TransportManagerImpl::ReconnectionTimeout() {
}
void TransportManagerImpl::AddCloudDevice(
- const transport_manager::transport_adapter::CloudAppProperties
+ const transport_manager::transport_adapter::CloudAppProperties&
cloud_properties) {
transport_adapter::DeviceType type = transport_adapter::DeviceType::UNKNOWN;
if ((cloud_properties.cloud_transport_type == "WS") ||