[Filter/TF] fix warning
authorJaeyun <jy1210.jung@samsung.com>
Thu, 20 Dec 2018 04:16:03 +0000 (13:16 +0900)
committerMyungJoo Ham <myungjoo.ham@gmail.com>
Thu, 20 Dec 2018 06:05:24 +0000 (15:05 +0900)
To fix coverity issue, init variables and code clean.

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
gst/tensor_filter/tensor_filter_tensorflow_core.cc
gst/tensor_filter/tensor_filter_tensorflow_core.h
gst/tensor_filter/tensor_filter_tensorflow_lite_core.cc

index 51e7524..5a7e93b 100644 (file)
 TFCore::TFCore (const char *_model_path)
 {
   model_path = _model_path;
+
+  memset (&inputTensorMeta, 0, sizeof (GstTensorsInfo));
+  memset (&outputTensorMeta, 0, sizeof (GstTensorsInfo));
+
+  for (int i = 0; i < NNS_TENSOR_SIZE_LIMIT; ++i) {
+    inputTensorRank[i] = 0;
+    outputTensorRank[i] = 0;
+  }
 }
 
 /**
@@ -225,13 +233,15 @@ TFCore::getTensorTypeToTF (tensor_type tType)
  *        -5 if the rank of input tensors exceeds our capacity NNS_TENSOR_RANK_LIMIT.
  */
 int
-TFCore::inputTensorValidation (std::vector<const NodeDef*> placeholders)
+TFCore::inputTensorValidation (const std::vector<const NodeDef*> &placeholders)
 {
-  if (inputTensorMeta.num_tensors != placeholders.size()){
+  int length = placeholders.size();
+
+  if (inputTensorMeta.num_tensors != length){
     GST_ERROR ("Input Tensor is not valid: the number of input tensor is different\n");
     return -1;
   }
-  int length = placeholders.size();
+
   for (int i = 0; i < length; i++) {
     const NodeDef* node = placeholders[i];
     string shape_description = "None";
@@ -299,13 +309,7 @@ int
 TFCore::setTensorProp (GstTensorsInfo * dest, const GstTensorsInfo * src)
 {
   dest->num_tensors = src->num_tensors;
-  for (int i = 0; i < src->num_tensors; i++) {
-    dest->info[i].name = src->info[i].name;
-    dest->info[i].type = src->info[i].type;
-    for (int j = 0; j < NNS_TENSOR_RANK_LIMIT; j++) {
-      dest->info[i].dimension[j] = src->info[i].dimension[j];
-    }
-  }
+  memcpy (dest->info, src->info, sizeof (GstTensorInfo) * src->num_tensors);
   return 0;
 }
 
index b1b878f..a5a0814 100644 (file)
@@ -91,7 +91,7 @@ private:
   tensor_type getTensorTypeFromTF (DataType tfType);
   DataType getTensorTypeToTF (tensor_type tType);
   int setTensorProp (GstTensorsInfo * dest, const GstTensorsInfo * src);
-  int inputTensorValidation (std::vector<const NodeDef*> placeholders);
+  int inputTensorValidation (const std::vector<const NodeDef*> &placeholders);
   /*TODO*/
   // int outputTensorValidation ();
 };
index bcbcc27..5253178 100644 (file)
@@ -42,6 +42,9 @@
 TFLiteCore::TFLiteCore (const char *_model_path)
 {
   model_path = _model_path;
+
+  memset (&inputTensorMeta, 0, sizeof (GstTensorsInfo));
+  memset (&outputTensorMeta, 0, sizeof (GstTensorsInfo));
 }
 
 /**