diff options
author | Andrey Oleynik (GitHub) <aoleynik@luxoft.com> | 2017-12-07 16:51:55 +0200 |
---|---|---|
committer | Andriy Byzhynar <AByzhynar@luxoft.com> | 2018-01-18 12:03:51 +0200 |
commit | 8e628176a3cfe6d9bc47c80ba8c2a44cc0d961f0 (patch) | |
tree | e05e2fa6eb8c8c752e70e415b588682f43d87f9c /src | |
parent | c4e771fb7d402157c5cbb5159c41e0a4553b8492 (diff) | |
download | sdl_core-8e628176a3cfe6d9bc47c80ba8c2a44cc0d961f0.tar.gz |
Adds null pointer checks, fixes typos and other minor changes.
Diffstat (limited to 'src')
10 files changed, 43 insertions, 30 deletions
diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 89ed149add..5962ca5b11 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -1295,7 +1295,7 @@ class ApplicationManagerImpl * @param application Pointer to switched application, must be validated * before passing * @param connection_key Connection key from registration request of - * switched + * switched * application */ void ProcessReconnection(ApplicationSharedPtr application, diff --git a/src/components/application_manager/include/application_manager/helpers/application_helper.h b/src/components/application_manager/include/application_manager/helpers/application_helper.h index ebf709bc45..73cc54515c 100644 --- a/src/components/application_manager/include/application_manager/helpers/application_helper.h +++ b/src/components/application_manager/include/application_manager/helpers/application_helper.h @@ -88,6 +88,6 @@ struct SubscribedToIVIPredicate { * @param app Application to clean its data * @param app_manager Application manager */ -void RecallApplicationData(ApplicationSharedPtr app, +void DeleteApplicationData(ApplicationSharedPtr app, ApplicationManager& app_manager); } // namespace application_manager diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index d42d6d91b2..da28cf9635 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -108,6 +108,7 @@ DeviceTypes devicesType = { */ bool device_id_comparator(const std::string& device_id, ApplicationSharedPtr app) { + DCHECK_OR_RETURN(app, false); LOG4CXX_DEBUG(logger_, "Data to compare: device_id : " << device_id << " app mac: " << app->mac_address()); @@ -1118,7 +1119,7 @@ void ApplicationManagerImpl::OnDeviceSwitchingStart( hmi_apis::FunctionID::BasicCommunication_UpdateDeviceList; so_to_send[jhs::S_PARAMS][jhs::S_MESSAGE_TYPE] = hmi_apis::messageType::request; - so_to_send[jhs::S_PARAMS][jhs::S_PROTOCOL_VERSION] = 3; + so_to_send[jhs::S_PARAMS][jhs::S_PROTOCOL_VERSION] = 2; so_to_send[jhs::S_PARAMS][jhs::S_PROTOCOL_TYPE] = 1; so_to_send[jhs::S_PARAMS][jhs::S_CORRELATION_ID] = GetNextHMICorrelationID(); so_to_send[jhs::S_MSG_PARAMS] = *msg_params; @@ -1150,6 +1151,7 @@ void ApplicationManagerImpl::SwitchApplication(ApplicationSharedPtr app, const size_t device_id, const std::string& mac_address) { LOG4CXX_AUTO_TRACE(logger_); + DCHECK_OR_RETURN_VOID(app); sync_primitives::AutoLock lock(applications_list_lock_); DCHECK_OR_RETURN_VOID(1 == applications_.erase(app)); diff --git a/src/components/application_manager/src/command_holder_impl.cc b/src/components/application_manager/src/command_holder_impl.cc index 82ba486913..4e2cf89f57 100644 --- a/src/components/application_manager/src/command_holder_impl.cc +++ b/src/components/application_manager/src/command_holder_impl.cc @@ -45,6 +45,7 @@ void CommandHolderImpl::Suspend( CommandType type, utils::SharedPtr<smart_objects::SmartObject> command) { LOG4CXX_AUTO_TRACE(logger_); + DCHECK_OR_RETURN_VOID(application); LOG4CXX_DEBUG(logger_, "Suspending command(s) for application: " << application->policy_app_id()); @@ -64,6 +65,7 @@ void CommandHolderImpl::Suspend( void CommandHolderImpl::Resume(ApplicationSharedPtr application, CommandType type) { LOG4CXX_AUTO_TRACE(logger_); + DCHECK_OR_RETURN_VOID(application); LOG4CXX_DEBUG( logger_, "Resuming command(s) for application: " << application->policy_app_id()); @@ -76,6 +78,7 @@ void CommandHolderImpl::Resume(ApplicationSharedPtr application, void CommandHolderImpl::Clear(ApplicationSharedPtr application) { LOG4CXX_AUTO_TRACE(logger_); + DCHECK_OR_RETURN_VOID(application); LOG4CXX_DEBUG( logger_, "Clearing command(s) for application: " << application->policy_app_id()); @@ -98,6 +101,7 @@ void CommandHolderImpl::Clear(ApplicationSharedPtr application) { } void CommandHolderImpl::ResumeHmiCommand(ApplicationSharedPtr application) { + DCHECK_OR_RETURN_VOID(application); sync_primitives::AutoLock lock(commands_lock_); auto app_commands = app_hmi_commands_.find(application); if (app_hmi_commands_.end() == app_commands) { @@ -116,6 +120,7 @@ void CommandHolderImpl::ResumeHmiCommand(ApplicationSharedPtr application) { } void CommandHolderImpl::ResumeMobileCommand(ApplicationSharedPtr application) { + DCHECK_OR_RETURN_VOID(application); sync_primitives::AutoLock lock(commands_lock_); auto app_commands = app_mobile_commands_.find(application); if (app_mobile_commands_.end() == app_commands) { diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc index f9cb09816e..5251c9e122 100644 --- a/src/components/application_manager/src/commands/command_impl.cc +++ b/src/components/application_manager/src/commands/command_impl.cc @@ -114,7 +114,9 @@ bool CommandImpl::ReplaceMobileWithHMIAppId( smart_objects::SmartArray* message_array = message.asArray(); smart_objects::SmartArray::iterator it = message_array->begin(); for (; it != message_array->end(); ++it) { - ReplaceMobileWithHMIAppId(*it); + if (!ReplaceMobileWithHMIAppId(*it)) { + break; + } } break; } @@ -123,7 +125,9 @@ bool CommandImpl::ReplaceMobileWithHMIAppId( std::set<std::string>::const_iterator key = keys.begin(); for (; key != keys.end(); ++key) { std::string k = *key; - ReplaceMobileWithHMIAppId(message[*key]); + if (!ReplaceMobileWithHMIAppId(message[*key])) { + break; + } } break; } @@ -193,7 +197,9 @@ bool CommandImpl::ReplaceHMIWithMobileAppId( smart_objects::SmartArray* message_array = message.asArray(); smart_objects::SmartArray::iterator it = message_array->begin(); for (; it != message_array->end(); ++it) { - ReplaceHMIWithMobileAppId(*it); + if (!ReplaceHMIWithMobileAppId(*it)) { + break; + } } break; } @@ -201,7 +207,9 @@ bool CommandImpl::ReplaceHMIWithMobileAppId( std::set<std::string> keys = message.enumerate(); std::set<std::string>::const_iterator key = keys.begin(); for (; key != keys.end(); ++key) { - ReplaceHMIWithMobileAppId(message[*key]); + if (!ReplaceHMIWithMobileAppId(message[*key])) { + break; + } } break; } diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index cb6534dd2d..26e50d39fe 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -645,7 +645,7 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( "Application has been switched from another transport, " "but doesn't have correct hashID."); - application_manager::RecallApplicationData(application, + application_manager::DeleteApplicationData(application, application_manager_); SendResponse( diff --git a/src/components/application_manager/src/helpers/application_helper.cc b/src/components/application_manager/src/helpers/application_helper.cc index 2007b97434..16b49faa2a 100644 --- a/src/components/application_manager/src/helpers/application_helper.cc +++ b/src/components/application_manager/src/helpers/application_helper.cc @@ -7,7 +7,7 @@ namespace { using namespace application_manager; -void RecallWayPoints(ApplicationSharedPtr app, +void DeleteWayPoints(ApplicationSharedPtr app, ApplicationManager& app_manager) { app_manager.UnsubscribeAppFromWayPoints(app); if (!app_manager.IsAnyAppSubscribedForWayPoints()) { @@ -15,7 +15,7 @@ void RecallWayPoints(ApplicationSharedPtr app, } } -void RecallCommands(ApplicationSharedPtr app, ApplicationManager& app_manager) { +void DeleteCommands(ApplicationSharedPtr app, ApplicationManager& app_manager) { CommandsMap cmap = app->commands_map().GetData(); for (auto cmd : cmap) { @@ -24,7 +24,7 @@ void RecallCommands(ApplicationSharedPtr app, ApplicationManager& app_manager) { } } -void RecallSubmenus(ApplicationSharedPtr app, ApplicationManager& app_manager) { +void DeleteSubmenus(ApplicationSharedPtr app, ApplicationManager& app_manager) { SubMenuMap smap = app->sub_menu_map().GetData(); for (auto smenu : smap) { @@ -33,7 +33,7 @@ void RecallSubmenus(ApplicationSharedPtr app, ApplicationManager& app_manager) { } } -void RecallChoiceSets(ApplicationSharedPtr app, +void DeleteChoiceSets(ApplicationSharedPtr app, ApplicationManager& app_manager) { ChoiceSetMap csmap = app->choice_set_map().GetData(); @@ -43,7 +43,7 @@ void RecallChoiceSets(ApplicationSharedPtr app, } } -void RecallGlobalProperties(ApplicationSharedPtr app, +void DeleteGlobalProperties(ApplicationSharedPtr app, ApplicationManager& app_manager) { using namespace smart_objects; @@ -74,7 +74,7 @@ void RecallGlobalProperties(ApplicationSharedPtr app, MessageHelper::SendResetPropertiesRequest(app, app_manager); } -void RecallButtonSubscriptions(ApplicationSharedPtr app, +void DeleteButtonSubscriptions(ApplicationSharedPtr app, ApplicationManager& app_manager) { ButtonSubscriptions buttons = app->SubscribedButtons().GetData(); @@ -87,7 +87,7 @@ void RecallButtonSubscriptions(ApplicationSharedPtr app, } } -void RecallVISubscriptions(ApplicationSharedPtr app, +void DeleteVISubscriptions(ApplicationSharedPtr app, ApplicationManager& app_manager) { VehicleInfoSubscriptions ivi = app->SubscribedIVI().GetData(); @@ -128,18 +128,18 @@ bool SubscribedToIVIPredicate::operator()( return app ? app->IsSubscribedToIVI(vehicle_info_) : false; } -void RecallApplicationData(ApplicationSharedPtr app, +void DeleteApplicationData(ApplicationSharedPtr app, ApplicationManager& app_manager) { LOG4CXX_AUTO_TRACE(logger); DCHECK_OR_RETURN_VOID(app); - RecallWayPoints(app, app_manager); - RecallCommands(app, app_manager); - RecallSubmenus(app, app_manager); - RecallChoiceSets(app, app_manager); - RecallGlobalProperties(app, app_manager); - RecallButtonSubscriptions(app, app_manager); - RecallVISubscriptions(app, app_manager); + DeleteWayPoints(app, app_manager); + DeleteCommands(app, app_manager); + DeleteSubmenus(app, app_manager); + DeleteChoiceSets(app, app_manager); + DeleteGlobalProperties(app, app_manager); + DeleteButtonSubscriptions(app, app_manager); + DeleteVISubscriptions(app, app_manager); CleanupAppFiles(app); } diff --git a/src/components/application_manager/test/application_helper_test.cc b/src/components/application_manager/test/application_helper_test.cc index 167244c3eb..ce33dc6b45 100644 --- a/src/components/application_manager/test/application_helper_test.cc +++ b/src/components/application_manager/test/application_helper_test.cc @@ -193,7 +193,7 @@ TEST_F(ApplicationHelperTest, RecallApplicationData_ExpectAppDataReset) { EXPECT_TRUE(file_ptr->file_name == filename); // Act - application_manager::RecallApplicationData(app_impl_, app_manager_impl_); + application_manager::DeleteApplicationData(app_impl_, app_manager_impl_); EXPECT_FALSE(NULL != app_impl_->FindCommand(cmd_id)); EXPECT_FALSE(NULL != app_impl_->FindSubMenu(menu_id)); EXPECT_FALSE(NULL != app_impl_->FindChoiceSet(choice_set_id)); @@ -249,7 +249,7 @@ TEST_F(ApplicationHelperTest, RecallApplicationData_ExpectHMICleanupRequests) { EXPECT_CALL(*mock_message_helper_, SendUnsubscribeIVIRequest(_, _, _)); // Act - application_manager::RecallApplicationData(app_impl_, app_manager_impl_); + application_manager::DeleteApplicationData(app_impl_, app_manager_impl_); } } // application_manager_test diff --git a/src/components/application_manager/test/mock_application_helper.cc b/src/components/application_manager/test/mock_application_helper.cc index 31895ec80d..c64a56e53e 100644 --- a/src/components/application_manager/test/mock_application_helper.cc +++ b/src/components/application_manager/test/mock_application_helper.cc @@ -47,7 +47,7 @@ MockApplicationHelper& MockApplicationHelper::application_helper_mock() { namespace application_manager { -void RecallApplicationData(ApplicationSharedPtr app, +void DeleteApplicationData(ApplicationSharedPtr app, ApplicationManager& app_manager) { test::components::application_manager_test::MockApplicationHelper:: application_helper_mock().RecallApplicationData(app, app_manager); diff --git a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc index 98e03ef911..944f3594c4 100644 --- a/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc +++ b/src/components/transport_manager/src/transport_adapter/transport_adapter_impl.cc @@ -501,15 +501,13 @@ void TransportAdapterImpl::SearchDeviceFailed(const SearchDeviceError& error) { } bool TransportAdapterImpl::IsSearchDevicesSupported() const { - LOG4CXX_TRACE(logger_, "enter"); + LOG4CXX_AUTO_TRACE(logger_); return device_scanner_ != 0; - LOG4CXX_TRACE(logger_, "exit"); } bool TransportAdapterImpl::IsServerOriginatedConnectSupported() const { - LOG4CXX_TRACE(logger_, "enter"); + LOG4CXX_AUTO_TRACE(logger_); return server_connection_factory_ != 0; - LOG4CXX_TRACE(logger_, "exit"); } bool TransportAdapterImpl::IsClientOriginatedConnectSupported() const { |