diff options
98 files changed, 639 insertions, 961 deletions
diff --git a/cppcheck.xml b/cppcheck.xml new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/cppcheck.xml diff --git a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc index fd7b03fabc..e03973614d 100644 --- a/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/app_service_rpc_plugin/src/app_service_rpc_plugin.cc @@ -107,14 +107,15 @@ void AppServiceRpcPlugin::DeleteSubscriptions( } // namespace app_service_rpc_plugin -extern "C" __attribute__((visibility("default"))) -application_manager::plugin_manager::RPCPlugin* -Create(logger::Logger* logger_instance) { +using RPCPlugin = application_manager::plugin_manager::RPCPlugin; +// cppcheck-suppress unusedFunction +extern "C" __attribute__((visibility("default"))) RPCPlugin* Create( + logger::Logger* logger_instance) { logger::Logger::instance(logger_instance); return new app_service_rpc_plugin::AppServiceRpcPlugin(); } -extern "C" __attribute__((visibility("default"))) void Delete( - application_manager::plugin_manager::RPCPlugin* data) { +// cppcheck-suppress unusedFunction +extern "C" __attribute__((visibility("default"))) void Delete(RPCPlugin* data) { delete data; } diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc index b7a343a907..217258b086 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/hmi/rc_on_remote_control_settings_notification.cc @@ -65,15 +65,6 @@ RCOnRemoteControlSettingsNotification::RCOnRemoteControlSettingsNotification( RCOnRemoteControlSettingsNotification:: ~RCOnRemoteControlSettingsNotification() {} -hmi_apis::Common_RCAccessMode::eType AccessModeFromString( - const std::string& access_mode) { - std::map<std::string, hmi_apis::Common_RCAccessMode::eType>::const_iterator - mode = access_modes.find(access_mode); - return access_modes.end() != mode - ? mode->second - : hmi_apis::Common_RCAccessMode::INVALID_ENUM; -} - std::string AccessModeToString( const hmi_apis::Common_RCAccessMode::eType access_mode) { std::map<std::string, hmi_apis::Common_RCAccessMode::eType>::const_iterator diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/release_interior_vehicle_data_module_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/release_interior_vehicle_data_module_request.cc index e7532636b2..47430c2487 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/release_interior_vehicle_data_module_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/release_interior_vehicle_data_module_request.cc @@ -55,9 +55,9 @@ struct ResponseParams { void PrepareResponseResult( ResponseParams& response_params_out, - rc_rpc_plugin::ResourceReleasedState::eType& released_result) { + const rc_rpc_plugin::ResourceReleasedState::eType& released_result) { std::stringstream ss; - auto info_inserter = [&ss, response_params_out](std::string info) { + auto info_inserter = [&ss, response_params_out](const std::string& info) { ss << "Module [" << response_params_out.module_type << ":" << response_params_out.module_id << "] " << info; }; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index 8dd4eab306..dea660b780 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -105,8 +105,9 @@ mobile_apis::Result::eType PrepareResultCodeAndInfo( } else { info = "Accessing not supported module data."; } - return result_code; + SDL_LOG_WARN(info); + return result_code; } void SetInteriorVehicleDataRequest::Execute() { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc index 53222e0d04..12608d64c1 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/rc_command_request.cc @@ -247,8 +247,8 @@ void RCCommandRequest::ProcessAccessResponse( mobile_apis::Result::SUCCESS, mobile_apis::Result::WARNINGS); - bool is_allowed = false; if (result) { + bool is_allowed = false; if (message[app_mngr::strings::msg_params].keyExists( message_params::kAllowed)) { is_allowed = diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc index 1db25265e7..c295ad4f11 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/interior_data_manager_impl.cc @@ -197,9 +197,12 @@ InteriorDataManagerImpl::AppsSubscribedModuleTypes() { auto app_subscriptions = rc_extension->InteriorVehicleDataSubscriptions(); std::vector<std::string> app_module_types; - for (auto& app_subscription : app_subscriptions) { - app_module_types.push_back(app_subscription.first); - } + std::transform(app_subscriptions.begin(), + app_subscriptions.end(), + std::back_inserter(app_module_types), + [](const ModuleUid& app_subscription) { + return app_subscription.first; + }); std::sort(app_module_types.begin(), app_module_types.end()); result[app_ptr] = app_module_types; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc index e2b67effee..c1743c8540 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_command_factory.cc @@ -71,7 +71,7 @@ using rc_rpc_plugin::ResourceAllocationManager; template <typename RCCommandType> class RCCommandCreator : public CommandCreator { public: - RCCommandCreator(const RCCommandParams& params) : params_(params) {} + explicit RCCommandCreator(const RCCommandParams& params) : params_(params) {} private: bool CanBeCreated() const override { @@ -92,7 +92,8 @@ struct RCInvalidCommand {}; template <> class RCCommandCreator<RCInvalidCommand> : public CommandCreator { public: - RCCommandCreator(const RCCommandParams& params) { + // cppcheck-suppress unusedFunction //Used in RCCommandCreatorFactory + explicit RCCommandCreator(const RCCommandParams& params) { UNUSED(params); } @@ -109,7 +110,8 @@ class RCCommandCreator<RCInvalidCommand> : public CommandCreator { }; struct RCCommandCreatorFactory { - RCCommandCreatorFactory(const RCCommandParams& params) : params_(params) {} + explicit RCCommandCreatorFactory(const RCCommandParams& params) + : params_(params) {} template <typename RCCommandType> CommandCreator& GetCreator() { diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc index 61524546a8..b2d1f1513b 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_helpers.cc @@ -111,18 +111,28 @@ rc_rpc_types::ModuleIdConsentVector RCHelpers::FillModuleConsents( std::vector<std::string> RCHelpers::RetrieveModuleIds( const ns_smart_device_link::ns_smart_objects::SmartObject& moduleIds) { std::vector<std::string> module_ids; - for (const auto& module_id : (*moduleIds.asArray())) { - module_ids.push_back(module_id.asString()); - } + + std::transform((*moduleIds.asArray()).begin(), + (*moduleIds.asArray()).end(), + std::back_inserter(module_ids), + [](const smart_objects::SmartObject& module_id) { + return module_id.asString(); + }); + return module_ids; } std::vector<bool> RCHelpers::RetrieveModuleConsents( const ns_smart_device_link::ns_smart_objects::SmartObject& consents) { std::vector<bool> module_consents; - for (const auto& allowed_item : (*consents.asArray())) { - module_consents.push_back(allowed_item.asBool()); - } + + std::transform((*consents.asArray()).begin(), + (*consents.asArray()).end(), + std::back_inserter(module_consents), + [](const smart_objects::SmartObject& allowed_item) { + return allowed_item.asBool(); + }); + return module_consents; } @@ -333,11 +343,14 @@ smart_objects::SmartObject RCHelpers::MergeArray( } auto& data2_array = *data2.asArray(); - for (const auto& data_item : data2_array) { - if (data_item.getType() != smart_objects::SmartType_Map || - !data_item.keyExists(application_manager::strings::id)) { - return data2; - } + + auto compare = [](const smart_objects::SmartObject& data_item) { + return (data_item.getType() != smart_objects::SmartType_Map || + !data_item.keyExists(application_manager::strings::id)); + }; + + if (std::any_of(data2_array.begin(), data2_array.end(), compare)) { + return data2; } smart_objects::SmartObject result = data1; diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc index 4345aa044a..87090405e7 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/rc_rpc_plugin.cc @@ -212,11 +212,14 @@ RCRPCPlugin::Apps RCRPCPlugin::GetRCApplications( ApplicationSet accessor = app_mngr.applications().GetData(); std::vector<ApplicationSharedPtr> result; - for (const auto& it : accessor) { - if (it->is_remote_control_supported()) { - result.push_back(it); - } - } + + std::copy_if(accessor.begin(), + accessor.end(), + std::back_inserter(result), + [](const ApplicationSharedPtr& app) { + return app->is_remote_control_supported(); + }); + return result; } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_consent_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_consent_notification.cc index 37552e003a..e9e0c65424 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_consent_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_app_permission_consent_notification.cc @@ -50,7 +50,7 @@ namespace { struct PermissionsAppender : public std::unary_function<void, const smart_objects::SmartArray::value_type&> { - PermissionsAppender(policy::PermissionConsent& consents) + explicit PermissionsAppender(policy::PermissionConsent& consents) : allowed_key_(application_manager::hmi_response::allowed) , consents_(consents) {} void operator()(const smart_objects::SmartArray::value_type& item) const { @@ -82,7 +82,7 @@ struct PermissionsAppender */ struct ExternalConsentStatusAppender : std::unary_function<void, const smart_objects::SmartArray::value_type&> { - ExternalConsentStatusAppender( + explicit ExternalConsentStatusAppender( policy::ExternalConsentStatus& external_consent_status) : external_consent_status_(external_consent_status) {} void operator()(const smart_objects::SmartArray::value_type& item) const { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc index 527cf911b9..372f83e4fd 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/sdl_activate_app_request.cc @@ -43,7 +43,7 @@ namespace commands { namespace { struct ProtoV4AppsOnDevice : std::unary_function<ApplicationSharedPtr, bool> { connection_handler::DeviceHandle handle_; - ProtoV4AppsOnDevice(const connection_handler::DeviceHandle handle) + explicit ProtoV4AppsOnDevice(const connection_handler::DeviceHandle handle) : handle_(handle) {} bool operator()(const ApplicationSharedPtr app) const { return app ? handle_ == app->device() && diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc index 288cafb94e..c83538c023 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/add_sub_menu_request.cc @@ -209,9 +209,9 @@ bool AddSubMenuRequest::Init() { bool AddSubMenuRequest::CheckSubMenuName() { SDL_LOG_AUTO_TRACE(); - const char* str = NULL; - str = (*message_)[strings::msg_params][strings::menu_name].asCharArray(); + const char* str = + (*message_)[strings::msg_params][strings::menu_name].asCharArray(); if (!CheckSyntax(str)) { SDL_LOG_INFO("Invalid subMenu name."); return false; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc index 55783be4cd..5312491035 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/alert_request.cc @@ -409,8 +409,6 @@ void AlertRequest::SendSpeakRequest(int32_t app_id, SmartObject msg_params = smart_objects::SmartObject(SmartType_Map); if (tts_chunks_exists && length_tts_chunks) { msg_params[hmi_request::tts_chunks] = - smart_objects::SmartObject(SmartType_Array); - msg_params[hmi_request::tts_chunks] = (*message_)[strings::msg_params][strings::tts_chunks]; } if ((*message_)[strings::msg_params].keyExists(strings::play_tone) && diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc index 8e13110515..13a57cf9a8 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/change_registration_request.cc @@ -44,7 +44,8 @@ namespace { namespace custom_str = utils::custom_string; struct IsSameNickname { - IsSameNickname(const custom_str::CustomString& app_id) : app_id_(app_id) {} + explicit IsSameNickname(const custom_str::CustomString& app_id) + : app_id_(app_id) {} bool operator()(const policy::StringArray::value_type& nickname) const { return app_id_.CompareIgnoreCase(nickname.c_str()); } @@ -512,7 +513,6 @@ bool ChangeRegistrationRequest::IsLanguageSupportedByTTS( for (size_t i = 0; i < tts_languages->length(); ++i) { if (hmi_display_lang == tts_languages->getElement(i).asInt()) { return true; - break; } } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc index d43e8e0710..345a6a8497 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/create_interaction_choice_set_request.cc @@ -239,9 +239,8 @@ bool CreateInteractionChoiceSetRequest::compareStr( bool CreateInteractionChoiceSetRequest::IsWhiteSpaceExist( const smart_objects::SmartObject& choice_set) { SDL_LOG_AUTO_TRACE(); - const char* str = NULL; - str = choice_set[strings::menu_name].asCharArray(); + const char* str = choice_set[strings::menu_name].asCharArray(); if (!CheckSyntax(str)) { SDL_LOG_ERROR("Invalid menu_name syntax check failed"); return true; @@ -322,8 +321,6 @@ void CreateInteractionChoiceSetRequest::SendVRAddCommandRequests( msg_params[strings::cmd_id] = choice_set[strings::choice_set][chs_num][strings::choice_id]; msg_params[strings::vr_commands] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - msg_params[strings::vr_commands] = choice_set[strings::choice_set][chs_num][strings::vr_commands]; sync_primitives::AutoLock commands_lock(vr_commands_lock_); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc index 0c731a027b..e6bdd50350 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/delete_command_request.cc @@ -96,15 +96,6 @@ void DeleteCommandRequest::Run() { (*message_)[strings::msg_params][strings::cmd_id]; msg_params[strings::app_id] = application->app_id(); - // we should specify amount of required responses in the 1st request - uint32_t chaining_counter = 0; - if (command.keyExists(strings::menu_params)) { - ++chaining_counter; - } - - if (command.keyExists(strings::vr_commands)) { - ++chaining_counter; - } /* Need to set all flags before sending request to HMI * for correct processing this flags in method on_event */ if (command.keyExists(strings::menu_params)) { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_request.cc index 33d3479941..54b542d245 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/get_way_points_request.cc @@ -68,10 +68,8 @@ void GetWayPointsRequest::Run() { SendResponse(false, mobile_apis::Result::APPLICATION_NOT_REGISTERED); return; } - smart_objects::SmartObject msg_params = - smart_objects::SmartObject(smart_objects::SmartType_Map); - msg_params = (*message_)[strings::msg_params]; + smart_objects::SmartObject msg_params = (*message_)[strings::msg_params]; msg_params[strings::app_id] = app->app_id(); StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); SendHMIRequest(hmi_apis::FunctionID::Navigation_GetWayPoints, diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc index 90ed038b89..4a97d5b970 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_system_request_notification.cc @@ -173,7 +173,7 @@ void OnSystemRequestNotification::AddHeader(BinaryMessage& message) const { } char timeout_str[24]; - if (0 > sprintf(timeout_str, "%d", timeout)) { + if (0 > sprintf(timeout_str, "%u", timeout)) { memset(timeout_str, 0, sizeof(timeout_str)); } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc index 9c218e0e99..7b29f33d24 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/perform_interaction_request.cc @@ -34,12 +34,12 @@ #include "sdl_rpc_plugin/commands/mobile/perform_interaction_request.h" #include <string.h> + #include <numeric> #include <string> #include "application_manager/application_impl.h" #include "application_manager/message_helper.h" - #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.h" #include "utils/custom_string.h" @@ -871,9 +871,9 @@ void PerformInteractionRequest::DisablePerformInteraction() { bool PerformInteractionRequest::IsWhiteSpaceExist() { SDL_LOG_AUTO_TRACE(); - const char* str = NULL; - str = (*message_)[strings::msg_params][strings::initial_text].asCharArray(); + const char* str = + (*message_)[strings::msg_params][strings::initial_text].asCharArray(); if (!CheckSyntax(str)) { SDL_LOG_ERROR("Invalid initial_text syntax check failed"); return true; @@ -1038,7 +1038,6 @@ bool PerformInteractionRequest::CheckChoiceIDFromRequest( const smart_objects::SmartObject& choice_set_id_list) const { SDL_LOG_AUTO_TRACE(); - size_t choice_list_length = 0; std::set<uint32_t> choice_id_set; std::pair<std::set<uint32_t>::iterator, bool> ins_res; @@ -1046,12 +1045,11 @@ bool PerformInteractionRequest::CheckChoiceIDFromRequest( auto choice_set = app->FindChoiceSet(choice_set_id_list[i].asInt()); if (smart_objects::SmartType_Null == choice_set.getType()) { SDL_LOG_ERROR( - "Couldn't find choiceset_id = " << choice_set_id_list[i].asInt()); return false; } - choice_list_length = choice_set[strings::choice_set].length(); + size_t choice_list_length = choice_set[strings::choice_set].length(); const smart_objects::SmartObject& choices_list = choice_set[strings::choice_set]; for (size_t k = 0; k < choice_list_length; ++k) { @@ -1076,15 +1074,14 @@ const bool PerformInteractionRequest::HasHMIResponsesToWait() const { void PerformInteractionRequest::SendBothModeResponse( const smart_objects::SmartObject& msg_param) { SDL_LOG_AUTO_TRACE(); - mobile_apis::Result::eType perform_interaction_result_code = - mobile_apis::Result::INVALID_ENUM; + app_mngr::commands::ResponseInfo ui_perform_info( ui_result_code_, HmiInterfaces::HMI_INTERFACE_UI, application_manager_); app_mngr::commands::ResponseInfo vr_perform_info( vr_result_code_, HmiInterfaces::HMI_INTERFACE_VR, application_manager_); const bool result = PrepareResultForMobileResponse(ui_perform_info, vr_perform_info); - perform_interaction_result_code = + mobile_apis::Result::eType perform_interaction_result_code = PrepareResultCodeForResponse(ui_perform_info, vr_perform_info); const smart_objects::SmartObject* response_params = msg_param.empty() ? NULL : &msg_param; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_request.cc index 50ff392e33..5263991716 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/put_file_request.cc @@ -165,7 +165,6 @@ void PutFileRequest::Run() { is_persistent_file_ = false; bool is_system_file = false; length_ = binary_data.size(); - bool is_download_complete = true; bool offset_exist = (*message_)[strings::msg_params].keyExists(strings::offset); @@ -252,6 +251,7 @@ void PutFileRequest::Run() { case mobile_apis::Result::SUCCESS: { SDL_LOG_INFO("PutFile is successful"); if (!is_system_file) { + bool is_download_complete = true; AppFile file(sync_file_name_, is_persistent_file_, is_download_complete, diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc index c30f83bc00..72faad8668 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc @@ -111,7 +111,7 @@ std::string AppHMITypeToString(mobile_apis::AppHMIType::eType type) { } struct AppHMITypeInserter { - AppHMITypeInserter(smart_objects::SmartObject& so_array) + explicit AppHMITypeInserter(smart_objects::SmartObject& so_array) : index_(0), so_array_(so_array) {} bool operator()(const std::string& app_hmi_type) { @@ -162,7 +162,7 @@ class SmartArrayValueExtractor { }; struct IsSameNickname { - IsSameNickname(const custom_str::CustomString app_name) + explicit IsSameNickname(const custom_str::CustomString app_name) : app_name_(app_name) {} bool operator()(const policy::StringArray::value_type& nickname) const { return app_name_.CompareIgnoreCase(nickname.c_str()); @@ -1369,9 +1369,9 @@ bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() { bool RegisterAppInterfaceRequest::IsWhiteSpaceExist() { SDL_LOG_AUTO_TRACE(); - const char* str = NULL; - str = (*message_)[strings::msg_params][strings::app_name].asCharArray(); + const char* str = + (*message_)[strings::msg_params][strings::app_name].asCharArray(); if (!CheckSyntax(str)) { SDL_LOG_ERROR("Invalid app_name syntax check failed"); return true; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc index 37d43a354b..fcc898b348 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/send_location_request.cc @@ -119,9 +119,7 @@ void SendLocationRequest::Run() { } if (msg_params.keyExists(strings::location_image)) { - mobile_apis::Result::eType verification_result = - mobile_apis::Result::SUCCESS; - verification_result = MessageHelper::VerifyImage( + mobile_apis::Result::eType verification_result = MessageHelper::VerifyImage( (*message_)[strings::msg_params][strings::location_image], app, application_manager_); @@ -132,8 +130,7 @@ void SendLocationRequest::Run() { } } - SmartObject request_msg_params = SmartObject(smart_objects::SmartType_Map); - request_msg_params = msg_params; + SmartObject request_msg_params = msg_params; request_msg_params[strings::app_id] = app->hmi_app_id(); StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); SendHMIRequest( diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc index 922a45ebdb..396763ff98 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_global_properties_request.cc @@ -111,10 +111,8 @@ void SetGlobalPropertiesRequest::Run() { return; } - mobile_apis::Result::eType verification_result = mobile_apis::Result::SUCCESS; - if (msg_params.keyExists(strings::menu_icon)) { - verification_result = MessageHelper::VerifyImage( + mobile_apis::Result::eType verification_result = MessageHelper::VerifyImage( msg_params[strings::menu_icon], app, application_manager_); if (mobile_apis::Result::INVALID_DATA == verification_result) { SDL_LOG_ERROR("MessageHelper::VerifyImage return " @@ -241,11 +239,11 @@ void SetGlobalPropertiesRequest::Run() { application_manager_.GetPluginManager().ForEachPlugin( on_global_properties_updated); - smart_objects::SmartObject params = + smart_objects::SmartObject rc_request_params = smart_objects::SmartObject(smart_objects::SmartType_Map); - params[strings::app_id] = app->app_id(); - params[strings::user_location] = user_location; - SendRCRequest(params, true); + rc_request_params[strings::app_id] = app->app_id(); + rc_request_params[strings::user_location] = user_location; + SendRCRequest(rc_request_params, true); } // check TTS params @@ -257,7 +255,7 @@ void SetGlobalPropertiesRequest::Run() { if (is_help_prompt_present) { smart_objects::SmartObject& help_prompt = (*message_)[strings::msg_params][strings::help_prompt]; - verification_result = + mobile_apis::Result::eType verification_result = MessageHelper::VerifyTtsFiles(help_prompt, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { @@ -273,8 +271,9 @@ void SetGlobalPropertiesRequest::Run() { if (is_timeout_prompt_present) { smart_objects::SmartObject& timeout_prompt = (*message_)[strings::msg_params][strings::timeout_prompt]; - verification_result = MessageHelper::VerifyTtsFiles( - timeout_prompt, app, application_manager_); + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles( + timeout_prompt, app, application_manager_); if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { SDL_LOG_ERROR("MessageHelper::VerifyTtsFiles return " @@ -291,7 +290,7 @@ void SetGlobalPropertiesRequest::Run() { std::begin(invalid_params), std::end(invalid_params), std::string(""), - [](std::string& first, std::string& second) { + [](std::string& first, const std::string& second) { return first.empty() ? second : first + ", " + second; }); const std::string info = @@ -518,7 +517,6 @@ SetGlobalPropertiesRequest::PrepareResultCodeForResponse( const app_mngr::commands::ResponseInfo& second, const app_mngr::commands::ResponseInfo& third) { SDL_LOG_AUTO_TRACE(); - mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; if (IsResultCodeUnsupported(first, second, third) || IsResultCodeUnsupported(second, third, first) || IsResultCodeUnsupported(third, first, second)) { @@ -547,7 +545,7 @@ SetGlobalPropertiesRequest::PrepareResultCodeForResponse( hmi_apis::Common_Result::eType intermediate_result = std::max(first_result, second_result); - result_code = MessageHelper::HMIToMobileResult( + mobile_apis::Result::eType result_code = MessageHelper::HMIToMobileResult( std::max(intermediate_result, third_result)); return result_code; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_request.cc index b7b8fc27ad..cf5d80ecc0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/set_media_clock_timer_request.cc @@ -77,10 +77,8 @@ void SetMediaClockRequest::Run() { } if (isDataValid()) { - smart_objects::SmartObject msg_params = - smart_objects::SmartObject(smart_objects::SmartType_Map); // copy entirely msg - msg_params = (*message_)[strings::msg_params]; + smart_objects::SmartObject msg_params = (*message_)[strings::msg_params]; msg_params[strings::app_id] = app->app_id(); StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc index 04310bcd58..cfb9d5896e 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/show_constant_tbt_request.cc @@ -80,9 +80,7 @@ void ShowConstantTBTRequest::Run() { return; } - smart_objects::SmartObject msg_params = - smart_objects::SmartObject(smart_objects::SmartType_Map); - msg_params = (*message_)[strings::msg_params]; + smart_objects::SmartObject msg_params = (*message_)[strings::msg_params]; if (IsWhiteSpaceExist()) { SDL_LOG_ERROR("Incoming show constant TBT has contains \t\n \\t \\n"); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc index 15ced6d5a1..e46d3fd7f0 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/slider_request.cc @@ -109,9 +109,7 @@ void SliderRequest::Run() { return; } - smart_objects::SmartObject msg_params = - smart_objects::SmartObject(smart_objects::SmartType_Map); - msg_params = (*message_)[strings::msg_params]; + smart_objects::SmartObject msg_params = (*message_)[strings::msg_params]; msg_params[strings::app_id] = application->app_id(); if (!(*message_)[strings::msg_params].keyExists(strings::timeout)) { @@ -183,9 +181,9 @@ void SliderRequest::on_event(const event_engine::Event& event) { bool SliderRequest::IsWhiteSpaceExist() { SDL_LOG_AUTO_TRACE(); - const char* str = NULL; - str = (*message_)[strings::msg_params][strings::slider_header].asCharArray(); + const char* str = + (*message_)[strings::msg_params][strings::slider_header].asCharArray(); if (!CheckSyntax(str)) { SDL_LOG_ERROR("Invalid slider_header value syntax check failed"); return true; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subtle_alert_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subtle_alert_request.cc index 502290328a..327315b372 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subtle_alert_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subtle_alert_request.cc @@ -349,7 +349,6 @@ void SubtleAlertRequest::SendSubtleAlertRequest(int32_t app_id) { hmi_apis::Common_TextFieldName::subtleAlertText2; msg_params[hmi_request::alert_strings][index][hmi_request::field_text] = (*message_)[strings::msg_params][strings::alert_text2]; - index++; } // softButtons @@ -408,8 +407,6 @@ void SubtleAlertRequest::SendSpeakRequest(int32_t app_id, SmartObject msg_params = smart_objects::SmartObject(SmartType_Map); if (tts_chunks_exists && length_tts_chunks) { msg_params[hmi_request::tts_chunks] = - smart_objects::SmartObject(SmartType_Array); - msg_params[hmi_request::tts_chunks] = (*message_)[strings::msg_params][strings::tts_chunks]; } msg_params[strings::app_id] = app_id; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc index 17e295304c..cca088ed2d 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/system_request.cc @@ -34,10 +34,12 @@ Copyright (c) 2018, Ford Motor Company #include "sdl_rpc_plugin/commands/mobile/system_request.h" #include <stdio.h> + #include <algorithm> #include <sstream> #include <string> #include <vector> + #include "application_manager/policies/policy_handler_interface.h" #include "formatters/CFormatterJsonBase.h" #include "interfaces/MOBILE_API.h" @@ -70,11 +72,99 @@ const unsigned int kAppIdLengthMax = 40U; const unsigned int kAppNameLengthMax = 100U; const unsigned int kLanguageArraySizeMax = 100U; +typedef std::set<std::string> SynonymsSet; +typedef std::map<std::string, SynonymsSet> SynonymsMap; + +bool ValidateSynonymsAtLanguage(const smart_objects::SmartObject& language, + const std::string& language_name, + SynonymsMap& synonyms_map) { + if (!language[language_name].keyExists(json::vrSynonyms)) { + SDL_LOG_WARN(kQueryAppsValidationFailedPrefix + << "'languages.vrSynonyms' doesn't exist"); + return false; + } + const smart_objects::SmartArray* synonyms_array = + language[language_name][json::vrSynonyms].asArray(); + if (!synonyms_array) { + SDL_LOG_WARN(kQueryAppsValidationFailedPrefix + << "vrSynonyms is not array."); + return false; + } + const size_t synonyms_array_size = synonyms_array->size(); + if (synonyms_array_size < kVrArraySizeMin) { + SDL_LOG_WARN(kQueryAppsValidationFailedPrefix + << "vrSynomyms array has [" << synonyms_array_size + << "] size < allowed min size [" << kVrArraySizeMin << "]"); + return false; + } + if (synonyms_array_size > kVrArraySizeMax) { + SDL_LOG_WARN(kQueryAppsValidationFailedPrefix + << "vrSynomyms array size [" << synonyms_array_size + << "] exceeds maximum allowed size [" << kVrArraySizeMax + << "]"); + return false; + } + + for (std::size_t idx = 0; idx < synonyms_array_size; ++idx) { + const smart_objects::SmartObject& synonym = (*synonyms_array)[idx]; + const std::string vrSynonym = synonym.asString(); + if (vrSynonym.length() > kVrSynonymLengthMax) { + SDL_LOG_WARN(kQueryAppsValidationFailedPrefix + << "vrSYnomym item [" << idx << "] exceeds max length [" + << vrSynonym.length() << "]>[" << kVrSynonymLengthMax + << "]"); + return false; + } + if (vrSynonym.length() < kVrSynonymLengthMin) { + SDL_LOG_WARN(kQueryAppsValidationFailedPrefix + << "vrSYnomym item [" << idx << "] length [" + << vrSynonym.length() << "] is less then min length [" + << kVrSynonymLengthMin << "] allowed."); + return false; + } + // Verify duplicates + SynonymsMap::iterator synonyms_map_iter = synonyms_map.find(language_name); + if (synonyms_map_iter != synonyms_map.end()) { + if (!(*synonyms_map_iter).second.insert(vrSynonym).second) { + SDL_LOG_WARN(kQueryAppsValidationFailedPrefix + << "vrSYnomym item already defined [" << vrSynonym.c_str() + << "] for language [" << language_name << "]"); + return false; + } + } + } + return true; +} + +bool CheckMandatoryParametersPresent( + const smart_objects::SmartObject& app_data) { + if (!app_data.keyExists(json::android) && !app_data.keyExists(json::ios)) { + return false; + } + + if (app_data.keyExists(json::android) && + !app_data[json::android].keyExists(json::packageName)) { + return false; + } + + if (app_data.keyExists(json::ios) && + !app_data[json::ios].keyExists(json::urlScheme)) { + return false; + } + + if (!app_data.keyExists(json::appId)) { + return false; + } + + if (!app_data.keyExists(json::name)) { + return false; + } + + return true; +} + class QueryAppsDataValidator { public: - typedef std::set<std::string> SynonymsSet; - typedef std::map<std::string, SynonymsSet> SynonymsMap; - QueryAppsDataValidator(smart_objects::SmartObject& object, const ApplicationManager& manager) : data_(object), manager_(manager) {} @@ -298,96 +388,6 @@ class QueryAppsDataValidator { return true; } - bool ValidateSynonymsAtLanguage(const smart_objects::SmartObject& language, - const std::string& language_name, - SynonymsMap& synonyms_map) const { - if (!language[language_name].keyExists(json::vrSynonyms)) { - SDL_LOG_WARN(kQueryAppsValidationFailedPrefix - << "'languages.vrSynonyms' doesn't exist"); - return false; - } - const smart_objects::SmartArray* synonyms_array = - language[language_name][json::vrSynonyms].asArray(); - if (!synonyms_array) { - SDL_LOG_WARN(kQueryAppsValidationFailedPrefix - << "vrSynonyms is not array."); - return false; - } - const size_t synonyms_array_size = synonyms_array->size(); - if (synonyms_array_size < kVrArraySizeMin) { - SDL_LOG_WARN(kQueryAppsValidationFailedPrefix - << "vrSynomyms array has [" << synonyms_array_size - << "] size < allowed min size [" << kVrArraySizeMin << "]"); - return false; - } - if (synonyms_array_size > kVrArraySizeMax) { - SDL_LOG_WARN(kQueryAppsValidationFailedPrefix - << "vrSynomyms array size [" << synonyms_array_size - << "] exceeds maximum allowed size [" << kVrArraySizeMax - << "]"); - return false; - } - - for (std::size_t idx = 0; idx < synonyms_array_size; ++idx) { - const smart_objects::SmartObject& synonym = (*synonyms_array)[idx]; - const std::string vrSynonym = synonym.asString(); - if (vrSynonym.length() > kVrSynonymLengthMax) { - SDL_LOG_WARN(kQueryAppsValidationFailedPrefix - << "vrSYnomym item [" << idx << "] exceeds max length [" - << vrSynonym.length() << "]>[" << kVrSynonymLengthMax - << "]"); - return false; - } - if (vrSynonym.length() < kVrSynonymLengthMin) { - SDL_LOG_WARN(kQueryAppsValidationFailedPrefix - << "vrSYnomym item [" << idx << "] length [" - << vrSynonym.length() << "] is less then min length [" - << kVrSynonymLengthMin << "] allowed."); - return false; - } - // Verify duplicates - SynonymsMap::iterator synonyms_map_iter = - synonyms_map.find(language_name); - if (synonyms_map_iter != synonyms_map.end()) { - if (!(*synonyms_map_iter).second.insert(vrSynonym).second) { - SDL_LOG_WARN(kQueryAppsValidationFailedPrefix - << "vrSYnomym item already defined [" - << vrSynonym.c_str() << "] for language [" - << language_name << "]"); - return false; - } - } - } - return true; - } - - bool CheckMandatoryParametersPresent( - const smart_objects::SmartObject& app_data) const { - if (!app_data.keyExists(json::android) && !app_data.keyExists(json::ios)) { - return false; - } - - if (app_data.keyExists(json::android) && - !app_data[json::android].keyExists(json::packageName)) { - return false; - } - - if (app_data.keyExists(json::ios) && - !app_data[json::ios].keyExists(json::urlScheme)) { - return false; - } - - if (!app_data.keyExists(json::appId)) { - return false; - } - - if (!app_data.keyExists(json::name)) { - return false; - } - - return true; - } - smart_objects::SmartObject& data_; std::set<std::string> applications_id_set_; const ApplicationManager& manager_; @@ -466,7 +466,7 @@ void SystemRequest::Run() { SDL_LOG_TRACE("Request subtype: " << request_subtype << " is ALLOWED"); } - std::string file_name = kSYNC; + std::string file_name; if ((*message_)[strings::msg_params].keyExists(strings::file_name)) { file_name = (*message_)[strings::msg_params][strings::file_name].asString(); } else { diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc index 824d1150b3..3da9206184 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/update_turn_list_request.cc @@ -112,9 +112,7 @@ void UpdateTurnListRequest::Run() { } } - smart_objects::SmartObject msg_params = - smart_objects::SmartObject(smart_objects::SmartType_Map); - msg_params = (*message_)[strings::msg_params]; + smart_objects::SmartObject msg_params = (*message_)[strings::msg_params]; if ((*message_)[strings::msg_params].keyExists(strings::turn_list)) { if (!CheckTurnListArray()) { diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc index d51790ea55..9e35e96ce3 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/commands/mobile/subscribe_vehicle_data_request.cc @@ -261,7 +261,7 @@ void SubscribeVehicleDataRequest::AddAlreadySubscribedVI( struct SubscribedToIVIPredicate { std::string vehicle_info_; - SubscribedToIVIPredicate(std::string vehicle_info) + explicit SubscribedToIVIPredicate(const std::string& vehicle_info) : vehicle_info_(vehicle_info) {} bool operator()(const ApplicationSharedPtr app) const { DCHECK_OR_RETURN(app, false); @@ -393,6 +393,7 @@ void SubscribeVehicleDataRequest::CheckVISubscriptions( return; } + // cppcheck-suppress knownConditionTrueFalse if (0 == subscribed_items && is_interface_available) { out_result_code = mobile_apis::Result::IGNORED; out_info = "Already subscribed on provided VehicleData."; diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/custom_vehicle_data_manager_impl.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/custom_vehicle_data_manager_impl.cc index b85fd5aaaf..af9d605ff0 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/custom_vehicle_data_manager_impl.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/custom_vehicle_data_manager_impl.cc @@ -161,7 +161,7 @@ smart_objects::SmartObject CustomVehicleDataManagerImpl::CreateHMIMessageParams( const policy_table::VehicleDataItem&)> ParamsConstructor; - auto fill_param = [](ParamsConstructor& constructor, + auto fill_param = [](const ParamsConstructor& constructor, const policy_table::VehicleDataItem& param, smart_objects::SmartObject* out_params) { DCHECK_OR_RETURN_VOID(out_params) @@ -354,12 +354,14 @@ void CustomVehicleDataManagerImpl::UpdateVehicleDataItems() { }; auto get_vehicle_data_history = - [&vehicle_data_items](std::string name) -> std::vector<VehicleDataItem> { + [&vehicle_data_items]( + const std::string& name) -> std::vector<VehicleDataItem> { std::vector<VehicleDataItem> result; - std::copy_if(vehicle_data_items.begin(), - vehicle_data_items.end(), - std::back_inserter(result), - [&name](VehicleDataItem& item) { return item.name == name; }); + std::copy_if( + vehicle_data_items.begin(), + vehicle_data_items.end(), + std::back_inserter(result), + [&name](const VehicleDataItem& item) { return item.name == name; }); std::sort(result.begin(), result.end(), diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc index 3687245066..131b5304c4 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_hmi_command_factory.cc @@ -60,7 +60,7 @@ namespace strings = app_mngr::strings; template <typename VehicleInfoCommandType> class VehicleInfoCommandCreator : public application_manager::CommandCreator { public: - VehicleInfoCommandCreator(const VehicleInfoCommandParams& params) + explicit VehicleInfoCommandCreator(const VehicleInfoCommandParams& params) : params_(params) {} private: @@ -85,7 +85,8 @@ template <> class VehicleInfoCommandCreator<VehicleInfoInvalidCommand> : public application_manager::CommandCreator { public: - VehicleInfoCommandCreator(const VehicleInfoCommandParams& params) { + // cppcheck-suppress unusedFunction //Used in VehicleInfoCommandCreatorFactory + explicit VehicleInfoCommandCreator(const VehicleInfoCommandParams& params) { UNUSED(params); } @@ -103,7 +104,8 @@ class VehicleInfoCommandCreator<VehicleInfoInvalidCommand> }; struct VehicleInfoCommandCreatorFactory { - VehicleInfoCommandCreatorFactory(const VehicleInfoCommandParams& params) + explicit VehicleInfoCommandCreatorFactory( + const VehicleInfoCommandParams& params) : params_(params) {} template <typename VehicleInfoCommandType> diff --git a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc index b2d7df5d28..77cb5e71d7 100644 --- a/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc +++ b/src/components/application_manager/rpc_plugins/vehicle_info_plugin/src/vehicle_info_mobile_command_factory.cc @@ -60,7 +60,7 @@ namespace strings = app_mngr::strings; template <typename VehicleInfoCommandType> class VehicleInfoCommandCreator : public application_manager::CommandCreator { public: - VehicleInfoCommandCreator(const VehicleInfoCommandParams& params) + explicit VehicleInfoCommandCreator(const VehicleInfoCommandParams& params) : params_(params) {} private: @@ -85,7 +85,7 @@ template <> class VehicleInfoCommandCreator<VehicleInfoInvalidCommand> : public application_manager::CommandCreator { public: - VehicleInfoCommandCreator(const VehicleInfoCommandParams& params) { + explicit VehicleInfoCommandCreator(const VehicleInfoCommandParams& params) { UNUSED(params); } @@ -103,7 +103,8 @@ class VehicleInfoCommandCreator<VehicleInfoInvalidCommand> }; struct VehicleInfoCommandCreatorFactory { - VehicleInfoCommandCreatorFactory(const VehicleInfoCommandParams& params) + explicit VehicleInfoCommandCreatorFactory( + const VehicleInfoCommandParams& params) : params_(params) {} template <typename VehicleInfoCommandType> diff --git a/src/components/application_manager/src/app_launch/app_launch_data_db.cc b/src/components/application_manager/src/app_launch/app_launch_data_db.cc index 7c015b0707..c9357a0ec5 100644 --- a/src/components/application_manager/src/app_launch/app_launch_data_db.cc +++ b/src/components/application_manager/src/app_launch/app_launch_data_db.cc @@ -278,10 +278,9 @@ std::vector<ApplicationDataPtr> AppLaunchDataDB::GetAppDataByDevMac( bool AppLaunchDataDB::Clear() { SDL_LOG_AUTO_TRACE(); - bool retVal = false; utils::dbms::SQLQuery query(db()); - retVal = query.Exec(kDropSchema); + bool retVal = query.Exec(kDropSchema); if (retVal) { SDL_LOG_INFO("App_Launch table had been cleared successfully"); diff --git a/src/components/application_manager/src/app_launch/apps_launcher.cc b/src/components/application_manager/src/app_launch/apps_launcher.cc index bf1fa2fb5d..1ee7bffb2a 100644 --- a/src/components/application_manager/src/app_launch/apps_launcher.cc +++ b/src/components/application_manager/src/app_launch/apps_launcher.cc @@ -56,7 +56,8 @@ void AppsLauncher::StartLaunching(ApplicationDataPtr app_data) { } struct AppLauncherFinder { - AppLauncherFinder(const ApplicationDataPtr& app_data) : app_data_(app_data) {} + explicit AppLauncherFinder(const ApplicationDataPtr& app_data) + : app_data_(app_data) {} bool operator()(const AppsLauncher::LauncherPtr& launcher) const { DCHECK_OR_RETURN(launcher->app_data_ && app_data_, false) return *launcher->app_data_ == *app_data_; diff --git a/src/components/application_manager/src/app_launch/device_apps_launcher.cc b/src/components/application_manager/src/app_launch/device_apps_launcher.cc index 0a1bea3714..5f36e41efb 100644 --- a/src/components/application_manager/src/app_launch/device_apps_launcher.cc +++ b/src/components/application_manager/src/app_launch/device_apps_launcher.cc @@ -68,15 +68,6 @@ class Launcher { LaunchNext(); } - void OnAppRegistered(const ApplicationDataPtr& app_data) { - std::vector<ApplicationDataPtr>& apps = apps_on_device_->second; - std::vector<ApplicationDataPtr>::iterator it = - std::find(apps.begin(), apps.end(), app_data); - if (it != apps.end()) { - apps.erase(it); - } - } - void Clear() { gap_between_app_timer_.Stop(); wait_before_launch_timer_.Stop(); diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index 6bc970c8a3..9b31d57ca0 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -67,7 +67,7 @@ smart_objects::SmartObject AppServiceManager::PublishAppService( const bool mobile_service, const uint32_t connection_key) { SDL_LOG_AUTO_TRACE(); - std::string str_to_hash = ""; + std::string str_to_hash; std::string service_id = ""; std::string service_type = manifest[strings::service_type].asString(); @@ -413,10 +413,10 @@ bool AppServiceManager::ActivateAppService(const std::string service_id) { EnumConversionHelper<mobile_apis::AppServiceType::eType>::EnumToString( mobile_apis::AppServiceType::NAVIGATION, &navi_service_type); if (service_type == navi_service_type) { - smart_objects::SmartObject msg_params; - msg_params[strings::system_capability][strings::system_capability_type] = + smart_objects::SmartObject params; + params[strings::system_capability][strings::system_capability_type] = mobile_apis::SystemCapabilityType::NAVIGATION; - MessageHelper::BroadcastCapabilityUpdate(msg_params, app_manager_); + MessageHelper::BroadcastCapabilityUpdate(params, app_manager_); } return true; } diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 2edf3860d6..cbfb87023d 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -311,8 +311,9 @@ bool ApplicationImpl::webengine_projection_enabled() const { struct StateIDComparator { HmiState::StateID state_id_; - StateIDComparator(HmiState::StateID state_id) : state_id_(state_id) {} - bool operator()(const HmiStatePtr cur) { + explicit StateIDComparator(HmiState::StateID state_id) + : state_id_(state_id) {} + bool operator()(const HmiStatePtr cur) const { return cur->state_id() == state_id_; } }; @@ -475,10 +476,6 @@ void ApplicationImpl::set_is_media_application(bool option) { is_media_ = option; } -bool IsTTSState(const HmiStatePtr state) { - return state->state_id() == HmiState::STATE_ID_TTS_SESSION; -} - void ApplicationImpl::set_tts_properties_in_none(bool active) { tts_properties_in_none_ = active; } @@ -660,7 +657,7 @@ void ApplicationImpl::WakeUpStreaming( if (ServiceType::kMobileNav == service_type) { { // reduce the range of video_streaming_suspended_lock_ - sync_primitives::AutoLock lock(video_streaming_suspended_lock_); + sync_primitives::AutoLock auto_lock(video_streaming_suspended_lock_); if (video_streaming_suspended_) { application_manager_.OnAppStreaming(app_id(), service_type, true); application_manager_.ProcessOnDataStreamingNotification( @@ -673,7 +670,7 @@ void ApplicationImpl::WakeUpStreaming( timer::kPeriodic); } else if (ServiceType::kAudio == service_type) { { // reduce the range of audio_streaming_suspended_lock_ - sync_primitives::AutoLock lock(audio_streaming_suspended_lock_); + sync_primitives::AutoLock auto_lock(audio_streaming_suspended_lock_); if (audio_streaming_suspended_) { application_manager_.OnAppStreaming(app_id(), service_type, true); application_manager_.ProcessOnDataStreamingNotification( @@ -940,10 +937,7 @@ bool ApplicationImpl::AreCommandLimitsExceeded( limit.first = current; limit.second = 1; - return false; - - break; } // In case of policy table values, there is EVEN limitation for number of // commands per minute, e.g. 10 command per minute i.e. 1 command per 6 sec @@ -984,7 +978,6 @@ bool ApplicationImpl::AreCommandLimitsExceeded( cmd_number_to_time_limits_[cmd_id] = {current, dummy_limit}; return false; - break; } default: { SDL_LOG_WARN("Limit source is not implemented."); @@ -1163,10 +1156,10 @@ void ApplicationImpl::SubscribeToSoftButtons( struct FindSoftButtonId { uint32_t soft_button_id_; - FindSoftButtonId(const uint32_t soft_button_id) + explicit FindSoftButtonId(const uint32_t soft_button_id) : soft_button_id_(soft_button_id) {} - bool operator()(const std::pair<uint32_t, WindowID>& element) { + bool operator()(const std::pair<uint32_t, WindowID>& element) const { return soft_button_id_ == element.first; } }; diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 1823458ce0..90855fa9ee 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -693,9 +693,9 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( bool is_mismatched_cloud_app = false; if (apps_to_register_.end() == it) { - DevicePredicate finder(application->device()); + DevicePredicate device_finder(application->device()); it = std::find_if( - apps_to_register_.begin(), apps_to_register_.end(), finder); + apps_to_register_.begin(), apps_to_register_.end(), device_finder); bool found = apps_to_register_.end() != it; is_mismatched_cloud_app = found && (*it)->is_cloud_app() && @@ -3083,11 +3083,11 @@ void ApplicationManagerImpl::UnregisterAllApplications() { SDL_LOG_DEBUG("Unregister reason " << unregister_reason_); SetHMICooperating(false); - bool is_ignition_off = false; + using namespace mobile_api::AppInterfaceUnregisteredReason; using namespace helpers; - is_ignition_off = + bool is_ignition_off = Compare<eType, EQ, ONE>(unregister_reason_, IGNITION_OFF, INVALID_ENUM); bool is_unexpected_disconnect = Compare<eType, NEQ, ALL>( @@ -3846,9 +3846,7 @@ bool ApplicationManagerImpl::ResetVrHelpTitleItems( } const std::string& vr_help_title = get_settings().vr_help_title(); - smart_objects::SmartObject so_vr_help_title = - smart_objects::SmartObject(smart_objects::SmartType_String); - so_vr_help_title = vr_help_title; + smart_objects::SmartObject so_vr_help_title(vr_help_title); app->reset_vr_help_title(); app->reset_vr_help(); @@ -4380,7 +4378,7 @@ void ApplicationManagerImpl::OnUpdateHMIAppType( std::vector<std::string> hmi_types_from_policy; smart_objects::SmartObject transform_app_hmi_types( smart_objects::SmartType_Array); - bool flag_diffirence_app_hmi_type = false; + bool flag_diffirence_app_hmi_type; DataAccessor<ApplicationSet> accessor(applications()); for (ApplicationSetIt it = accessor.GetData().begin(); it != accessor.GetData().end(); @@ -4389,7 +4387,6 @@ void ApplicationManagerImpl::OnUpdateHMIAppType( if (it_app_hmi_types_from_policy != app_hmi_types.end() && ((it_app_hmi_types_from_policy->second).size())) { - flag_diffirence_app_hmi_type = false; hmi_types_from_policy = (it_app_hmi_types_from_policy->second); if (transform_app_hmi_types.length()) { @@ -4611,7 +4608,6 @@ void ApplicationManagerImpl::SendGetIconUrlNotifications( continue; } - std::string endpoint = app_icon_it->second.endpoint; bool pending_request = app_icon_it->second.pending_request; if (pending_request) { @@ -4942,7 +4938,7 @@ void ApplicationManagerImpl::SetMockMediaManager( #endif // BUILD_TESTS struct MobileAppIdPredicate { std::string policy_app_id_; - MobileAppIdPredicate(const std::string& policy_app_id) + explicit MobileAppIdPredicate(const std::string& policy_app_id) : policy_app_id_(policy_app_id) {} bool operator()(const ApplicationSharedPtr app) const { return app ? policy_app_id_ == app->policy_app_id() : false; @@ -4951,7 +4947,8 @@ struct MobileAppIdPredicate { struct TakeDeviceHandle { public: - TakeDeviceHandle(const ApplicationManager& app_mngr) : app_mngr_(app_mngr) {} + explicit TakeDeviceHandle(const ApplicationManager& app_mngr) + : app_mngr_(app_mngr) {} std::string operator()(ApplicationSharedPtr& app) { DCHECK_OR_RETURN(app, ""); return MessageHelper::GetDeviceMacAddressForHandle(app->device(), diff --git a/src/components/application_manager/src/application_state.cc b/src/components/application_manager/src/application_state.cc index 2fb583ab3e..1ec4abaed7 100644 --- a/src/components/application_manager/src/application_state.cc +++ b/src/components/application_manager/src/application_state.cc @@ -42,7 +42,7 @@ namespace { struct StateIDComparator { application_manager::HmiState::StateID state_id_; - StateIDComparator(application_manager::HmiState::StateID state_id) + explicit StateIDComparator(application_manager::HmiState::StateID state_id) : state_id_(state_id) {} bool operator()(const application_manager::HmiStatePtr cur) const { return cur->state_id() == state_id_; @@ -209,8 +209,8 @@ void ApplicationState::EraseHMIState(HmiStates& hmi_states, } else { HmiStates::iterator next = it; HmiStates::iterator prev = it; - next++; - prev--; + ++next; + --prev; if (hmi_states.end() != next) { HmiStatePtr next_state = *next; diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index 938b7afc99..08bf25de54 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -846,7 +846,6 @@ void CommandRequestImpl::GetInfo( mobile_apis::Result::eType CommandRequestImpl::PrepareResultCodeForResponse( const ResponseInfo& first, const ResponseInfo& second) { SDL_LOG_AUTO_TRACE(); - mobile_apis::Result::eType result_code = mobile_apis::Result::INVALID_ENUM; if (IsResultCodeUnsupported(first, second) || IsResultCodeUnsupported(second, first)) { return mobile_apis::Result::UNSUPPORTED_RESOURCE; @@ -867,7 +866,7 @@ mobile_apis::Result::eType CommandRequestImpl::PrepareResultCodeForResponse( if (!second.is_unsupported_resource) { second_result = second.result_code; } - result_code = + mobile_apis::Result::eType result_code = MessageHelper::HMIToMobileResult(std::max(first_result, second_result)); return result_code; } diff --git a/src/components/application_manager/src/event_engine/event_dispatcher_impl.cc b/src/components/application_manager/src/event_engine/event_dispatcher_impl.cc index 3d294f0035..7392731d70 100644 --- a/src/components/application_manager/src/event_engine/event_dispatcher_impl.cc +++ b/src/components/application_manager/src/event_engine/event_dispatcher_impl.cc @@ -78,7 +78,7 @@ void EventDispatcherImpl::add_observer(const Event::EventID& event_id, } struct IdCheckFunctor { - IdCheckFunctor(const unsigned long id) : target_id(id) {} + explicit IdCheckFunctor(const unsigned long id) : target_id(id) {} bool operator()(const EventObserver* obs) const { return (obs->id() == target_id); diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc index c19b70f2f5..c207f7fa00 100644 --- a/src/components/application_manager/src/hmi_capabilities_impl.cc +++ b/src/components/application_manager/src/hmi_capabilities_impl.cc @@ -610,7 +610,7 @@ struct JsonCapabilitiesGetter { * @param json_cache_node reference to cached JSON capabilities node */ JsonCapabilitiesGetter(Json::Value& json_default_node, - Json::Value& json_cache_node) + const Json::Value& json_cache_node) : json_default_node_(json_default_node) , json_cache_node_(json_cache_node) {} @@ -941,18 +941,17 @@ bool HMICapabilitiesImpl::LoadCapabilitiesFromFile() { pcm_capabilities_so); set_pcm_stream_capabilities(pcm_capabilities_so); } - auto ui_hmi_zone_capabilities_node = json_ui_getter.GetJsonMember(hmi_response::hmi_zone_capabilities, hmi_apis::FunctionID::UI_GetCapabilities, requests_required_for_capabilities_); if (!ui_hmi_zone_capabilities_node.isNull()) { - smart_objects::SmartObject hmi_zone_capabilities_so = - smart_objects::SmartObject(smart_objects::SmartType_Array); auto enum_value = ConvertStringToEnum<hmi_apis::Common_HmiZoneCapabilities::eType>( ui_hmi_zone_capabilities_node.asString()); if (hmi_apis::Common_HmiZoneCapabilities::INVALID_ENUM != enum_value) { + smart_objects::SmartObject hmi_zone_capabilities_so( + smart_objects::SmartType_Array); hmi_zone_capabilities_so = enum_value; set_hmi_zone_capabilities(hmi_zone_capabilities_so); } diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index 3dadd8c193..fde2022364 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -426,6 +426,8 @@ const StateID2StrMap kStateID2StrMap = HmiState::StateID::STATE_ID_EMBEDDED_NAVI, "EMBEDDED_NAVI"); } // anonymous namespace +// cppcheck-suppress unusedFunction //Used in the next +// overload of operator<< std::ostream& operator<<(std::ostream& os, const HmiState::StateID src) { try { os << kStateID2StrMap.left.at(src); diff --git a/src/components/application_manager/src/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index c5cc11bbe5..ed8b801377 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -107,7 +107,7 @@ bool ValidateSoftButtons(smart_objects::SmartObject& soft_buttons) { struct GroupsAppender : std::unary_function<void, const PermissionsList::value_type&> { - GroupsAppender(smart_objects::SmartObject& groups) + explicit GroupsAppender(smart_objects::SmartObject& groups) : groups_(groups), index_(0) {} void operator()(const PermissionsList::value_type& item) { @@ -135,7 +135,7 @@ struct GroupsAppender struct ExternalConsentStatusAppender : std::unary_function<void, const policy::ExternalConsentStatus::value_type&> { - ExternalConsentStatusAppender(smart_objects::SmartObject& status) + explicit ExternalConsentStatusAppender(smart_objects::SmartObject& status) : status_(status), index_(0) {} void operator()(const policy::ExternalConsentStatus::value_type& item) { @@ -710,23 +710,23 @@ void MessageHelper::SendDeleteSubmenuRequest(smart_objects::SmartObject* cmd, if ((*cmd)[strings::menu_id].asInt() == (*it->second)[strings::menu_params][hmi_request::parent_id].asInt()) { - SmartObject msg_params = SmartObject(smart_objects::SmartType_Map); - msg_params[strings::cmd_id] = (*it->second)[strings::cmd_id].asInt(); - msg_params[strings::app_id] = application->app_id(); - msg_params[strings::grammar_id] = application->get_grammar_id(); - msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command; + SmartObject params = SmartObject(smart_objects::SmartType_Map); + params[strings::cmd_id] = (*it->second)[strings::cmd_id].asInt(); + params[strings::app_id] = application->app_id(); + params[strings::grammar_id] = application->get_grammar_id(); + params[strings::type] = hmi_apis::Common_VRCommandType::Command; - SmartObjectSPtr message = CreateMessageForHMI( + SmartObjectSPtr hmi_message = CreateMessageForHMI( hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); - DCHECK(message); + DCHECK(hmi_message); - SmartObject& object = *message; - object[strings::params][strings::function_id] = + SmartObject& smart_object = *hmi_message; + smart_object[strings::params][strings::function_id] = hmi_apis::FunctionID::VR_DeleteCommand; - object[strings::msg_params] = msg_params; + smart_object[strings::msg_params] = params; - app_mngr.GetRPCService().ManageHMICommand(message); + app_mngr.GetRPCService().ManageHMICommand(hmi_message); } } } @@ -767,9 +767,7 @@ void MessageHelper::SendResetPropertiesRequest(ApplicationSharedPtr application, using namespace smart_objects; { - SmartObject msg_params = SmartObject(smart_objects::SmartType_Map); - - msg_params = *MessageHelper::CreateAppVrHelp(application); + SmartObject msg_params = *MessageHelper::CreateAppVrHelp(application); msg_params[hmi_request::menu_title] = ""; smart_objects::SmartObject keyboard_properties = @@ -1060,7 +1058,7 @@ void MessageHelper::CreateGetVehicleDataRequest( smart_objects::SmartObject(smart_objects::SmartType_Map); for (std::vector<std::string>::const_iterator it = params.begin(); it != params.end(); - it++) { + ++it) { (*request)[strings::msg_params][*it] = true; } app_mngr.GetRPCService().ManageHMICommand(request); @@ -1337,8 +1335,6 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI( ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { SDL_LOG_AUTO_TRACE(); - uint32_t correlation_id = app_mngr.GetNextHMICorrelationID(); - smart_objects::SmartObjectList requests; if (app.use_count() == 0) { SDL_LOG_ERROR("Invalid application"); @@ -1398,7 +1394,7 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI( // TTS global properties if (can_send_vr && (app->help_prompt() || app->timeout_prompt())) { - correlation_id = app_mngr.GetNextHMICorrelationID(); + uint32_t correlation_id = app_mngr.GetNextHMICorrelationID(); smart_objects::SmartObjectSPtr tts_global_properties = CreateMessageForHMI(hmi_apis::messageType::request, correlation_id); if (!tts_global_properties) { @@ -1657,8 +1653,6 @@ MessageHelper::CreateAddVRCommandRequestFromChoiceToHMI( msg_params[strings::cmd_id] = (*(it->second))[strings::choice_set][j][strings::choice_id]; msg_params[strings::vr_commands] = - smart_objects::SmartObject(smart_objects::SmartType_Array); - msg_params[strings::vr_commands] = (*(it->second))[strings::choice_set][j][strings::vr_commands]; msg_params[strings::type] = hmi_apis::Common_VRCommandType::Choice; msg_params[strings::grammar_id] = choice_grammar_id; @@ -3460,10 +3454,7 @@ mobile_apis::Result::eType MessageHelper::ProcessSoftButtons( } break; } - default: { - continue; - break; - } + default: { continue; } } soft_buttons[j++] = request_soft_buttons[i]; diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 8ec21660a8..280e1cace5 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -2394,8 +2394,6 @@ bool PolicyHandler::CheckAppServiceParameters( const std::string& requested_service_name, const std::string& requested_service_type, smart_objects::SmartArray* requested_handled_rpcs) const { - std::string service_name = std::string(); - std::string service_type = std::string(); std::vector<int32_t> handled_rpcs = {}; policy_table::AppServiceParameters app_service_parameters = diff --git a/src/components/application_manager/src/request_controller.cc b/src/components/application_manager/src/request_controller.cc index d2db9fced2..a34457ff66 100644 --- a/src/components/application_manager/src/request_controller.cc +++ b/src/components/application_manager/src/request_controller.cc @@ -81,7 +81,7 @@ void RequestController::InitializeThreadpool() { pool_state_ = TPoolState::STARTED; char name[50]; for (uint32_t i = 0; i < pool_size_; i++) { - snprintf(name, sizeof(name) / sizeof(name[0]), "AM Pool %d", i); + snprintf(name, sizeof(name) / sizeof(name[0]), "AM Pool %u", i); pool_.push_back(threads::CreateThread(name, new Worker(this))); pool_[i]->Start(); SDL_LOG_DEBUG("Request thread initialized: " << name); diff --git a/src/components/application_manager/src/request_info.cc b/src/components/application_manager/src/request_info.cc index 1149c9aaf9..e1fffdf6fe 100644 --- a/src/components/application_manager/src/request_info.cc +++ b/src/components/application_manager/src/request_info.cc @@ -219,7 +219,7 @@ bool RequestInfoSet::Erase(const RequestInfoPtr request_info) { DCHECK(request_info == found); time_sorted_pending_requests_.erase(it); CheckSetSizes(); - return 1 == erased_count; + return true; } CheckSetSizes(); return false; diff --git a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc index 8295ddd1f9..545560c132 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -60,7 +60,8 @@ static mobile_api::HMILevel::eType PickHigherHmiLevel( mobile_api::HMILevel::eType val1, mobile_api::HMILevel::eType val2); static mobile_api::HMILevel::eType PickLowerHmiLevel( mobile_api::HMILevel::eType val1, mobile_api::HMILevel::eType val2); -static mobile_api::HMILevel::eType ConvertHmiLevelString(const std::string str); +static mobile_api::HMILevel::eType ConvertHmiLevelString( + const std::string& str); SDL_CREATE_LOG_VARIABLE("Resumption") @@ -1037,7 +1038,7 @@ static mobile_api::HMILevel::eType PickLowerHmiLevel( } static mobile_api::HMILevel::eType ConvertHmiLevelString( - const std::string str) { + const std::string& str) { using namespace mobile_apis; if ("BACKGROUND" == str) { @@ -1046,8 +1047,6 @@ static mobile_api::HMILevel::eType ConvertHmiLevelString( return HMILevel::HMI_FULL; } else if ("LIMITED" == str) { return HMILevel::HMI_LIMITED; - } else if ("NONE" == str) { - return HMILevel::HMI_NONE; } else { return HMILevel::HMI_NONE; } diff --git a/src/components/application_manager/src/resumption/resumption_data.cc b/src/components/application_manager/src/resumption/resumption_data.cc index 558724ecdc..95dd331b88 100644 --- a/src/components/application_manager/src/resumption/resumption_data.cc +++ b/src/components/application_manager/src/resumption/resumption_data.cc @@ -186,7 +186,7 @@ smart_objects::SmartObject ResumptionData::GetApplicationFiles( int i = 0; for (AppFilesMap::const_iterator file_it = app_files.begin(); file_it != app_files.end(); - file_it++) { + ++file_it) { const AppFile& file = file_it->second; if (file.is_persistent) { smart_objects::SmartObject file_data = diff --git a/src/components/application_manager/src/resumption/resumption_data_db.cc b/src/components/application_manager/src/resumption/resumption_data_db.cc index 88f28a41a3..f00b100913 100644 --- a/src/components/application_manager/src/resumption/resumption_data_db.cc +++ b/src/components/application_manager/src/resumption/resumption_data_db.cc @@ -1756,7 +1756,6 @@ bool ResumptionDataDB::ExecInsertChoice( field "idimage" from table "choice" = 4 field "idsecondaryImage" from table "choice" = 5*/ int64_t image_primary_key = 0; - int64_t choice_primary_key = 0; size_t length_choice_array = choice_array.length(); for (size_t i = 0; i < length_choice_array; ++i) { insert_choice.Bind(0, (choice_array[i][strings::choice_id]).asInt()); @@ -1789,7 +1788,7 @@ bool ResumptionDataDB::ExecInsertChoice( SDL_LOG_WARN("Problem with execution insert_choice query"); return false; } - choice_primary_key = insert_choice.LastInsertId(); + int64_t choice_primary_key = insert_choice.LastInsertId(); if ((!ExecInsertVrCommands(choice_primary_key, choice_array[i][strings::vr_commands], @@ -2082,7 +2081,6 @@ bool ResumptionDataDB::InsertCommandsData( } utils::dbms::SQLQuery query_insert_command(db()); int64_t image_primary_key = 0; - int64_t command_primary_key = 0; if (!query_insert_command.Prepare(kInsertToCommand)) { SDL_LOG_WARN("Problem with verification queries for insertion commands"); @@ -2121,7 +2119,7 @@ bool ResumptionDataDB::InsertCommandsData( SDL_LOG_WARN("Incorrect insertion of command data to DB"); return false; } - command_primary_key = query_insert_command.LastInsertId(); + int64_t command_primary_key = query_insert_command.LastInsertId(); if (commands[i].keyExists(strings::vr_commands)) { if (!ExecInsertVrCommands(command_primary_key, commands[i][strings::vr_commands], diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index 2eb813e69f..e7ec998a2f 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -394,7 +394,7 @@ void StateControllerImpl::HmiLevelConflictResolver::operator()( result_video_state = mobile_apis::VideoStreamingState::STREAMABLE; } - mobile_apis::HMILevel::eType result_hmi_level = state_to_resolve->hmi_level(); + mobile_apis::HMILevel::eType result_hmi_level; using namespace helpers; if (mobile_apis::VideoStreamingState::STREAMABLE == result_video_state || @@ -803,11 +803,11 @@ void StateControllerImpl::on_event(const event_engine::Event& event) { case FunctionID::BasicCommunication_OnEventChanged: { bool is_active = message[strings::msg_params][hmi_notification::is_active].asBool(); - const uint32_t id = + const uint32_t event_id = message[strings::msg_params][hmi_notification::event_name].asUInt(); // TODO(AOleynik): Add verification/conversion check here const Common_EventTypes::eType state_id = - static_cast<Common_EventTypes::eType>(id); + static_cast<Common_EventTypes::eType>(event_id); if (is_active) { if (Common_EventTypes::AUDIO_SOURCE == state_id) { ApplyTempState<HmiState::STATE_ID_AUDIO_SOURCE>(); diff --git a/src/components/application_manager/test/resumption/resumption_data_test.cc b/src/components/application_manager/test/resumption/resumption_data_test.cc index 12a38e1bc4..d5228934db 100644 --- a/src/components/application_manager/test/resumption/resumption_data_test.cc +++ b/src/components/application_manager/test/resumption/resumption_data_test.cc @@ -176,7 +176,7 @@ void ResumptionDataTest::CheckChoiceSet(sm::SmartObject& res_list) { sm::SmartObject command = res_list[i][am::strings::choice_set][j]; EXPECT_EQ(i + j, command[am::strings::choice_id].asUInt()); char numb[12]; - std::snprintf(numb, 12, "%d", i + j); + std::snprintf(numb, 12, "%u", i + j); std::string test_choice = (*test_choiceset_map[i])[am::strings::choice_set][j] [am::strings::vr_commands][0] @@ -340,11 +340,10 @@ void ResumptionDataTest::CheckTimeoutPrompt( void ResumptionDataTest::CheckVRHelp(sm::SmartObject& res_list) { std::string text; - int position; for (uint i = 0; i < kCountOfVrhelptitle_; ++i) { text = (*vr_help_)[i][am::strings::text].asString(); EXPECT_EQ(text, res_list[i][am::strings::text].asString()); - position = (*vr_help_)[i][am::strings::position].asInt(); + int position = (*vr_help_)[i][am::strings::position].asInt(); EXPECT_EQ(position, res_list[i][am::strings::position].asInt()); } } @@ -517,7 +516,7 @@ void ResumptionDataTest::SetCommands() { sm::SmartObject sm_icon; for (uint32_t i = 0; i < kCountOfCommands_; ++i) { char numb[12]; - std::snprintf(numb, 12, "%d", i); + std::snprintf(numb, 12, "%u", i); sm_comm[am::strings::cmd_id] = i; sm_comm[am::strings::menu_params][am::strings::position] = i; sm_comm[am::strings::menu_params][am::hmi_request::parent_id] = i; @@ -526,7 +525,7 @@ void ResumptionDataTest::SetCommands() { for (uint32_t j = 0; j < kCountOfChoice_; ++j) { char vr[12]; - std::snprintf(vr, 12, "%d", i + j); + std::snprintf(vr, 12, "%u", i + j); vr_commandsvector[j] = "VrCommand " + std::string(vr); } sm_comm[am::strings::vr_commands] = vr_commandsvector; @@ -544,7 +543,7 @@ void ResumptionDataTest::SetSubmenues() { sm::SmartObject sm_comm; for (uint32_t i = 10; i < kCountOfSubmenues_ + 10; ++i) { char numb[12]; - std::snprintf(numb, 12, "%d", i); + std::snprintf(numb, 12, "%u", i); sm_comm[am::strings::menu_id] = i; sm_comm[am::strings::position] = i; sm_comm[am::strings::menu_name] = "SubMenu" + std::string(numb); @@ -563,7 +562,7 @@ void ResumptionDataTest::SetChoiceSet() { for (uint32_t i = 0; i < kCountOfChoiceSets_; ++i) { for (uint32_t j = 0; j < kCountOfChoice_; ++j) { char numb[12]; - std::snprintf(numb, 12, "%d", i + j); + std::snprintf(numb, 12, "%u", i + j); choice[am::strings::choice_id] = i + j; vr_commandsvector[0] = "ChoiceSet VrCommand " + std::string(numb); @@ -596,11 +595,10 @@ void ResumptionDataTest::SetChoiceSet() { void ResumptionDataTest::SetAppFiles() { am::AppFile test_file; - int file_types; for (uint i = 0; i < kCountOfFiles_; ++i) { char numb[12]; std::snprintf(numb, 12, "%d", i); - file_types = i; + int file_types = i; test_file.is_persistent = true; test_file.is_download_complete = true; test_file.file_type = static_cast<FileType::eType>(file_types); diff --git a/src/components/config_profile/src/ini_file.cc b/src/components/config_profile/src/ini_file.cc index f549f4b915..dd64f48afa 100644 --- a/src/components/config_profile/src/ini_file.cc +++ b/src/components/config_profile/src/ini_file.cc @@ -152,13 +152,15 @@ char* ini_read_value(const char* fname, return NULL; } +#ifdef BUILD_TESTS +// cppcheck-suppress unusedFunction //Used in unit tests char ini_write_value(const char* fname, const char* chapter, const char* item, const char* value, uint8_t flag) { FILE *rd_fp, *wr_fp = 0; - uint16_t i, cr_count; + uint16_t cr_count; int32_t wr_result; bool chapter_found = false; bool value_written = false; @@ -186,11 +188,9 @@ char ini_write_value(const char* fname, #if USE_MKSTEMP { const char* temp_str = "./"; - int32_t fd = -1; if (temp_str) { snprintf(temp_fname, PATH_MAX, "%s/ini.XXXXXX", temp_str); - - fd = mkstemp(temp_fname); + int32_t fd = mkstemp(temp_fname); if (-1 == fd) { fclose(rd_fp); return FALSE; @@ -244,7 +244,7 @@ char ini_write_value(const char* fname, first chapter is significant */ value_written = true; } else if (result == INI_RIGHT_ITEM) { - for (i = 0; i < cr_count; i++) + for (uint16_t i = 0; i < cr_count; i++) fprintf(wr_fp, "\n"); cr_count = 0; wr_result = fprintf(wr_fp, "%s=%s\n", item, value); @@ -286,10 +286,10 @@ char ini_write_value(const char* fname, return (value_written); } +#endif // BUILD_TESTS Ini_search_id ini_parse_line(const char* line, const char* tag, char* value) { const char* line_ptr; - char* temp_ptr; char temp_str[INI_LINE_LEN] = ""; *temp_str = '\0'; @@ -332,7 +332,7 @@ Ini_search_id ini_parse_line(const char* line, const char* tag, char* value) { return INI_NOTHING; snprintf(temp_str, INI_LINE_LEN, "%s", line_ptr); - temp_ptr = strrchr(temp_str, ']'); + char* temp_ptr = strrchr(temp_str, ']'); if (NULL == temp_ptr) { return INI_NOTHING; } else { diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc index a86d09da94..d9204acf90 100644 --- a/src/components/config_profile/src/profile.cc +++ b/src/components/config_profile/src/profile.cc @@ -1739,8 +1739,7 @@ void Profile::UpdateValues() { help_prompt_.clear(); std::string help_prompt_value; if (ReadValue(&help_prompt_value, kGlobalPropertiesSection, kHelpPromptKey)) { - char* str = NULL; - str = strtok(const_cast<char*>(help_prompt_value.c_str()), ","); + char* str = strtok(const_cast<char*>(help_prompt_value.c_str()), ","); while (str != NULL) { // Default prompt should have delimiter included for each item const std::string prompt_item = std::string(str) + tts_delimiter_; @@ -1759,8 +1758,7 @@ void Profile::UpdateValues() { std::string timeout_prompt_value; if (ReadValue( &timeout_prompt_value, kGlobalPropertiesSection, kTimeoutPromptKey)) { - char* str = NULL; - str = strtok(const_cast<char*>(timeout_prompt_value.c_str()), ","); + char* str = strtok(const_cast<char*>(timeout_prompt_value.c_str()), ","); while (str != NULL) { // Default prompt should have delimiter included for each item const std::string prompt_item = std::string(str) + tts_delimiter_; @@ -1784,8 +1782,7 @@ void Profile::UpdateValues() { vr_commands_.clear(); std::string vr_help_command_value; if (ReadValue(&vr_help_command_value, kVrCommandsSection, kHelpCommandKey)) { - char* str = NULL; - str = strtok(const_cast<char*>(vr_help_command_value.c_str()), ","); + char* str = strtok(const_cast<char*>(vr_help_command_value.c_str()), ","); while (str != NULL) { const std::string vr_item = str; vr_commands_.push_back(vr_item); @@ -1867,8 +1864,8 @@ void Profile::UpdateValues() { "", kMainSection, kSupportedDiagModesKey)) { - char* str = NULL; - str = strtok(const_cast<char*>(supported_diag_modes_value.c_str()), ","); + char* str = + strtok(const_cast<char*>(supported_diag_modes_value.c_str()), ","); while (str != NULL) { errno = 0; uint32_t user_value = strtol(str, NULL, 16); diff --git a/src/components/connection_handler/src/connection.cc b/src/components/connection_handler/src/connection.cc index 14e2b83848..03915516c3 100644 --- a/src/components/connection_handler/src/connection.cc +++ b/src/components/connection_handler/src/connection.cc @@ -110,7 +110,7 @@ Connection::~Connection() { << static_cast<int>(session_it->first) << " from Session/Connection Map in Connection Destructor"); connection_handler_->RemoveSession(session_it->first); - session_it++; + ++session_it; } session_map_.clear(); @@ -324,7 +324,7 @@ uint8_t Connection::RemoveSecondaryServices( removed_services_list.push_back(service_it->service_type); service_it = service_list.erase(service_it); } else { - service_it++; + ++service_it; } } diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index 827d6fa17e..8cefa390e8 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -215,7 +215,7 @@ namespace { struct DeviceFinder { explicit DeviceFinder(const std::string& device_uid) : device_uid_(device_uid) {} - bool operator()(const DeviceMap::value_type& device) { + bool operator()(const DeviceMap::value_type& device) const { return device_uid_ == device.second.mac_address(); } @@ -1169,7 +1169,7 @@ const uint8_t ConnectionHandlerImpl::GetSessionIdFromSecondaryTransport( transport_manager::ConnectionUID secondary_transport_id) const { sync_primitives::AutoLock auto_lock(session_connection_map_lock_ptr_); SessionConnectionMap::const_iterator it = session_connection_map_.begin(); - for (; session_connection_map_.end() != it; it++) { + for (; session_connection_map_.end() != it; ++it) { SessionTransports st = it->second; if (st.secondary_transport == secondary_transport_id) { return it->first; diff --git a/src/components/formatters/src/CFormatterJsonBase.cc b/src/components/formatters/src/CFormatterJsonBase.cc index e5354d5326..d88ffc7158 100644 --- a/src/components/formatters/src/CFormatterJsonBase.cc +++ b/src/components/formatters/src/CFormatterJsonBase.cc @@ -95,7 +95,7 @@ void ns_smart_device_link::ns_json_handler::formatters::CFormatterJsonBase:: for (std::set<std::string>::const_iterator key = keys.begin(); key != keys.end(); - key++) { + ++key) { Json::Value value(Json::nullValue); objToJsonValue(obj.getElement(*key), value); diff --git a/src/components/formatters/test/include/formatters/SmartFactoryTestHelper.h b/src/components/formatters/test/include/formatters/SmartFactoryTestHelper.h index 08962db120..d937849b5d 100644 --- a/src/components/formatters/test/include/formatters/SmartFactoryTestHelper.h +++ b/src/components/formatters/test/include/formatters/SmartFactoryTestHelper.h @@ -110,10 +110,6 @@ class CSmartFactoryTest : public CSmartFactory<FunctionIdTest::eType, std::shared_ptr<ISchemaItem> > TStructsSchemaItems; - static std::shared_ptr<ISchemaItem> ProvideObjectSchemaItemForStruct( - TStructsSchemaItems& struct_schema_items, - const StructIdentifiersTest::eType struct_id); - void InitStructSchemes(TStructsSchemaItems& struct_schema_items); void InitFunctionSchemes( diff --git a/src/components/formatters/test/src/SmartFactoryTestHelper.cc b/src/components/formatters/test/src/SmartFactoryTestHelper.cc index 4d089ff9b1..dd4dbe5910 100644 --- a/src/components/formatters/test/src/SmartFactoryTestHelper.cc +++ b/src/components/formatters/test/src/SmartFactoryTestHelper.cc @@ -432,13 +432,6 @@ std::shared_ptr<ISchemaItem> CSmartFactoryTest::InitStructSchemaItem_Common_1( TSchemaItemParameter<size_t>(500), TSchemaItemParameter<std::string>()); - // Struct member image. - // - // Image struct - std::shared_ptr<ISchemaItem> image_SchemaItem = - ProvideObjectSchemaItemForStruct(struct_schema_items, - StructIdentifiersTest::Common_2); - // Struct member position. // // Position to display item @@ -446,19 +439,12 @@ std::shared_ptr<ISchemaItem> CSmartFactoryTest::InitStructSchemaItem_Common_1( TNumberSchemaItem<int32_t>::create(TSchemaItemParameter<int32_t>(1), TSchemaItemParameter<int32_t>(500), TSchemaItemParameter<int32_t>()); - Members struct_members; - struct_members["image"] = SMember(image_SchemaItem, false); Members schema_members; schema_members["text"] = SMember(text_SchemaItem, true); schema_members["position"] = SMember(position_SchemaItem, true); - Members root_members_map; - root_members_map[""] = - SMember(CObjectSchemaItem::create(struct_members), true); - root_members_map[""] = - SMember(CObjectSchemaItem::create(schema_members), true); return CObjectSchemaItem::create(schema_members); } @@ -485,16 +471,3 @@ CSmartFactoryTest::InitStructSchemaItem_Common_2() { return CObjectSchemaItem::create(schema_members); } - -std::shared_ptr<ISchemaItem> -CSmartFactoryTest::ProvideObjectSchemaItemForStruct( - TStructsSchemaItems& struct_schema_items, - const StructIdentifiersTest::eType struct_id) { - const TStructsSchemaItems::const_iterator it = - struct_schema_items.find(struct_id); - if (it != struct_schema_items.end()) { - return it->second; - } - return ns_smart_device_link::ns_smart_objects::CAlwaysFalseSchemaItem:: - create(); -} diff --git a/src/components/formatters/test/src/create_smartSchema.cc b/src/components/formatters/test/src/create_smartSchema.cc index c852c65ea1..23459e2eac 100644 --- a/src/components/formatters/test/src/create_smartSchema.cc +++ b/src/components/formatters/test/src/create_smartSchema.cc @@ -139,6 +139,8 @@ const AppTypeTest::eType test::components::formatters::AppTypeTest::MEDIA, }; +#ifdef BUILD_TESTS +// cppcheck-suppress unusedFunction //Used in unit tests CSmartSchema initObjectSchema() { std::set<TestType::eType> resultCode_allowedEnumSubsetValues; resultCode_allowedEnumSubsetValues.insert( @@ -222,6 +224,7 @@ CSmartSchema initObjectSchema() { return CSmartSchema(CObjectSchemaItem::create(rootMembersMap)); }; +// cppcheck-suppress unusedFunction //Used in unit tests CSmartSchema initSchemaForMetaFormatter() { std::set<TestType::eType> resultCode_allowedEnumSubsetValues; resultCode_allowedEnumSubsetValues.insert( @@ -336,15 +339,6 @@ CSmartSchema initSchemaForMetaFormatter() { ISchemaItemPtr majorVersion_SchemaItem = TNumberSchemaItem<int>::create(); ISchemaItemPtr minorVersion_SchemaItem = TNumberSchemaItem<int>::create(); ISchemaItemPtr patchVersion_SchemaItem = TNumberSchemaItem<int>::create(); - ISchemaItemPtr syncMsg_SchemaItem = - CStringSchemaItem::create(TSchemaItemParameter<size_t>(0), - TSchemaItemParameter<size_t>(1000), - TSchemaItemParameter<std::string>()); - - ISchemaItemPtr syncMsgVersion_SchemaItem = - CArraySchemaItem::create(syncMsg_SchemaItem, - TSchemaItemParameter<size_t>(0), - TSchemaItemParameter<size_t>(1000)); // Creation map for syncMsgVersion std::map<std::string, SMember> schemaSyncMsgVersionMap; @@ -400,6 +394,7 @@ CSmartSchema initSchemaForMetaFormatter() { SMember(CObjectSchemaItem::create(paramsMembersMap), true); return CSmartSchema(CObjectSchemaItem::create(rootMembersMap)); }; +#endif // BUILD_TESTS } // namespace formatters } // namespace components diff --git a/src/components/formatters/test/src/meta_formatter_test_helper.cc b/src/components/formatters/test/src/meta_formatter_test_helper.cc index 4f8975fe53..0c396d4dc7 100644 --- a/src/components/formatters/test/src/meta_formatter_test_helper.cc +++ b/src/components/formatters/test/src/meta_formatter_test_helper.cc @@ -148,7 +148,7 @@ void CMetaFormatterTestHelper::CompareObjects(const SmartObject& first, for (std::set<std::string>::const_iterator key = keys.begin(); key != keys.end(); - key++) { + ++key) { CompareObjects(first.getElement(*key), second.getElement(*key)); } } else if (SmartType_Boolean == first.getType()) { diff --git a/src/components/hmi_message_handler/src/mb_controller.cc b/src/components/hmi_message_handler/src/mb_controller.cc index 681e57906a..b0388a5bf2 100644 --- a/src/components/hmi_message_handler/src/mb_controller.cc +++ b/src/components/hmi_message_handler/src/mb_controller.cc @@ -159,14 +159,13 @@ bool CMessageBrokerController::isResponse(Json::Value& message) { } void CMessageBrokerController::sendResponse(Json::Value& message) { - WebsocketSession* ws; std::map<std::string, WebsocketSession*>::iterator it; sync_primitives::AutoLock request_lock(mRequestListLock); std::string id = message["id"].asString(); it = mRequestList.find(id); if (it != mRequestList.end()) { - ws = it->second; + WebsocketSession* ws = it->second; ws->sendJsonMessage(message); mRequestList.erase(it); } @@ -182,7 +181,6 @@ void CMessageBrokerController::sendJsonMessage(Json::Value& message) { } // Send request - WebsocketSession* ws; std::map<std::string, WebsocketSession*>::iterator it; std::string method = message["method"].asString(); std::string component_name = GetComponentName(method); @@ -190,7 +188,7 @@ void CMessageBrokerController::sendJsonMessage(Json::Value& message) { sync_primitives::AutoLock lock(mControllersListLock); it = mControllersList.find(component_name); if (it != mControllersList.end()) { - ws = it->second; + WebsocketSession* ws = it->second; ws->sendJsonMessage(message); } } @@ -359,7 +357,6 @@ void CMessageBrokerController::deleteSubscriber(WebsocketSession* ws, int CMessageBrokerController::getSubscribersFd( std::string name, std::vector<WebsocketSession*>& result) { int res = 0; - std::map<std::string, WebsocketSession*>::iterator it; sync_primitives::AutoLock lock(mSubscribersListLock); std::pair<std::multimap<std::string, WebsocketSession*>::iterator, diff --git a/src/components/include/protocol/rpc_type.h b/src/components/include/protocol/rpc_type.h index db4a808cfd..fde8fe7885 100644 --- a/src/components/include/protocol/rpc_type.h +++ b/src/components/include/protocol/rpc_type.h @@ -49,7 +49,6 @@ enum RpcType { // Validate and map byte value to RPC type RpcType RpcTypeFromByte(uint8_t byte); // Check and convert RpcType to byte value ready to be transmitted -uint8_t RpcTypeToByte(RpcType type); const char* RpcTypeToString(RpcType type); diff --git a/src/components/include/protocol/service_type.h b/src/components/include/protocol/service_type.h index 803b8106b8..77a095f7e9 100644 --- a/src/components/include/protocol/service_type.h +++ b/src/components/include/protocol/service_type.h @@ -79,7 +79,6 @@ enum ServiceType { * Service types to binary stream */ ServiceType ServiceTypeFromByte(uint8_t type); -uint8_t ServiceTypeToByte(ServiceType type); } // namespace protocol_handler #endif // SRC_COMPONENTS_INCLUDE_PROTOCOL_SERVICE_TYPE_H_ diff --git a/src/components/policy/policy_external/include/policy/policy_helper.h b/src/components/policy/policy_external/include/policy/policy_helper.h index 69ba8806d4..87a9228c12 100644 --- a/src/components/policy/policy_external/include/policy/policy_helper.h +++ b/src/components/policy/policy_external/include/policy/policy_helper.h @@ -68,13 +68,6 @@ struct CompareGroupName { const StringsValueType& group_name_; }; -/* - * @brief Used for compare of policies parameters mapped with specific - * application ids - */ -bool operator!=(const policy_table::ApplicationParams& first, - const policy_table::ApplicationParams& second); - /** * @brief Helper struct for checking changes of application policies, which * come with update along with current data snapshot @@ -393,15 +386,6 @@ FunctionalGroupIDs Merge(const FunctionalGroupIDs& first, const FunctionalGroupIDs& second); /** - * @brief Finds same values - * @param first First source of values - * @param second Second source of values - * @return Same values set, if any found - */ -FunctionalGroupIDs FindSame(const FunctionalGroupIDs& first, - const FunctionalGroupIDs& second); - -/** * @brief Unwrap application policies from predefined values to specific policy * values, i.e. if application has "default", it will be assigned default * policies diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index 67d8bdb2d1..570246adb7 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -166,7 +166,8 @@ struct LinkCollector typedef std::vector<policy_table::UserConsentRecords::key_type> ApplicationsIds; - LinkCollector(std::map<std::string, std::string>& links) : links_(links) {} + explicit LinkCollector(std::map<std::string, std::string>& links) + : links_(links) {} void operator()(const policy_table::DeviceData::value_type& value) { using namespace policy_table; @@ -208,10 +209,12 @@ struct ExternalConsentConsentGroupAppender }; struct DefaultPolicyUpdater { - DefaultPolicyUpdater(const policy_table::ApplicationParams& default_params) + explicit DefaultPolicyUpdater( + const policy_table::ApplicationParams& default_params) : default_params_(default_params) {} - void operator()(policy_table::ApplicationPolicies::value_type& pt_value) { + void operator()( + policy_table::ApplicationPolicies::value_type& pt_value) const { if (policy::kDefaultId == pt_value.second.get_string()) { pt_value.second = default_params_; pt_value.second.set_to_string(policy::kDefaultId); @@ -1704,6 +1707,8 @@ std::vector<UserFriendlyMessage> CacheManager::GetUserFriendlyMsg( SDL_LOG_ERROR("No fallback language found for message code: " << *it); continue; } + // FIXME (VSemenyuk): message_string will always be overwritten by + // active_hmi_language_message_string message_string = fallback_message_string; } message_string = active_hmi_language_message_string; @@ -1827,10 +1832,6 @@ bool CacheManager::GetPriority(const std::string& policy_app_id, void CacheManager::CheckSnapshotInitialization() { CACHE_MANAGER_CHECK_VOID(); - if (!snapshot_) { - SDL_LOG_ERROR("Snapshot pointer is not initialized"); - return; - } *(snapshot_->policy_table.module_config.preloaded_pt) = false; @@ -2182,9 +2183,9 @@ int CacheManager::CountUnconsentedGroups(const std::string& policy_app_id, pt_->policy_table.app_policies_section; policy_table::Strings::iterator app_groups; - policy_table::Strings::iterator app_groups_end = app_groups; + policy_table::Strings::iterator app_groups_end; policy_table::Strings::iterator app_pre_groups; - policy_table::Strings::iterator app_pre_groups_end = app_pre_groups; + policy_table::Strings::iterator app_pre_groups_end; if (kDeviceId == policy_app_id) { app_groups = app_policies_section.device.groups.begin(); @@ -2294,11 +2295,10 @@ std::string CacheManager::GetCCPUVersionFromPT() const { bool CacheManager::IsMetaInfoPresent() const { CACHE_MANAGER_CHECK(false); - bool result = true; sync_primitives::AutoLock lock(cache_lock_); - result = NULL != pt_->policy_table.module_meta->ccpu_version && - NULL != pt_->policy_table.module_meta->wers_country_code && - NULL != pt_->policy_table.module_meta->language; + bool result = NULL != pt_->policy_table.module_meta->ccpu_version && + NULL != pt_->policy_table.module_meta->wers_country_code && + NULL != pt_->policy_table.module_meta->language; return result; } diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc index 4607c3ca5f..e6605aed3a 100644 --- a/src/components/policy/policy_external/src/policy_helper.cc +++ b/src/components/policy/policy_external/src/policy_helper.cc @@ -102,25 +102,6 @@ bool CompareGroupName::operator()( return !(strcasecmp(gn_.c_str(), gn_compare.c_str())); } -bool operator!=(const policy_table::ApplicationParams& first, - const policy_table::ApplicationParams& second) { - if (first.groups.size() != second.groups.size()) { - return true; - } - StringsConstItr it_first = first.groups.begin(); - StringsConstItr it_first_end = first.groups.end(); - StringsConstItr it_second = second.groups.begin(); - StringsConstItr it_second_end = second.groups.end(); - for (; it_first != it_first_end; ++it_first) { - CompareGroupName gp(*it_first); - StringsConstItr it = std::find_if(it_second, it_second_end, gp); - if (it_second_end == it) { - return true; - } - } - return false; -} - CheckAppPolicy::CheckAppPolicy( PolicyManagerImpl* pm, const std::shared_ptr<policy_table::Table> update, @@ -607,7 +588,6 @@ bool CheckAppPolicy::IsConsentRequired(const std::string& app_id, return false; } - bool is_preconsented = false; policy_table::Strings::value_type str(group_name); policy_table::Strings::iterator pre_begin = update_->policy_table.app_policies_section.apps[app_id] @@ -618,7 +598,7 @@ bool CheckAppPolicy::IsConsentRequired(const std::string& app_id, policy_table::Strings::iterator it2 = std::find(pre_begin, pre_end, str); - is_preconsented = pre_end != it2; + bool is_preconsented = pre_end != it2; return it->second.user_consent_prompt.is_initialized() && !is_preconsented; } @@ -768,7 +748,7 @@ bool CheckAppPolicy::IsEncryptionRequiredFlagChanged( return result; }; - auto get_app_rpcs = [](const std::string group_name, + auto get_app_rpcs = [](const std::string& group_name, const FunctionalGroupings& groups) -> rpc::Optional<policy_table::Rpcs> { auto it = groups.find(group_name); @@ -953,8 +933,7 @@ void FillNotificationData::UpdateParameters( // If 'parameters' section is omitted if (!in_parameters.is_initialized()) { - if (!does_require_user_consent_ || - (does_require_user_consent_ && kAllowedKey == current_key_)) { + if (!does_require_user_consent_ || kAllowedKey == current_key_) { out_parameter.any_parameter_allowed = true; } } @@ -1251,28 +1230,6 @@ FunctionalGroupIDs Merge(const FunctionalGroupIDs& first, return merged; } -FunctionalGroupIDs FindSame(const FunctionalGroupIDs& first, - const FunctionalGroupIDs& second) { - SDL_LOG_INFO("Find same groups"); - FunctionalGroupIDs first_copy(first); - FunctionalGroupIDs second_copy(second); - - std::sort(first_copy.begin(), first_copy.end()); - std::sort(second_copy.begin(), second_copy.end()); - - FunctionalGroupIDs same; - std::set_intersection(first_copy.begin(), - first_copy.end(), - second_copy.begin(), - second_copy.end(), - std::back_inserter(same)); - - same.resize( - std::distance(same.begin(), std::unique(same.begin(), same.end()))); - - return same; -} - bool UnwrapAppPolicies(policy_table::ApplicationPolicies& app_policies) { policy_table::ApplicationPolicies::iterator it_default = app_policies.find(kDefaultId); diff --git a/src/components/policy/policy_external/src/policy_manager_impl.cc b/src/components/policy/policy_external/src/policy_manager_impl.cc index 773c689409..fc7fc0f171 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -62,7 +62,7 @@ namespace { struct GroupNamesAppender : public std::unary_function<void, const policy::FunctionalGroupPermission&> { - GroupNamesAppender(policy_table::Strings& names) : names_(names) {} + explicit GroupNamesAppender(policy_table::Strings& names) : names_(names) {} void operator()(const policy::FunctionalGroupPermission& value) { names_.push_back(value.group_name); @@ -1827,13 +1827,12 @@ bool PolicyManagerImpl::IsNeedToUpdateExternalConsentStatus( ItemV difference_v; difference_v.resize(new_status_v.size() + existing_status_v.size()); - ItemV::iterator ci = difference_v.begin(); - ci = std::set_difference(new_status_v.begin(), - new_status_v.end(), - existing_status_v.begin(), - existing_status_v.end(), - difference_v.begin(), - ConsentStatusComparatorFunc); + ItemV::iterator ci = std::set_difference(new_status_v.begin(), + new_status_v.end(), + existing_status_v.begin(), + existing_status_v.end(), + difference_v.begin(), + ConsentStatusComparatorFunc); difference_v.resize(ci - difference_v.begin()); return !difference_v.empty(); @@ -2386,7 +2385,7 @@ void PolicyManagerImpl::SetDefaultHmiTypes( } struct HMITypeToInt { - int operator()(const policy_table::AppHMITypes::value_type item) { + int operator()(const policy_table::AppHMITypes::value_type item) const { return policy_table::AppHMIType(item); } }; @@ -2587,6 +2586,7 @@ __attribute__((visibility("default"))) policy::PolicyManager* CreateManager( return new policy::PolicyManagerImpl(); } +// cppcheck-suppress unusedFunction __attribute__((visibility("default"))) void DeleteManager( policy::PolicyManager* pm) { delete pm; diff --git a/src/components/policy/policy_external/src/policy_table/types.cc b/src/components/policy/policy_external/src/policy_table/types.cc index 1f344f5263..0194ac68a3 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -872,7 +872,6 @@ ModuleConfig::ModuleConfig(const Json::Value* value__) impl::ValueMember(value__, "lock_screen_dismissal_enabled")) {} void ModuleConfig::SafeCopyFrom(const ModuleConfig& from) { - exchange_after_x_days = from.exchange_after_x_days; exchange_after_x_kilometers = from.exchange_after_x_kilometers; exchange_after_x_days = from.exchange_after_x_days; exchange_after_x_ignition_cycles = from.exchange_after_x_ignition_cycles; diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc index 36e363d922..fc9ebd96a9 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -1750,9 +1750,7 @@ SQLPTRepresentation::SelectCompositeVehicleDataItems() const { if (!vdi.is_initialized()) { return policy_table::VehicleDataItems(); } - for (const auto& item : vdi) { - result.push_back(item); - } + std::copy(vdi.begin(), vdi.end(), std::back_inserter(result)); } return result; diff --git a/src/components/policy/policy_regular/include/policy/policy_helper.h b/src/components/policy/policy_regular/include/policy/policy_helper.h index d5155cf91b..f01d132049 100644 --- a/src/components/policy/policy_regular/include/policy/policy_helper.h +++ b/src/components/policy/policy_regular/include/policy/policy_helper.h @@ -68,13 +68,6 @@ struct CompareGroupName { }; /* - * @brief Used for compare of policies parameters mapped with specific - * application ids - */ -bool operator!=(const policy_table::ApplicationParams& first, - const policy_table::ApplicationParams& second); - -/* * @brief Helper struct for checking changes of application policies, which * come with update along with current data snapshot * In case of policies changed for some application, current data will be @@ -257,15 +250,6 @@ FunctionalGroupIDs Merge(const FunctionalGroupIDs& first, const FunctionalGroupIDs& second); /** - * @brief Finds same values - * @param first First source of values - * @param second Second source of values - * @return Same values set, if any found - */ -FunctionalGroupIDs FindSame(const FunctionalGroupIDs& first, - const FunctionalGroupIDs& second); - -/** * @brief Unwrap application policies from predefined values to specific policy * values, i.e. if application has "default", it will be assigned default * policies diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 5a75c47725..d031b5f027 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -79,7 +79,7 @@ SDL_CREATE_LOG_VARIABLE("Policy") } struct LanguageFinder { - LanguageFinder(const std::string& language) : language_(language) {} + explicit LanguageFinder(const std::string& language) : language_(language) {} bool operator()(const policy_table::Languages::value_type& lang) const { return !strcasecmp(language_.c_str(), lang.first.c_str()); } @@ -89,10 +89,12 @@ struct LanguageFinder { }; struct PolicyTableUpdater { - PolicyTableUpdater(const policy_table::ApplicationParams& default_params) + explicit PolicyTableUpdater( + const policy_table::ApplicationParams& default_params) : default_params_(default_params) {} - void operator()(policy_table::ApplicationPolicies::value_type& pt_value) { + void operator()( + policy_table::ApplicationPolicies::value_type& pt_value) const { if (policy::kDefaultId == pt_value.second.get_string()) { pt_value.second = default_params_; pt_value.second.set_to_string(policy::kDefaultId); @@ -1138,10 +1140,6 @@ bool CacheManager::GetPriority(const std::string& policy_app_id, void CacheManager::CheckSnapshotInitialization() { CACHE_MANAGER_CHECK_VOID(); - if (!snapshot_) { - SDL_LOG_ERROR("Snapshot pointer is not initialized"); - return; - } *(snapshot_->policy_table.module_config.preloaded_pt) = false; @@ -1309,8 +1307,6 @@ void CacheManager::PersistData() { copy_pt.policy_table.app_policies_section.apps.end(); bool is_revoked = false; - bool is_default_policy; - bool is_predata_policy; for (; app_policy_iter != app_policy_iter_end; ++app_policy_iter) { const std::string app_id = (*app_policy_iter).first; @@ -1321,7 +1317,7 @@ void CacheManager::PersistData() { copy_pt.policy_table.app_policies_section.apps[app_id].is_null(); } - is_default_policy = + bool is_default_policy = copy_pt.policy_table.app_policies_section.apps.end() != copy_pt.policy_table.app_policies_section.apps.find(app_id) && policy::kDefaultId == @@ -1329,7 +1325,7 @@ void CacheManager::PersistData() { .get_string(); // TODO(AOleynik): Remove this field from DB - is_predata_policy = + bool is_predata_policy = copy_pt.policy_table.app_policies_section.apps.end() != copy_pt.policy_table.app_policies_section.apps.find(app_id) && policy::kPreDataConsentId == diff --git a/src/components/policy/policy_regular/src/policy_helper.cc b/src/components/policy/policy_regular/src/policy_helper.cc index 7d99ff51c0..ec84486ea6 100644 --- a/src/components/policy/policy_regular/src/policy_helper.cc +++ b/src/components/policy/policy_regular/src/policy_helper.cc @@ -54,9 +54,10 @@ bool CompareStrings(const StringsValueType& first, } struct CheckGroupName { - CheckGroupName(const policy::StringsValueType& value) : value_(value) {} + explicit CheckGroupName(const policy::StringsValueType& value) + : value_(value) {} - bool operator()(const FunctionalGroupNames::value_type& value) { + bool operator()(const FunctionalGroupNames::value_type& value) const { return value.second.second == std::string(value_); } @@ -101,25 +102,6 @@ bool CompareGroupName::operator()( return !(strcasecmp(gn_.c_str(), gn_compare.c_str())); } -bool operator!=(const policy_table::ApplicationParams& first, - const policy_table::ApplicationParams& second) { - if (first.groups.size() != second.groups.size()) { - return true; - } - StringsConstItr it_first = first.groups.begin(); - StringsConstItr it_first_end = first.groups.end(); - StringsConstItr it_second = second.groups.begin(); - StringsConstItr it_second_end = second.groups.end(); - for (; it_first != it_first_end; ++it_first) { - CompareGroupName gp(*it_first); - StringsConstItr it = std::find_if(it_second, it_second_end, gp); - if (it_second_end == it) { - return true; - } - } - return false; -} - CheckAppPolicy::CheckAppPolicy( PolicyManagerImpl* pm, const std::shared_ptr<policy_table::Table> update, @@ -559,8 +541,7 @@ bool CheckAppPolicy::IsConsentRequired(const std::string& app_id, return false; } - bool is_preconsented = false; - return it->second.user_consent_prompt.is_initialized() && !is_preconsented; + return it->second.user_consent_prompt.is_initialized(); } bool CheckAppPolicy::IsRequestTypeChanged( @@ -707,7 +688,7 @@ bool CheckAppPolicy::IsEncryptionRequiredFlagChanged( return result; }; - auto get_app_rpcs = [](const std::string group_name, + auto get_app_rpcs = [](const std::string& group_name, const FunctionalGroupings& groups) -> rpc::Optional<policy_table::Rpcs> { auto it = groups.find(group_name); @@ -1106,28 +1087,6 @@ FunctionalGroupIDs Merge(const FunctionalGroupIDs& first, return merged; } -FunctionalGroupIDs FindSame(const FunctionalGroupIDs& first, - const FunctionalGroupIDs& second) { - SDL_LOG_INFO("Find same groups"); - FunctionalGroupIDs first_copy(first); - FunctionalGroupIDs second_copy(second); - - std::sort(first_copy.begin(), first_copy.end()); - std::sort(second_copy.begin(), second_copy.end()); - - FunctionalGroupIDs same; - std::set_intersection(first_copy.begin(), - first_copy.end(), - second_copy.begin(), - second_copy.end(), - std::back_inserter(same)); - - same.resize( - std::distance(same.begin(), std::unique(same.begin(), same.end()))); - - return same; -} - bool UnwrapAppPolicies(policy_table::ApplicationPolicies& app_policies) { policy_table::ApplicationPolicies::iterator it = app_policies.begin(); policy_table::ApplicationPolicies::iterator it_default = diff --git a/src/components/policy/policy_regular/src/policy_manager_impl.cc b/src/components/policy/policy_regular/src/policy_manager_impl.cc index daf043f96b..6fbc4e798f 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -1708,7 +1708,7 @@ void PolicyManagerImpl::SetDefaultHmiTypes( } struct HMITypeToInt { - int operator()(const policy_table::AppHMITypes::value_type item) { + int operator()(const policy_table::AppHMITypes::value_type item) const { return policy_table::AppHMIType(item); } }; 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 49b7f2e7be..bf578aebe5 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -2770,9 +2770,7 @@ SQLPTRepresentation::SelectCompositeVehicleDataItems() const { if (!vdi.is_initialized()) { return policy_table::VehicleDataItems(); } - for (const auto& item : vdi) { - result.push_back(item); - } + std::copy(vdi.begin(), vdi.end(), std::back_inserter(result)); } return result; diff --git a/src/components/protocol/src/rpc_type.cc b/src/components/protocol/src/rpc_type.cc index fb9845d148..0e2edb34e8 100644 --- a/src/components/protocol/src/rpc_type.cc +++ b/src/components/protocol/src/rpc_type.cc @@ -62,11 +62,6 @@ RpcType RpcTypeFromByte(uint8_t byte) { return supported_type ? type : kRpcTypeReserved; } -uint8_t RpcTypeToByte(RpcType type) { - DCHECK(IsSupported(type)); - return uint8_t(type); -} - const char* RpcTypeToString(RpcType type) { switch (type) { case kRpcTypeRequest: diff --git a/src/components/protocol/src/service_type.cc b/src/components/protocol/src/service_type.cc index e6417b07d0..b1674e10d8 100644 --- a/src/components/protocol/src/service_type.cc +++ b/src/components/protocol/src/service_type.cc @@ -63,9 +63,4 @@ ServiceType ServiceTypeFromByte(uint8_t byte) { return valid_type ? type : kInvalidServiceType; } -uint8_t ServiceTypeToByte(ServiceType type) { - DCHECK(IsValid(type)); - return uint8_t(type); -} - } // namespace protocol_handler diff --git a/src/components/protocol_handler/src/incoming_data_handler.cc b/src/components/protocol_handler/src/incoming_data_handler.cc index f0692b3304..08997acaac 100644 --- a/src/components/protocol_handler/src/incoming_data_handler.cc +++ b/src/components/protocol_handler/src/incoming_data_handler.cc @@ -158,7 +158,7 @@ RESULT_CODE IncomingDataHandler::CreateFrame( } SDL_LOG_DEBUG("Payload size " << header_.dataSize); const uint32_t packet_size = GetPacketSize(header_); - if (packet_size <= 0) { + if (packet_size == 0) { SDL_LOG_WARN("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 f1179e7107..dc710549cd 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -1243,7 +1243,7 @@ void ProtocolHandlerImpl::OnTransportConfigUpdated( if (st.secondary_transport != kDisabledSecondary) { SendTransportUpdateEvent(st.primary_transport, itr->first); } - itr++; + ++itr; } } @@ -2573,7 +2573,7 @@ void ProtocolHandlerImpl::GenerateSecondaryTransportsForStartSessionAck( secondaryTransports.push_back("TCP_WIFI"); } - it++; + ++it; } } @@ -2600,7 +2600,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); SDL_LOG_TRACE( diff --git a/src/components/protocol_handler/src/protocol_payload.cc b/src/components/protocol_handler/src/protocol_payload.cc index 8916fe91b0..a18f04f8a1 100644 --- a/src/components/protocol_handler/src/protocol_payload.cc +++ b/src/components/protocol_handler/src/protocol_payload.cc @@ -93,8 +93,11 @@ std::ostream& operator<<(std::ostream& os, const ProtocolPayloadV2& payload) { << ", data (bytes): " << payload.data.size() << ")"; } +#ifdef BUILD_TESTS +// cppcheck-suppress unusedFunction //Used in unit tests size_t ProtocolPayloadV2SizeBits() { return PayloadHeaderBits; } +#endif // BUILD_TESTS } // namespace protocol_handler diff --git a/src/components/security_manager/src/crypto_manager_impl.cc b/src/components/security_manager/src/crypto_manager_impl.cc index 9ee820b19d..845485a6c3 100644 --- a/src/components/security_manager/src/crypto_manager_impl.cc +++ b/src/components/security_manager/src/crypto_manager_impl.cc @@ -338,10 +338,16 @@ bool CryptoManagerImpl::IsCertificateUpdateRequired( const double seconds = difftime(certificates_time, system_time); - SDL_LOG_DEBUG( - "Certificate UTC time: " << asctime(gmtime(&certificates_time))); + const size_t maxsize = 40; + char certificate_utc_time[maxsize]; + std::strftime( + certificate_utc_time, maxsize, "%c", gmtime(&certificates_time)); + SDL_LOG_DEBUG("Certificate UTC time: " << certificate_utc_time); + + char host_utc_time[maxsize]; + std::strftime(host_utc_time, maxsize, "%c", gmtime(&system_time)); + SDL_LOG_DEBUG("Host UTC time: " << host_utc_time); - SDL_LOG_DEBUG("Host UTC time: " << asctime(gmtime(&system_time))); SDL_LOG_DEBUG("Seconds before expiration: " << seconds); if (seconds < 0) { SDL_LOG_WARN("Certificate is already expired."); diff --git a/src/components/security_manager/test/security_query_matcher.cc b/src/components/security_manager/test/security_query_matcher.cc index 1bf22bf8cd..b9a4f83b10 100644 --- a/src/components/security_manager/test/security_query_matcher.cc +++ b/src/components/security_manager/test/security_query_matcher.cc @@ -90,15 +90,12 @@ MATCHER_P(InternalErrorWithErrId, } // namespace security_manager_test } // namespace components } // namespace test - /* - * Matcher for checking QueryHeader equal in GTests - */ -::testing::AssertionResult QueryHeader_EQ( - const char* m_expr, - const char* n_expr, - const ::security_manager::SecurityQuery::QueryHeader& q1, - const ::security_manager::SecurityQuery::QueryHeader& q2); +#ifdef BUILD_TESTS +/* + * Matcher for checking QueryHeader equal in GTests + */ +// cppcheck-suppress unusedFunction //Used in unit tests ::testing::AssertionResult QueryHeader_EQ( const char* m_expr, const char* n_expr, @@ -121,3 +118,4 @@ MATCHER_P(InternalErrorWithErrId, << ", seq_number_2=" << q2.seq_number; return ::testing::AssertionSuccess(); } +#endif // BUILD_TESTS diff --git a/src/components/smart_objects/src/object_schema_item.cc b/src/components/smart_objects/src/object_schema_item.cc index 7e5c49bae0..920d548c48 100644 --- a/src/components/smart_objects/src/object_schema_item.cc +++ b/src/components/smart_objects/src/object_schema_item.cc @@ -146,7 +146,7 @@ errors::eType CObjectSchemaItem::validate( } const SmartObject& field = object.getElement(key); - errors::eType result = errors::OK; + errors::eType result; // Check if MessageVersion matches schema version if (correct_member) { result = diff --git a/src/components/smart_objects/test/SmartObjectConvertionTime_test.cc b/src/components/smart_objects/test/SmartObjectConvertionTime_test.cc index 555239c489..1ce383e44d 100644 --- a/src/components/smart_objects/test/SmartObjectConvertionTime_test.cc +++ b/src/components/smart_objects/test/SmartObjectConvertionTime_test.cc @@ -270,367 +270,279 @@ class SmartObjectConvertionTimeTest : public ::testing::Test { return CSmartSchema(CObjectSchemaItem::create(rootMembersMap)); } - // Create SmartObjectSchema for test object - CSmartSchema initObjectSchema() { - std::set<TestType::eType> resultCode_allowedEnumSubsetValues; - resultCode_allowedEnumSubsetValues.insert( - TestType::APPLICATION_NOT_REGISTERED); - resultCode_allowedEnumSubsetValues.insert(TestType::SUCCESS); - resultCode_allowedEnumSubsetValues.insert( - TestType::TOO_MANY_PENDING_REQUESTS); - resultCode_allowedEnumSubsetValues.insert(TestType::REJECTED); - resultCode_allowedEnumSubsetValues.insert(TestType::INVALID_DATA); - resultCode_allowedEnumSubsetValues.insert(TestType::OUT_OF_MEMORY); - resultCode_allowedEnumSubsetValues.insert(TestType::ABORTED); - resultCode_allowedEnumSubsetValues.insert(TestType::USER_DISALLOWED); - resultCode_allowedEnumSubsetValues.insert(TestType::GENERIC_ERROR); - resultCode_allowedEnumSubsetValues.insert(TestType::DISALLOWED); - - std::set<FunctionIdTest::eType> functionId_allowedEnumSubsetValues; - functionId_allowedEnumSubsetValues.insert( - FunctionIdTest::RegisterAppInterface); - functionId_allowedEnumSubsetValues.insert( - FunctionIdTest::UnregisterAppInterface); - functionId_allowedEnumSubsetValues.insert( - FunctionIdTest::SetGlobalProperties); - - std::set<MessageTypeTest::eType> messageType_allowedEnumSubsetValues; - messageType_allowedEnumSubsetValues.insert(MessageTypeTest::request); - messageType_allowedEnumSubsetValues.insert(MessageTypeTest::response); - messageType_allowedEnumSubsetValues.insert(MessageTypeTest::notification); - - ISchemaItemPtr success_SchemaItem = - CBoolSchemaItem::create(TSchemaItemParameter<bool>()); - - ISchemaItemPtr resultCode_SchemaItem = - TEnumSchemaItem<TestType::eType>::create( - resultCode_allowedEnumSubsetValues, - TSchemaItemParameter<TestType::eType>()); - - ISchemaItemPtr info_SchemaItem = - CStringSchemaItem::create(TSchemaItemParameter<size_t>(0), - TSchemaItemParameter<size_t>(1000), - TSchemaItemParameter<std::string>()); - - ISchemaItemPtr tryAgainTime_SchemaItem = - TNumberSchemaItem<int>::create(TSchemaItemParameter<int>(0), - TSchemaItemParameter<int>(2000000000), - TSchemaItemParameter<int>()); - - std::map<std::string, SMember> schemaMembersMap; - - schemaMembersMap["success"] = SMember(success_SchemaItem, true); - schemaMembersMap["resultCode"] = SMember(resultCode_SchemaItem, true); - schemaMembersMap["info"] = SMember(info_SchemaItem, false); - schemaMembersMap["tryAgainTime"] = SMember(tryAgainTime_SchemaItem, true); - - std::map<std::string, SMember> paramsMembersMap; - paramsMembersMap - [ns_smart_device_link::ns_json_handler::strings::S_FUNCTION_ID] = - SMember(TEnumSchemaItem<FunctionIdTest::eType>::create( - functionId_allowedEnumSubsetValues), - true); - paramsMembersMap - [ns_smart_device_link::ns_json_handler::strings::S_MESSAGE_TYPE] = - SMember(TEnumSchemaItem<MessageTypeTest::eType>::create( - messageType_allowedEnumSubsetValues), - true); - paramsMembersMap - [ns_smart_device_link::ns_json_handler::strings::S_CORRELATION_ID] = - SMember(TNumberSchemaItem<int>::create(), true); - paramsMembersMap - [ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_VERSION] = - SMember( - TNumberSchemaItem<int>::create(TSchemaItemParameter<int>(1), - TSchemaItemParameter<int>(2)), - true); - paramsMembersMap - [ns_smart_device_link::ns_json_handler::strings::S_PROTOCOL_TYPE] = - SMember(TNumberSchemaItem<int>::create(), true); - - std::map<std::string, SMember> rootMembersMap; - rootMembersMap - [ns_smart_device_link::ns_json_handler::strings::S_MSG_PARAMS] = - SMember(CObjectSchemaItem::create(schemaMembersMap), true); - rootMembersMap[ns_smart_device_link::ns_json_handler::strings::S_PARAMS] = - SMember(CObjectSchemaItem::create(paramsMembersMap), true); - return CSmartSchema(CObjectSchemaItem::create(rootMembersMap)); + TEST_F(SmartObjectConvertionTimeTest, test_int_object_convertion) { + SmartObject srcObj, dstObj; + CSmartSchema schema = initObjectSchema(); + + srcObj.setSchema(schema); + dstObj.setSchema(schema); + + srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; + srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; + srcObj[S_PARAMS][S_CORRELATION_ID] = 13; + srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; + srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 1; + srcObj[S_MSG_PARAMS]["value"] = 5; + + printf("\n INT value.\n"); + calculateConvertionTime(srcObj, dstObj); } -}; -TEST_F(SmartObjectConvertionTimeTest, test_int_object_convertion) { - SmartObject srcObj, dstObj; - CSmartSchema schema = initObjectSchema(); + TEST_F(SmartObjectConvertionTimeTest, test_double_object_convertion) { + SmartObject srcObj, dstObj; + CSmartSchema schema = initObjectSchema(); + + srcObj.setSchema(schema); + dstObj.setSchema(schema); + + srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; + srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; + srcObj[S_PARAMS][S_CORRELATION_ID] = 13; + srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; + srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2; + srcObj[S_MSG_PARAMS]["value1"] = 3.1415926; + srcObj[S_MSG_PARAMS]["value2"] = 32.6; + srcObj[S_MSG_PARAMS]["value3"] = 33.945; + srcObj[S_MSG_PARAMS]["value4"] = -12.5487698; + srcObj[S_MSG_PARAMS]["value5"] = 0.61287346; + + printf("\n Double value.\n"); + calculateConvertionTime(srcObj, dstObj); + } - srcObj.setSchema(schema); - dstObj.setSchema(schema); + TEST_F(SmartObjectConvertionTimeTest, test_some_object_convertion) { + SmartObject srcObj, dstObj; + CSmartSchema schema = initObjectSchema(); + + srcObj.setSchema(schema); + dstObj.setSchema(schema); + + srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; + srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; + srcObj[S_PARAMS][S_CORRELATION_ID] = 13; + srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; + srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2; + srcObj[S_MSG_PARAMS]["appId"] = "APP ID"; + srcObj[S_MSG_PARAMS]["appName"] = "APP NAME"; + srcObj[S_MSG_PARAMS]["appType"][0] = "SYSTEM"; + srcObj[S_MSG_PARAMS]["appType"][1] = "COMMUNICATION"; + srcObj[S_MSG_PARAMS]["hmiDisplayLanguageDesired"] = "RU-RU"; + srcObj[S_MSG_PARAMS]["isMediaApplication"] = true; + srcObj[S_MSG_PARAMS]["languageDesired"] = "EN-US"; + srcObj[S_MSG_PARAMS]["ngnMediaScreenAppName"] = "SCREEN NAME"; + srcObj[S_MSG_PARAMS]["syncMsgVersion"]["majorVersion"] = 2; + srcObj[S_MSG_PARAMS]["syncMsgVersion"]["minorVersion"] = 10; + srcObj[S_MSG_PARAMS]["syncMsgVersion"]["patchVersion"] = 5; + + srcObj[S_MSG_PARAMS]["ttsName"][0]["text"] = "ABC"; + srcObj[S_MSG_PARAMS]["ttsName"][0]["type"] = "TEXT"; + srcObj[S_MSG_PARAMS]["vrSynonyms"][0] = "Synonym1"; + srcObj[S_MSG_PARAMS]["vrSynonyms"][1] = "Synonym2"; + srcObj[S_MSG_PARAMS]["null"] = SmartObject(); + srcObj[S_MSG_PARAMS]["double"] = -0.1234; + + printf("\n Random object.\n"); + calculateConvertionTime(srcObj, dstObj); + } - srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; - srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; - srcObj[S_PARAMS][S_CORRELATION_ID] = 13; - srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; - srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 1; - srcObj[S_MSG_PARAMS]["value"] = 5; + TEST_F(SmartObjectConvertionTimeTest, test_map_object_convertion) { + SmartObject srcObj, dstObj, mapObj, innerObj; + CSmartSchema schema = initObjectSchema(); + + srcObj.setSchema(schema); + dstObj.setSchema(schema); + + // First iteration + mapObj["request"]["name"] = "My Request"; + mapObj["request"]["id"] = 123; + mapObj["response"]["name"] = "My Response"; + mapObj["response"]["id"] = 456; + mapObj["we"]["need"]["to"]["go"]["deeper"] = true; + + srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; + srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; + srcObj[S_PARAMS][S_CORRELATION_ID] = 13; + srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; + srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2; + srcObj[S_MSG_PARAMS]["value"] = mapObj; + + printf("\n MAP object.\n"); + calculateConvertionTime(srcObj, dstObj); + + // Second iteration + innerObj = mapObj; + mapObj["request"]["value"] = innerObj; + mapObj["response"]["value"] = innerObj; + mapObj["we"]["need"]["to"]["go"]["deeper"]["value"] = innerObj; + srcObj[S_MSG_PARAMS]["value"] = mapObj; + + printf("\n Complex MAP object.\n"); + calculateConvertionTime(srcObj, dstObj); + + // Third iteration + innerObj = mapObj; + mapObj["request"]["value"] = innerObj; + mapObj["response"]["value"] = innerObj; + mapObj["we"]["need"]["to"]["go"]["deeper"]["value"] = innerObj; + srcObj[S_MSG_PARAMS]["value"] = mapObj; + + printf("\n Very Complex MAP object.\n"); + calculateConvertionTime(srcObj, dstObj); + + // Last iteration + innerObj = mapObj; + mapObj["request"]["value"] = innerObj; + mapObj["response"]["value"] = innerObj; + mapObj["we"]["need"]["to"]["go"]["deeper"]["value"] = innerObj; + srcObj[S_MSG_PARAMS]["value"] = mapObj; + + printf("\n Very Very Complex MAP object.\n"); + calculateConvertionTime(srcObj, dstObj); + } - printf("\n INT value.\n"); - calculateConvertionTime(srcObj, dstObj); -} + TEST_F(SmartObjectConvertionTimeTest, test_array_convertion) { + SmartObject srcObj, dstObj, arrayObj, innerObj; + CSmartSchema schema = initObjectSchema(); + int arraySize = 10; -TEST_F(SmartObjectConvertionTimeTest, test_double_object_convertion) { - SmartObject srcObj, dstObj; - CSmartSchema schema = initObjectSchema(); - - srcObj.setSchema(schema); - dstObj.setSchema(schema); - - srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; - srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; - srcObj[S_PARAMS][S_CORRELATION_ID] = 13; - srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; - srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2; - srcObj[S_MSG_PARAMS]["value1"] = 3.1415926; - srcObj[S_MSG_PARAMS]["value2"] = 32.6; - srcObj[S_MSG_PARAMS]["value3"] = 33.945; - srcObj[S_MSG_PARAMS]["value4"] = -12.5487698; - srcObj[S_MSG_PARAMS]["value5"] = 0.61287346; - - printf("\n Double value.\n"); - calculateConvertionTime(srcObj, dstObj); -} + srcObj.setSchema(schema); + dstObj.setSchema(schema); -TEST_F(SmartObjectConvertionTimeTest, test_some_object_convertion) { - SmartObject srcObj, dstObj; - CSmartSchema schema = initObjectSchema(); - - srcObj.setSchema(schema); - dstObj.setSchema(schema); - - srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; - srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; - srcObj[S_PARAMS][S_CORRELATION_ID] = 13; - srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; - srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2; - srcObj[S_MSG_PARAMS]["appId"] = "APP ID"; - srcObj[S_MSG_PARAMS]["appName"] = "APP NAME"; - srcObj[S_MSG_PARAMS]["appType"][0] = "SYSTEM"; - srcObj[S_MSG_PARAMS]["appType"][1] = "COMMUNICATION"; - srcObj[S_MSG_PARAMS]["hmiDisplayLanguageDesired"] = "RU-RU"; - srcObj[S_MSG_PARAMS]["isMediaApplication"] = true; - srcObj[S_MSG_PARAMS]["languageDesired"] = "EN-US"; - srcObj[S_MSG_PARAMS]["ngnMediaScreenAppName"] = "SCREEN NAME"; - srcObj[S_MSG_PARAMS]["syncMsgVersion"]["majorVersion"] = 2; - srcObj[S_MSG_PARAMS]["syncMsgVersion"]["minorVersion"] = 10; - srcObj[S_MSG_PARAMS]["syncMsgVersion"]["patchVersion"] = 5; - - srcObj[S_MSG_PARAMS]["ttsName"][0]["text"] = "ABC"; - srcObj[S_MSG_PARAMS]["ttsName"][0]["type"] = "TEXT"; - srcObj[S_MSG_PARAMS]["vrSynonyms"][0] = "Synonym1"; - srcObj[S_MSG_PARAMS]["vrSynonyms"][1] = "Synonym2"; - srcObj[S_MSG_PARAMS]["null"] = SmartObject(); - srcObj[S_MSG_PARAMS]["double"] = -0.1234; - - printf("\n Random object.\n"); - calculateConvertionTime(srcObj, dstObj); -} + // First iteration + for (int i = 0; i < arraySize; i++) { + arrayObj[i] = rand(); + } -TEST_F(SmartObjectConvertionTimeTest, test_map_object_convertion) { - SmartObject srcObj, dstObj, mapObj, innerObj; - CSmartSchema schema = initObjectSchema(); - - srcObj.setSchema(schema); - dstObj.setSchema(schema); - - // First iteration - mapObj["request"]["name"] = "My Request"; - mapObj["request"]["id"] = 123; - mapObj["response"]["name"] = "My Response"; - mapObj["response"]["id"] = 456; - mapObj["we"]["need"]["to"]["go"]["deeper"] = true; - - srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; - srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; - srcObj[S_PARAMS][S_CORRELATION_ID] = 13; - srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; - srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2; - srcObj[S_MSG_PARAMS]["value"] = mapObj; - - printf("\n MAP object.\n"); - calculateConvertionTime(srcObj, dstObj); - - // Second iteration - innerObj = mapObj; - mapObj["request"]["value"] = innerObj; - mapObj["response"]["value"] = innerObj; - mapObj["we"]["need"]["to"]["go"]["deeper"]["value"] = innerObj; - srcObj[S_MSG_PARAMS]["value"] = mapObj; - - printf("\n Complex MAP object.\n"); - calculateConvertionTime(srcObj, dstObj); - - // Third iteration - innerObj = mapObj; - mapObj["request"]["value"] = innerObj; - mapObj["response"]["value"] = innerObj; - mapObj["we"]["need"]["to"]["go"]["deeper"]["value"] = innerObj; - srcObj[S_MSG_PARAMS]["value"] = mapObj; - - printf("\n Very Complex MAP object.\n"); - calculateConvertionTime(srcObj, dstObj); - - // Last iteration - innerObj = mapObj; - mapObj["request"]["value"] = innerObj; - mapObj["response"]["value"] = innerObj; - mapObj["we"]["need"]["to"]["go"]["deeper"]["value"] = innerObj; - srcObj[S_MSG_PARAMS]["value"] = mapObj; - - printf("\n Very Very Complex MAP object.\n"); - calculateConvertionTime(srcObj, dstObj); -} + srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; + srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; + srcObj[S_PARAMS][S_CORRELATION_ID] = 13; + srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; + srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2; + srcObj[S_MSG_PARAMS]["array"] = arrayObj; + + printf("\n Array object [%d].\n", arraySize); + calculateConvertionTime(srcObj, dstObj); + + // Second iteration + printf("\n Array object [%d x %d].\n", arraySize, arraySize); + innerObj = arrayObj; + for (int i = 0; i < arraySize; i++) { + arrayObj[i] = innerObj; + } -TEST_F(SmartObjectConvertionTimeTest, test_array_convertion) { - SmartObject srcObj, dstObj, arrayObj, innerObj; - CSmartSchema schema = initObjectSchema(); - int arraySize = 10; + srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; + srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; + srcObj[S_PARAMS][S_CORRELATION_ID] = 13; + srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; + srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2; + srcObj[S_MSG_PARAMS]["array"] = arrayObj; - srcObj.setSchema(schema); - dstObj.setSchema(schema); + calculateConvertionTime(srcObj, dstObj); - // First iteration - for (int i = 0; i < arraySize; i++) { - arrayObj[i] = rand(); - } + // Third iteration + printf( + "\n Array object [%d x %d x %d].\n", arraySize, arraySize, arraySize); + innerObj = arrayObj; + for (int i = 0; i < arraySize; i++) { + arrayObj[i] = innerObj; + } - srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; - srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; - srcObj[S_PARAMS][S_CORRELATION_ID] = 13; - srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; - srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2; - srcObj[S_MSG_PARAMS]["array"] = arrayObj; - - printf("\n Array object [%d].\n", arraySize); - calculateConvertionTime(srcObj, dstObj); - - // Second iteration - printf("\n Array object [%d x %d].\n", arraySize, arraySize); - innerObj = arrayObj; - for (int i = 0; i < arraySize; i++) { - arrayObj[i] = innerObj; - } + srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; + srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; + srcObj[S_PARAMS][S_CORRELATION_ID] = 13; + srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; + srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2; + srcObj[S_MSG_PARAMS]["array"] = arrayObj; + + calculateConvertionTime(srcObj, dstObj); + + // Fourth iteration + printf("\n Array object [%d x %d x %d x %d].\n", + arraySize, + arraySize, + arraySize, + arraySize); + innerObj = arrayObj; + for (int i = 0; i < arraySize; i++) { + arrayObj[i] = innerObj; + } - srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; - srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; - srcObj[S_PARAMS][S_CORRELATION_ID] = 13; - srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; - srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2; - srcObj[S_MSG_PARAMS]["array"] = arrayObj; + srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; + srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; + srcObj[S_PARAMS][S_CORRELATION_ID] = 13; + srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; + srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2; + srcObj[S_MSG_PARAMS]["array"] = arrayObj; + + calculateConvertionTime(srcObj, dstObj); + + // Last iteration + printf("\n Array object [%d x %d x %d x %d x %d].\n", + arraySize, + arraySize, + arraySize, + arraySize, + arraySize); + innerObj = arrayObj; + for (int i = 0; i < arraySize; i++) { + arrayObj[i] = innerObj; + } - calculateConvertionTime(srcObj, dstObj); + srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; + srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; + srcObj[S_PARAMS][S_CORRELATION_ID] = 13; + srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; + srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2; + srcObj[S_MSG_PARAMS]["array"] = arrayObj; - // Third iteration - printf("\n Array object [%d x %d x %d].\n", arraySize, arraySize, arraySize); - innerObj = arrayObj; - for (int i = 0; i < arraySize; i++) { - arrayObj[i] = innerObj; + calculateConvertionTime(srcObj, dstObj); } - srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; - srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; - srcObj[S_PARAMS][S_CORRELATION_ID] = 13; - srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; - srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2; - srcObj[S_MSG_PARAMS]["array"] = arrayObj; - - calculateConvertionTime(srcObj, dstObj); - - // Fourth iteration - printf("\n Array object [%d x %d x %d x %d].\n", - arraySize, - arraySize, - arraySize, - arraySize); - innerObj = arrayObj; - for (int i = 0; i < arraySize; i++) { - arrayObj[i] = innerObj; + TEST_F(SmartObjectConvertionTimeTest, test_object_with_enum_convertion) { + SmartObject srcObj, dstObj; + CSmartSchema schema = initObjectSchema(); + + srcObj.setSchema(schema); + dstObj.setSchema(schema); + + srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; + srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; + srcObj[S_PARAMS][S_CORRELATION_ID] = 13; + srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; + srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2; + srcObj[S_MSG_PARAMS]["success"] = true; + srcObj[S_MSG_PARAMS]["resultCode"] = 2; + srcObj[S_MSG_PARAMS]["info"] = "Some string"; + srcObj[S_MSG_PARAMS]["tryAgainTime"] = 322; + srcObj.setSchema(schema); + + printf("\n Object with enum.\n"); + calculateConvertionTime(srcObj, dstObj); } - srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; - srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; - srcObj[S_PARAMS][S_CORRELATION_ID] = 13; - srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; - srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2; - srcObj[S_MSG_PARAMS]["array"] = arrayObj; - - calculateConvertionTime(srcObj, dstObj); - - // Last iteration - printf("\n Array object [%d x %d x %d x %d x %d].\n", - arraySize, - arraySize, - arraySize, - arraySize, - arraySize); - innerObj = arrayObj; - for (int i = 0; i < arraySize; i++) { - arrayObj[i] = innerObj; + TEST_F(SmartObjectConvertionTimeTest, test_object_without_enum_convertion) { + SmartObject srcObj, dstObj; + CSmartSchema schema = initObjectSchema(); + + srcObj.setSchema(schema); + dstObj.setSchema(schema); + + srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; + srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; + srcObj[S_PARAMS][S_CORRELATION_ID] = 13; + srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; + srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2; + srcObj[S_MSG_PARAMS]["success"] = true; + srcObj[S_MSG_PARAMS]["resultCode"] = 2; + srcObj[S_MSG_PARAMS]["info"] = "Some string"; + srcObj[S_MSG_PARAMS]["tryAgainTime"] = 322; + + printf("\n Object without enum.\n"); + calculateConvertionTime(srcObj, dstObj); } - - srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; - srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; - srcObj[S_PARAMS][S_CORRELATION_ID] = 13; - srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; - srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2; - srcObj[S_MSG_PARAMS]["array"] = arrayObj; - - calculateConvertionTime(srcObj, dstObj); -} - -TEST_F(SmartObjectConvertionTimeTest, test_object_with_enum_convertion) { - SmartObject srcObj, dstObj; - CSmartSchema schema = initObjectSchema(); - - srcObj.setSchema(schema); - dstObj.setSchema(schema); - - srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; - srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; - srcObj[S_PARAMS][S_CORRELATION_ID] = 13; - srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; - srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2; - srcObj[S_MSG_PARAMS]["success"] = true; - srcObj[S_MSG_PARAMS]["resultCode"] = 2; - srcObj[S_MSG_PARAMS]["info"] = "Some string"; - srcObj[S_MSG_PARAMS]["tryAgainTime"] = 322; - srcObj.setSchema(schema); - - printf("\n Object with enum.\n"); - calculateConvertionTime(srcObj, dstObj); -} - -TEST_F(SmartObjectConvertionTimeTest, test_object_without_enum_convertion) { - SmartObject srcObj, dstObj; - CSmartSchema schema = initObjectSchema(); - - srcObj.setSchema(schema); - dstObj.setSchema(schema); - - srcObj[S_PARAMS][S_MESSAGE_TYPE] = MessageTypeTest::request; - srcObj[S_PARAMS][S_FUNCTION_ID] = FunctionIdTest::RegisterAppInterface; - srcObj[S_PARAMS][S_CORRELATION_ID] = 13; - srcObj[S_PARAMS][S_PROTOCOL_TYPE] = 0; - srcObj[S_PARAMS][S_PROTOCOL_VERSION] = 2; - srcObj[S_MSG_PARAMS]["success"] = true; - srcObj[S_MSG_PARAMS]["resultCode"] = 2; - srcObj[S_MSG_PARAMS]["info"] = "Some string"; - srcObj[S_MSG_PARAMS]["tryAgainTime"] = 322; - - printf("\n Object without enum.\n"); - calculateConvertionTime(srcObj, dstObj); -} - +}; } // namespace smart_object_test } // namespace components -} // namespace test namespace ns_smart_device_link { namespace ns_smart_objects { diff --git a/src/components/transport_manager/src/cloud/websocket_client_connection.cc b/src/components/transport_manager/src/cloud/websocket_client_connection.cc index f6b791f886..c3eba1d905 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -248,7 +248,6 @@ void WebsocketClientConnection::OnRead(boost::system::error_code ec, Shutdown(); return; } - std::string data_str = boost::beast::buffers_to_string(buffer_.data()); ssize_t size = (ssize_t)buffer_.size(); const uint8_t* data = boost::asio::buffer_cast<const uint8_t*>( diff --git a/src/components/transport_manager/src/tcp/tcp_client_listener.cc b/src/components/transport_manager/src/tcp/tcp_client_listener.cc index 2683ce02c4..4010b2b628 100644 --- a/src/components/transport_manager/src/tcp/tcp_client_listener.cc +++ b/src/components/transport_manager/src/tcp/tcp_client_listener.cc @@ -163,9 +163,13 @@ TcpClientListener::~TcpClientListener() { void SetKeepaliveOptions(const int fd) { SDL_LOG_AUTO_TRACE(); SDL_LOG_DEBUG("fd: " << fd); + // cppcheck-suppress unreadVariable int yes = 1; + // cppcheck-suppress unreadVariable int keepidle = 3; // 3 seconds to disconnection detecting + // cppcheck-suppress unreadVariable int keepcnt = 5; + // cppcheck-suppress unreadVariable int keepintvl = 1; #ifdef __linux__ int user_timeout = 7000; // milliseconds 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 7d0eda9773..6a16e81d18 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 @@ -558,13 +558,13 @@ void TransportAdapterImpl::SearchDeviceDone(const DeviceVector& devices) { bool device_found = false; devices_mutex_.Acquire(); - for (DeviceMap::iterator it = devices_.begin(); it != devices_.end(); - ++it) { - DeviceSptr existing_device = it->second; + for (DeviceMap::iterator iter = devices_.begin(); iter != devices_.end(); + ++iter) { + DeviceSptr existing_device = iter->second; if (device->IsSameAs(existing_device.get())) { existing_device->set_keep_on_disconnect(true); device_found = true; - SDL_LOG_DEBUG("device found. DeviceSptr" << it->second); + SDL_LOG_DEBUG("device found. DeviceSptr" << iter->second); break; } } diff --git a/src/components/transport_manager/src/transport_manager_impl.cc b/src/components/transport_manager/src/transport_manager_impl.cc index a0d019cd69..eb1b63fb96 100644 --- a/src/components/transport_manager/src/transport_manager_impl.cc +++ b/src/components/transport_manager/src/transport_manager_impl.cc @@ -1386,7 +1386,8 @@ void TransportManagerImpl::Handle(::protocol_handler::RawMessagePtr msg) { } TransportAdapter* transport_adapter = connection->transport_adapter; - if (NULL == transport_adapter) { + + if (nullptr == transport_adapter) { std::string error_text = "Transport adapter is not found"; SDL_LOG_ERROR(error_text); RaiseEvent(&TransportManagerListener::OnTMMessageSendFailed, diff --git a/src/components/transport_manager/src/usb/qnx/usb_handler.cc b/src/components/transport_manager/src/usb/qnx/usb_handler.cc index 441fc8b664..2381daa15a 100644 --- a/src/components/transport_manager/src/usb/qnx/usb_handler.cc +++ b/src/components/transport_manager/src/usb/qnx/usb_handler.cc @@ -76,11 +76,6 @@ UsbHandler::~UsbHandler() { } } -bool operator==(const usbd_device_instance_t& a, - const usbd_device_instance_t& b) { - return a.path == b.path && a.devno == b.devno; -} - void UsbHandler::DeviceArrived(usbd_connection* connection, usbd_device_instance_t* instance) { for (Devices::const_iterator it = devices_.begin(); it != devices_.end(); diff --git a/src/components/transport_manager/src/usb/usb_device_scanner.cc b/src/components/transport_manager/src/usb/usb_device_scanner.cc index b0749728a6..e2e2fecd6e 100644 --- a/src/components/transport_manager/src/usb/usb_device_scanner.cc +++ b/src/components/transport_manager/src/usb/usb_device_scanner.cc @@ -47,7 +47,7 @@ SDL_CREATE_LOG_VARIABLE("TransportManager") class AoaInitSequence : public UsbControlTransferSequence { public: AoaInitSequence(); - AoaInitSequence(const TransportManagerSettings& settings); + explicit AoaInitSequence(const TransportManagerSettings& settings); virtual ~AoaInitSequence() {} private: diff --git a/src/components/transport_manager/test/include/transport_manager/raw_message_matcher.h b/src/components/transport_manager/test/include/transport_manager/raw_message_matcher.h index 2ee699096f..5aedfd58aa 100644 --- a/src/components/transport_manager/test/include/transport_manager/raw_message_matcher.h +++ b/src/components/transport_manager/test/include/transport_manager/raw_message_matcher.h @@ -55,7 +55,8 @@ class RawMessageMatcher : public MatcherInterface<RawMessagePtr> { public: explicit RawMessageMatcher(RawMessagePtr ptr); - virtual bool MatchAndExplain(const RawMessagePtr ptr, + DEPRECATED + virtual bool MatchAndExplain(const RawMessagePtr msg, MatchResultListener* listener) const; virtual void DescribeTo(std::ostream* os) const; virtual void DescribeNegationTo(std::ostream* os) const; diff --git a/src/components/transport_manager/test/network_interface_listener_test.cc b/src/components/transport_manager/test/network_interface_listener_test.cc index c6e007b62a..b2d9cbb51e 100644 --- a/src/components/transport_manager/test/network_interface_listener_test.cc +++ b/src/components/transport_manager/test/network_interface_listener_test.cc @@ -30,24 +30,10 @@ class NetworkInterfaceListenerTest : public ::testing::Test { virtual ~NetworkInterfaceListenerTest() {} protected: - struct InterfaceEntry { - const char* name; - const char* ipv4_address; - const char* ipv6_address; - unsigned int flags; - }; - void Deinit() { delete interface_listener_impl_; } - void SleepFor(long msec) const { - if (msec > 0) { - struct timespec ts = {0, msec * 1000 * 1000}; - nanosleep(&ts, NULL); - } - } - NetworkInterfaceListenerImpl* interface_listener_impl_; MockTcpClientListener mock_tcp_client_listener_; }; diff --git a/src/components/transport_manager/test/raw_message_matcher.cc b/src/components/transport_manager/test/raw_message_matcher.cc index 61d73a9253..48e0908f9a 100644 --- a/src/components/transport_manager/test/raw_message_matcher.cc +++ b/src/components/transport_manager/test/raw_message_matcher.cc @@ -38,6 +38,7 @@ namespace transport_manager_test { RawMessageMatcher::RawMessageMatcher(RawMessagePtr ptr) : ptr_(ptr) {} +// cppcheck-suppress unusedFunction bool RawMessageMatcher::MatchAndExplain(const RawMessagePtr msg, MatchResultListener* listener) const { if (msg->data_size() != ptr_->data_size()) { diff --git a/src/components/transport_manager/test/websocket_sample_client/websocket_sample_client.cc b/src/components/transport_manager/test/websocket_sample_client/websocket_sample_client.cc index 88525ad29d..6c2ff12bfd 100644 --- a/src/components/transport_manager/test/websocket_sample_client/websocket_sample_client.cc +++ b/src/components/transport_manager/test/websocket_sample_client/websocket_sample_client.cc @@ -105,7 +105,6 @@ bool WSSampleClient<WS>::Connect(tcp::resolver::results_type& results) { boost::system::error_code ec; boost::asio::connect(ws_->next_layer(), results.begin(), results.end(), ec); if (ec) { - std::string str_err = "ErrorMessage: " + ec.message(); return false; } return true; @@ -116,7 +115,6 @@ bool WSSampleClient<WSS>::Connect(tcp::resolver::results_type& results) { boost::system::error_code ec; boost::asio::connect(ws_->lowest_layer(), results.begin(), results.end(), ec); if (ec) { - std::string str_err = "ErrorMessage: " + ec.message(); return false; } return true; @@ -128,7 +126,6 @@ bool WSSampleClient<WS>::Handshake(const std::string& host, boost::system::error_code ec; ws_->handshake(host, target, ec); if (ec) { - std::string str_err = "ErrorMessage: " + ec.message(); return false; } return true; @@ -156,7 +153,6 @@ bool WSSampleClient<WSS>::Handshake(const std::string& host, ws_->handshake(host, target, ec); if (ec) { - std::string str_err = "ErrorMessage: " + ec.message(); return false; } diff --git a/src/components/utils/src/date_time.cc b/src/components/utils/src/date_time.cc index cea35a977e..389f973837 100644 --- a/src/components/utils/src/date_time.cc +++ b/src/components/utils/src/date_time.cc @@ -46,9 +46,7 @@ namespace date_time { TimeDuration getCurrentTime() { return bpt::microsec_clock::local_time() - bpt::from_time_t(0); } -TimeDuration TimeDurationZero() { - return TimeDuration(0, 0, 0, 0); -} + int64_t getSecs(const TimeDuration& t) { return t.total_seconds(); } @@ -61,13 +59,22 @@ int64_t getuSecs(const TimeDuration& t) { return t.total_microseconds(); } +#ifdef BUILD_TESTS +// cppcheck-suppress unusedFunction //Used in unit tests +TimeDuration TimeDurationZero() { + return TimeDuration(0, 0, 0, 0); +} + +// cppcheck-suppress unusedFunction //Used in unit tests int64_t get_just_mSecs(const TimeDuration& t) { return t.total_milliseconds() % MILLISECONDS_IN_SECOND; } +// cppcheck-suppress unusedFunction //Used in unit tests int64_t get_just_uSecs(const TimeDuration& t) { return t.total_microseconds() % MICROSECONDS_IN_SECOND; } +#endif // BUILD_TESTS int64_t calculateTimeSpan(const TimeDuration& sinceTime) { return calculateTimeDiff(getCurrentTime(), sinceTime); diff --git a/src/components/utils/src/file_system.cc b/src/components/utils/src/file_system.cc index e5c98183ac..5985475983 100644 --- a/src/components/utils/src/file_system.cc +++ b/src/components/utils/src/file_system.cc @@ -56,8 +56,7 @@ using boost::system::error_code; uint64_t file_system::GetAvailableDiskSpace(const std::string& path) { SDL_LOG_AUTO_TRACE(); error_code ec; - fs::space_info si = {0, 0, 0}; - si = fs::space(path, ec); + fs::space_info si = fs::space(path, ec); if (ec) { // If something went wrong, assume no free space @@ -466,11 +465,10 @@ bool file_system::ReadFile(const std::string& name, std::string& result) { const std::string file_system::ConvertPathForURL(const std::string& path) { SDL_LOG_AUTO_TRACE(); const std::string reserved_symbols = "!#$&'()*+,:;=?@[] "; - size_t pos = std::string::npos; std::string converted_path; for (const auto symbol : path) { - pos = reserved_symbols.find_first_of(symbol); + size_t pos = reserved_symbols.find_first_of(symbol); if (pos != std::string::npos) { const size_t size = 100; char percent_value[size]; |