From: Pawel Wasowski Date: Wed, 10 Feb 2021 09:20:12 +0000 (+0100) Subject: [ML] Fix issues found by SVACE X-Git-Tag: submit/tizen/20210217.032056~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7b995ecdf9637ac7ce46a8a16413026415677fdb;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [ML] Fix issues found by SVACE This commit fixes the following SVACE problems (WGIDs) in ML: 456856, 456857, 456858 [Verification] Code compiles. The changed code was tested with the snippets below // Source var pipeline_input = tizen.ml.pipeline.createPipeline("appsrc name=srcx ! " + "other/tensor,dimension=(string)1:1:1:1,type=(string)int8," +"framerate=(fraction)0/1 ! tensor_sink name=sinkx") var source_input = pipeline_input.getSource("srcx") // Valve var pipeline_def = "videotestsrc is-live=true ! videoconvert ! videoscale" + " ! video/x-raw,format=RGBx,width=16,height=16,framerate=10/1" + " ! tensor_converter ! valve name=valve1 ! fakesink"; var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def, function(state) {console.log(state);}); // READY // PAUSED var v = pipeline.getValve('valve1') // Valve {name: "valve1", _pipeline_id: 1} // Switch var pipeline_def = "videotestsrc is-live=true" + " ! videoconvert" + " ! tensor_converter" + " ! output-selector name=outs outs.src_0" + " ! tensor_sink name=sink0 async=false outs.src_1" + " ! tensor_sink name=sink1 async=false" var pipeline = tizen.ml.pipeline.createPipeline(pipeline_def, function(state) {console.log(state);}) pipeline.getSwitch('outs') // Switch {name: "outs", type: "OUTPUT_SELECTOR", _pipeline_id: 3} Change-Id: I9316f6a9f6f225aaa741e25458b53109f7c17c16 Signed-off-by: Pawel Wasowski --- diff --git a/src/ml/ml_pipeline.cc b/src/ml/ml_pipeline.cc index a180d4e4..22928440 100644 --- a/src/ml/ml_pipeline.cc +++ b/src/ml/ml_pipeline.cc @@ -245,7 +245,7 @@ PlatformResult Pipeline::GetSource(const std::string& name) { } std::unique_ptr source_ptr; - auto ret = Source::CreateSource(name, pipeline_, &source_ptr); + auto ret = Source::CreateSource(name, pipeline_, source_ptr); if (ret) { sources_.insert({name, std::move(source_ptr)}); } @@ -266,7 +266,7 @@ PlatformResult Pipeline::GetSwitch(const std::string& name, std::string* type) { LoggerD("Switch [%s] not found", name.c_str()); std::unique_ptr switch_ptr; - auto ret = Switch::CreateSwitch(name, pipeline_, &switch_ptr); + auto ret = Switch::CreateSwitch(name, pipeline_, switch_ptr); if (ret) { *type = switch_ptr->GetType(); switches_.insert({name, std::move(switch_ptr)}); @@ -287,7 +287,7 @@ PlatformResult Pipeline::GetValve(const std::string& name) { LoggerD("Creating [%s] Valve", name.c_str()); std::unique_ptr valve_ptr; - auto ret = Valve::CreateValve(name, pipeline_, *this, &valve_ptr); + auto ret = Valve::CreateValve(name, pipeline_, *this, valve_ptr); if (ret) { valves_.insert({name, std::move(valve_ptr)}); } diff --git a/src/ml/ml_pipeline_source.cc b/src/ml/ml_pipeline_source.cc index 418b4522..665d94af 100644 --- a/src/ml/ml_pipeline_source.cc +++ b/src/ml/ml_pipeline_source.cc @@ -25,7 +25,7 @@ namespace ml { namespace pipeline { PlatformResult Source::CreateSource(const std::string& name, ml_pipeline_h pipeline, - std::unique_ptr* out) { + std::unique_ptr& out) { ScopeLogger("name: [%s], pipeline: [%p]", name.c_str(), pipeline); ml_pipeline_src_h source_handle = nullptr; auto ret = ml_pipeline_src_get_handle(pipeline, name.c_str(), &source_handle); @@ -34,7 +34,7 @@ PlatformResult Source::CreateSource(const std::string& name, ml_pipeline_h pipel return util::ToPlatformResult(ret, "Could not get source"); } - out->reset(new (std::nothrow) Source{name, source_handle}); + out.reset(new (std::nothrow) Source{name, source_handle}); if (!out) { ret = ml_pipeline_src_release_handle(source_handle); if (ML_ERROR_NONE != ret) { diff --git a/src/ml/ml_pipeline_source.h b/src/ml/ml_pipeline_source.h index e0cf981f..8fe6a4f4 100644 --- a/src/ml/ml_pipeline_source.h +++ b/src/ml/ml_pipeline_source.h @@ -35,7 +35,7 @@ namespace pipeline { class Source { public: static PlatformResult CreateSource(const std::string& name, ml_pipeline_h pipeline, - std::unique_ptr* out); + std::unique_ptr& out); ~Source(); diff --git a/src/ml/ml_pipeline_switch.cc b/src/ml/ml_pipeline_switch.cc index c6045303..b5ca2e5e 100644 --- a/src/ml/ml_pipeline_switch.cc +++ b/src/ml/ml_pipeline_switch.cc @@ -40,7 +40,7 @@ namespace ml { namespace pipeline { PlatformResult Switch::CreateSwitch(const std::string& name, ml_pipeline_h pipeline, - std::unique_ptr* out) { + std::unique_ptr& out) { ScopeLogger("name: [%s], pipeline: [%p]", name.c_str(), pipeline); ml_pipeline_switch_e type = ML_PIPELINE_SWITCH_INPUT_SELECTOR; @@ -52,7 +52,7 @@ PlatformResult Switch::CreateSwitch(const std::string& name, ml_pipeline_h pipel } LoggerD("ml_pipeline_switch_get_handle() succeeded"); - out->reset(new (std::nothrow) Switch{name, TypeToString(type), switch_handle}); + out.reset(new (std::nothrow) Switch{name, TypeToString(type), switch_handle}); if (!out) { ret = ml_pipeline_switch_release_handle(switch_handle); if (ML_ERROR_NONE != ret) { diff --git a/src/ml/ml_pipeline_switch.h b/src/ml/ml_pipeline_switch.h index 48553c94..6cea5823 100644 --- a/src/ml/ml_pipeline_switch.h +++ b/src/ml/ml_pipeline_switch.h @@ -33,7 +33,7 @@ namespace pipeline { class Switch { public: static PlatformResult CreateSwitch(const std::string& name, ml_pipeline_h pipeline, - std::unique_ptr* out); + std::unique_ptr& out); std::string GetType() const; PlatformResult GetPadList(picojson::array* out) const; diff --git a/src/ml/ml_pipeline_valve.cc b/src/ml/ml_pipeline_valve.cc index 06d5a5e5..a171b9a9 100644 --- a/src/ml/ml_pipeline_valve.cc +++ b/src/ml/ml_pipeline_valve.cc @@ -29,7 +29,7 @@ namespace ml { namespace pipeline { PlatformResult Valve::CreateValve(const std::string& name, ml_pipeline_h native_pipeline_handle, - Pipeline& pipeline, std::unique_ptr* out) { + Pipeline& pipeline, std::unique_ptr& out) { ScopeLogger("name: [%s], native_pipeline_handle: [%p]", name.c_str(), native_pipeline_handle); ml_pipeline_valve_h valve_handle = nullptr; @@ -40,7 +40,7 @@ PlatformResult Valve::CreateValve(const std::string& name, ml_pipeline_h native_ } LoggerD("ml_pipeline_valve_get_handle() succeeded"); - out->reset(new (std::nothrow) Valve{name, valve_handle, pipeline}); + out.reset(new (std::nothrow) Valve{name, valve_handle, pipeline}); if (!out) { ret = ml_pipeline_valve_release_handle(valve_handle); if (ML_ERROR_NONE != ret) { diff --git a/src/ml/ml_pipeline_valve.h b/src/ml/ml_pipeline_valve.h index 75452b02..d6744b47 100644 --- a/src/ml/ml_pipeline_valve.h +++ b/src/ml/ml_pipeline_valve.h @@ -35,7 +35,7 @@ namespace pipeline { class Valve { public: static PlatformResult CreateValve(const std::string& name, ml_pipeline_h native_pipeline_handle, - Pipeline& pipeline, std::unique_ptr* out); + Pipeline& pipeline, std::unique_ptr& out); ~Valve();