[ML] Fix issues found by SVACE 65/253465/5
authorPawel Wasowski <p.wasowski2@samsung.com>
Wed, 10 Feb 2021 09:20:12 +0000 (10:20 +0100)
committerPawel Wasowski <p.wasowski2@samsung.com>
Wed, 10 Feb 2021 13:52:45 +0000 (13:52 +0000)
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 <p.wasowski2@samsung.com>
src/ml/ml_pipeline.cc
src/ml/ml_pipeline_source.cc
src/ml/ml_pipeline_source.h
src/ml/ml_pipeline_switch.cc
src/ml/ml_pipeline_switch.h
src/ml/ml_pipeline_valve.cc
src/ml/ml_pipeline_valve.h

index a180d4e43f54c684ce27e4bf1755235706a2317f..22928440f6bad16b1875ffa009c6e634ac142070 100644 (file)
@@ -245,7 +245,7 @@ PlatformResult Pipeline::GetSource(const std::string& name) {
   }
 
   std::unique_ptr<Source> 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> 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> 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)});
   }
index 418b45227131b6702192106be457950aacddbafe..665d94aff1fa691df45894dd8a3c24d36aa7fb17 100644 (file)
@@ -25,7 +25,7 @@ namespace ml {
 namespace pipeline {
 
 PlatformResult Source::CreateSource(const std::string& name, ml_pipeline_h pipeline,
-                                    std::unique_ptr<Source>* out) {
+                                    std::unique_ptr<Source>& 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) {
index e0cf981f0c5381f6f406fd488c49d3eecfb795b8..8fe6a4f4a7e865ee77fe21e5c420690908bbeb59 100644 (file)
@@ -35,7 +35,7 @@ namespace pipeline {
 class Source {
  public:
   static PlatformResult CreateSource(const std::string& name, ml_pipeline_h pipeline,
-                                     std::unique_ptr<Source>* out);
+                                     std::unique_ptr<Source>& out);
 
   ~Source();
 
index c6045303d256cc0fdfc75511fa0989c3ab235dcd..b5ca2e5ee503b677b1ac251b701c00f7977b2ce2 100644 (file)
@@ -40,7 +40,7 @@ namespace ml {
 namespace pipeline {
 
 PlatformResult Switch::CreateSwitch(const std::string& name, ml_pipeline_h pipeline,
-                                    std::unique_ptr<Switch>* out) {
+                                    std::unique_ptr<Switch>& 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) {
index 48553c947262056ee57fc3d61e02c0145e142e49..6cea5823e9073e23fdbeae82695a37acc74b69a5 100644 (file)
@@ -33,7 +33,7 @@ namespace pipeline {
 class Switch {
  public:
   static PlatformResult CreateSwitch(const std::string& name, ml_pipeline_h pipeline,
-                                     std::unique_ptr<Switch>* out);
+                                     std::unique_ptr<Switch>& out);
 
   std::string GetType() const;
   PlatformResult GetPadList(picojson::array* out) const;
index 06d5a5e5253ee01007db6fce58861d85df92950a..a171b9a9372883ddf9edadc7eb0137e4ca3a5d2c 100644 (file)
@@ -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<Valve>* out) {
+                                  Pipeline& pipeline, std::unique_ptr<Valve>& 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) {
index 75452b0297f82d4ece0f67a151c5eabf476bebd9..d6744b478be65f36b6722463697d6a6d48cde57b 100644 (file)
@@ -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<Valve>* out);
+                                    Pipeline& pipeline, std::unique_ptr<Valve>& out);
 
   ~Valve();