OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[core] Fix Coverity issue in inference component of core (#33702)
Pawel Raasz78f646271e3b
diff --git a/src/inference/dev_api/openvino/runtime/plugin_config.hpp b/src/inference/dev_api/openvino/runtime/plugin_config.hppindex 64bb3729222..14b5eafd841 100644--- a/src/inference/dev_api/openvino/runtime/plugin_config.hpp+++ b/src/inference/dev_api/openvino/runtime/plugin_config.hpp@@ -201,7 +201,7 @@ protected:virtual void apply_model_specific_options(const IRemoteContext* context, const ov::Model& model) {}void apply_env_options();- void apply_config_options(std::string_view device_name, std::filesystem::path config_path = "");+ void apply_config_options(std::string_view device_name, const std::filesystem::path& config_path = {});virtual void finalize_impl(const IRemoteContext* context) {}template <typename T, PropertyMutability mutability>@@ -227,7 +227,7 @@ protected:}}- ov::AnyMap read_config_file(std::filesystem::path filename, std::string_view target_device_name) const;+ ov::AnyMap read_config_file(const std::filesystem::path& filename, std::string_view target_device_name) const;ov::AnyMap read_env() const;static ov::Any read_env(const std::string& option_name, std::string_view prefix, const ConfigOptionBase* option);void cleanup_unsupported(ov::AnyMap& config) const;@@ -272,7 +272,7 @@ struct ConfigOption : public TypedOption<T> {std::string_view desc,std::function<bool(T)> validator = nullptr): TypedOption<T>(default_val, prop_name, desc),- validator(validator) {+ validator(std::move(validator)) {OptionRegistrationHelper option(config, name, this);}constexpr static const auto visibility = visibility_;diff --git a/src/inference/src/dev/core_impl.cpp b/src/inference/src/dev/core_impl.cppindex 6130ceda4a4..d5b386097a9 100644--- a/src/inference/src/dev/core_impl.cpp+++ b/src/inference/src/dev/core_impl.cpp@@ -236,7 +236,7 @@ ov::SoPtr<ov::ICompiledModel> import_compiled_model(const ov::Plugin& plugin,ov::SoPtr<ov::ICompiledModel> compiled_model;if (auto blob_hint = config.find(ov::hint::compiled_blob.name()); blob_hint != config.end()) {try {- auto compiled_blob = blob_hint->second.as<ov::Tensor>();+ const auto& compiled_blob = blob_hint->second.as<ov::Tensor>();compiled_model = context ? plugin.import_model(compiled_blob, context, config): plugin.import_model(compiled_blob, config);} catch (...) {@@ -1050,7 +1050,7 @@ std::vector<std::string> ov::CoreImpl::get_available_devices() const {devices.push_back(device_name + '.' + deviceID);}} else if (!devicesIDs.empty()) {- devices.push_back(device_name);+ devices.push_back(std::move(device_name));}}diff --git a/src/inference/src/dev/device_id_parser.cpp b/src/inference/src/dev/device_id_parser.cppindex c7bdd03b0f5..12e59dd48f7 100644--- a/src/inference/src/dev/device_id_parser.cpp+++ b/src/inference/src/dev/device_id_parser.cpp@@ -40,7 +40,7 @@ std::vector<std::string> DeviceIDParser::get_hetero_devices(const std::string& f}if (!fallback_dev.empty())- deviceNames.push_back(fallback_dev);+ deviceNames.push_back(std::move(fallback_dev));return deviceNames;}diff --git a/src/inference/src/dev/exec_model_info.cpp b/src/inference/src/dev/exec_model_info.cppindex 16b3bd21721..450f032ef2a 100644--- a/src/inference/src/dev/exec_model_info.cpp+++ b/src/inference/src/dev/exec_model_info.cpp@@ -17,9 +17,7 @@ std::shared_ptr<ov::Node> ov::exec_model_info::ExecutionNode::clone_with_new_inpauto cloned = std::make_shared<ExecutionNode>();cloned->set_arguments(inputs);-- for (auto kvp : get_rt_info())- cloned->get_rt_info()[kvp.first] = kvp.second;+ cloned->get_rt_info().insert(get_rt_info().begin(), get_rt_info().end());for (size_t i = 0; i < get_output_size(); ++i)cloned->set_output_type(i, get_output_element_type(i), get_output_partial_shape(i));diff --git a/src/inference/src/dev/iplugin.cpp b/src/inference/src/dev/iplugin.cppindex 08c028a23a1..8b796e9f028 100644--- a/src/inference/src/dev/iplugin.cpp+++ b/src/inference/src/dev/iplugin.cpp@@ -40,7 +40,11 @@ bool is_graph_input_node(const std::shared_ptr<ov::Node>& node) {} // namespace-ov::IPlugin::IPlugin() : m_executor_manager(ov::threading::executor_manager()) {}+ov::IPlugin::IPlugin()+ : m_plugin_name(),+ m_core(),+ m_executor_manager(ov::threading::executor_manager()),+ m_version() {}void ov::IPlugin::set_version(const ov::Version& version) {m_version = version;@@ -479,7 +483,7 @@ std::unordered_set<std::string> ov::get_supported_nodes(// and operation names from original modelfor (auto&& name : supported) {if (original_ops.count(name)) {- res.insert(name);+ res.insert(std::move(name));}}// Remove parameters (or parameter/constant + convert) which has no supported consumersdiff --git a/src/inference/src/dev/plugin_config.cpp b/src/inference/src/dev/plugin_config.cppindex d298ab3a2fc..d0d04c8c483 100644--- a/src/inference/src/dev/plugin_config.cpp+++ b/src/inference/src/dev/plugin_config.cpp@@ -145,7 +145,7 @@ void PluginConfig::apply_env_options() {set_property(env_properties);}-void PluginConfig::apply_config_options(std::string_view device_name, std::filesystem::path config_path) {+void PluginConfig::apply_config_options(std::string_view device_name, const std::filesystem::path& config_path) {if (!config_path.empty()) {ov::AnyMap config_properties = read_config_file(config_path, device_name);cleanup_unsupported(config_properties);@@ -156,7 +156,8 @@ void PluginConfig::apply_config_options(std::string_view device_name, std::files}}-ov::AnyMap PluginConfig::read_config_file(std::filesystem::path filename, std::string_view target_device_name) const {+ov::AnyMap PluginConfig::read_config_file(const std::filesystem::path& filename,+ std::string_view target_device_name) const {if (filename.empty())return {};@@ -208,7 +209,7 @@ ov::AnyMap PluginConfig::read_env() const {for (auto& [name, option] : m_options_map) {if (auto val = read_env(name, m_allowed_env_prefix, option); !val.empty()) {- config[name] = val;+ config[name] = std::move(val);}}diff --git a/src/inference/src/dev/threading/cpu_streams_executor.cpp b/src/inference/src/dev/threading/cpu_streams_executor.cppindex d5f8fb22f10..305c986154d 100644--- a/src/inference/src/dev/threading/cpu_streams_executor.cpp+++ b/src/inference/src/dev/threading/cpu_streams_executor.cpp@@ -391,7 +391,7 @@ struct CPUStreamsExecutor::Impl {#if OV_THREAD == OV_THREAD_TBB || OV_THREAD == OV_THREAD_TBB_AUTO || OV_THREAD == OV_THREAD_TBB_ADAPTIVEauto& arena = stream._taskArena;if (nullptr != arena) {- arena->execute(std::move(task));+ arena->execute(task);} else {task();}