Fix build error - unused param, sign comapre accepted/tizen/unified/20220221.080248 submit/tizen/20220221.055747
authorgichan <gichan2.jang@samsung.com>
Mon, 21 Feb 2022 02:21:15 +0000 (11:21 +0900)
committerSangjung Woo <again4you@gmail.com>
Mon, 21 Feb 2022 05:38:13 +0000 (14:38 +0900)
 Fix build error caused by unused param.
  - Ignore auto generated files (flatbuf, protobuf)
 Fix different sign compare

Signed-off-by: gichan <gichan2.jang@samsung.com>
ext/nnstreamer/extra/meson.build
ext/nnstreamer/tensor_filter/tensor_filter_movidius_ncsdk2.c
ext/nnstreamer/tensor_filter/tensor_filter_trix_engine.cc
ext/nnstreamer/tensor_source/tensor_src_tizensensor.c
tests/bmp2png.c
tests/nnstreamer_filter_mvncsdk2/NCSDKTensorFilterTestHelper.cc
tests/nnstreamer_filter_mvncsdk2/NCSDKTensorFilterTestHelper.hh
tests/nnstreamer_filter_mvncsdk2/meson.build

index c7bd352..73a0331 100644 (file)
@@ -30,6 +30,7 @@ endif
 if grpc_support_is_available
   grpc_common_src = ['nnstreamer_grpc_common.cc']
   grpc_util_sources = []
+  ignore_unused_param_auto_generated_files = declare_dependency(compile_args: ['-Wno-unused-parameter'])
 
   foreach s : grpc_common_src
     grpc_util_sources += join_paths(meson.current_source_dir(), s)
@@ -37,7 +38,7 @@ if grpc_support_is_available
 
   grpc_util_dep = declare_dependency(
     sources: grpc_util_sources,
-    dependencies: [nnstreamer_dep, glib_dep, gst_dep, libdl_dep, grpc_support_deps],
+    dependencies: [nnstreamer_dep, glib_dep, gst_dep, libdl_dep, grpc_support_deps, ignore_unused_param_auto_generated_files],
     include_directories: include_directories('.')
   )
 
@@ -51,7 +52,7 @@ if grpc_support_is_available
     # Don't generate proto files twice
     nns_protobuf_grpc_lib = shared_library ('nnstreamer_grpc_protobuf',
       sources : [grpc_pb_gen_src, nns_protobuf_grpc_sources],
-      dependencies : [grpc_util_dep, nns_protobuf_dep],
+      dependencies : [grpc_util_dep, nns_protobuf_dep, ignore_unused_param_auto_generated_files],
       install: true,
       install_dir: nnstreamer_libdir
     )
@@ -68,7 +69,7 @@ if grpc_support_is_available
 
     nns_flatbuf_grpc_lib = shared_library ('nnstreamer_grpc_flatbuf',
       sources : [grpc_fb_gen_src, nns_flatbuf_grpc_sources],
-      dependencies : [grpc_util_dep, flatbuf_dep],
+      dependencies : [grpc_util_dep, flatbuf_dep, ignore_unused_param_auto_generated_files],
       install: true,
       install_dir: nnstreamer_libdir
     )
index c9586df..4a8ecef 100644 (file)
@@ -32,6 +32,7 @@
 #include <gst/gst.h>
 #include <mvnc2/mvnc.h>
 #include <nnstreamer_log.h>
+#include <nnstreamer_util.h>
 #define NO_ANONYMOUS_NESTED_STRUCT
 #include <nnstreamer_plugin_api_filter.h>
 #undef NO_ANONYMOUS_NESTED_STRUCT
@@ -84,6 +85,7 @@ static void
 _mvncsdk2_close (const GstTensorFilterProperties * prop, void **private_data)
 {
   mvncsdk2_data *pdata = *private_data;
+  UNUSED (prop);
 
   if (pdata != NULL) {
     ncGraphDestroy (&(pdata->handle_graph));
@@ -367,6 +369,7 @@ _mvncsdk2_getInputDim (const GstTensorFilterProperties * prop,
   mvncsdk2_data *pdata = *private_data;
   struct ncTensorDescriptor_t *nc_input_desc = &(pdata->tensor_desc_input);
   GstTensorInfo *nns_input_tensor_info;
+  UNUSED (prop);
 
   /** MVNCSDK only supports one tensor at a time */
   info->num_tensors = NNS_MVNCSDK2_MAX_NUM_TENOSORS_SUPPORTED;
@@ -400,6 +403,7 @@ _mvncsdk2_getOutputDim (const GstTensorFilterProperties * prop,
   mvncsdk2_data *pdata = *private_data;
   struct ncTensorDescriptor_t *nc_output_desc = &(pdata->tensor_desc_output);
   GstTensorInfo *nns_output_info;
+  UNUSED (prop);
 
   /** MVNCSDK only supports one tensor at a time */
   info->num_tensors = NNS_MVNCSDK2_MAX_NUM_TENOSORS_SUPPORTED;
index f1d867c..f35c001 100644 (file)
@@ -246,8 +246,8 @@ TensorFilterTRIxEngine::invoke (const GstTensorMemory *input, GstTensorMemory *o
     return;
   }
 
-  input_buffers input_buf = {0};
-  output_buffers output_buf = {0};
+  input_buffers input_buf;
+  output_buffers output_buf;
   /* feed input data to npu-engine */
   feed_input_data (input, &input_buf);
 
index 3a6a3c6..a133056 100644 (file)
@@ -83,6 +83,7 @@
 #include <tensor_typedef.h>
 #include <nnstreamer_plugin_api.h>
 #include <nnstreamer_log.h>
+#include <nnstreamer_util.h>
 
 #include "tensor_src_tizensensor.h"
 
@@ -469,15 +470,15 @@ gst_tensor_src_tizensensor_init (GstTensorSrcTIZENSENSOR * self)
   gst_base_src_set_dynamic_size (GST_BASE_SRC (self), FALSE);
 
   if (NULL == tizensensors) {
-    int i;
+    int i, sensor_dim;
     tizensensors = g_hash_table_new (g_direct_hash, g_direct_equal);
 
     for (i = 0; tizensensorspecs[i].type != SENSOR_LAST; i++) {
       g_assert (g_hash_table_insert (tizensensors,
               GINT_TO_POINTER (tizensensorspecs[i].type),
               &tizensensorspecs[i].tinfo));
-      g_assert (tizensensorspecs[i].value_count ==
-          tizensensorspecs[i].tinfo.dimension[0]);
+      sensor_dim = tizensensorspecs[i].tinfo.dimension[0];
+      g_assert (tizensensorspecs[i].value_count == sensor_dim);
     }
   }
 }
@@ -1065,6 +1066,7 @@ gst_tensor_src_tizensensor_fixate (GstBaseSrc * src, GstCaps * caps)
 static gboolean
 gst_tensor_src_tizensensor_is_seekable (GstBaseSrc * src)
 {
+  UNUSED (src);
   nns_logd ("tensor_src_tizensensor is not seekable");
   return FALSE;
 }
@@ -1130,7 +1132,7 @@ gst_tensor_src_tizensensor_create (GstBaseSrc * src, guint64 offset,
   GstMemory *mem;
   guint buffer_size;
   GstFlowReturn retval = GST_FLOW_OK;
-
+  UNUSED (size);
   _LOCK (self);
 
   if (!self->configured) {
@@ -1219,7 +1221,8 @@ gst_tensor_src_tizensensor_fill (GstBaseSrc * src, guint64 offset,
   GstFlowReturn retval = GST_FLOW_OK;
   GstMemory *mem;
   GstMapInfo map;
-
+  int src_dim;
+  UNUSED (offset);
   _LOCK (self);
 
   if (!self->configured) {
@@ -1262,10 +1265,11 @@ gst_tensor_src_tizensensor_fill (GstBaseSrc * src, guint64 offset,
     }
 
     event = &events[count - 1];
-    if (event->value_count != self->src_spec->dimension[0]) {
+    src_dim = self->src_spec->dimension[0];
+    if (event->value_count != src_dim) {
       GST_ERROR_OBJECT (self,
           "The number of values (%d) mismatches the metadata (%d)",
-          event->value_count, self->src_spec->dimension[0]);
+          event->value_count, src_dim);
       retval = GST_FLOW_ERROR;
       goto exit_unmap;
     }
index 50d559e..968e077 100644 (file)
@@ -101,14 +101,6 @@ save_png_to_file (bitmap_t * bitmap, const char *path)
   int depth = 8;
   int color_type;
 
-  if (bitmap->color_format == GRAY8) {
-    pixel_size = 1;
-    color_type = PNG_COLOR_TYPE_GRAY;
-  } else {
-    pixel_size = 3;
-    color_type = PNG_COLOR_TYPE_RGB;
-  }
-
   fp = fopen (path, "wb");
   if (!fp) {
     goto fopen_failed;
@@ -132,6 +124,13 @@ save_png_to_file (bitmap_t * bitmap, const char *path)
   }
 
   /** Set image attributes. */
+  if (bitmap->color_format == GRAY8) {
+    pixel_size = 1;
+    color_type = PNG_COLOR_TYPE_GRAY;
+  } else {
+    pixel_size = 3;
+    color_type = PNG_COLOR_TYPE_RGB;
+  }
 
   png_set_IHDR (png_ptr,
       info_ptr,
index 851b479..c3d4f3c 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include "NCSDKTensorFilterTestHelper.hh"
+#include <nnstreamer_util.h>
 
 /* Static member variables for instance management */
 std::unique_ptr<NCSDKTensorFilterTestHelper> NCSDKTensorFilterTestHelper::mInstance;
@@ -143,7 +144,7 @@ NCSDKTensorFilterTestHelper::setFailStage (const fail_stage_t stage)
 /**
  * @brief Get the stage where the NCSDK fails
  */
-const fail_stage_t
+fail_stage_t
 NCSDKTensorFilterTestHelper::getFailStage ()
 {
   return this->mFailStage;
@@ -307,6 +308,7 @@ ncStatus_t
 NCSDKTensorFilterTestHelper::ncGraphGetOption (struct ncGraphHandle_t *graphHandle,
     int option, void *data, unsigned int *dataLength)
 {
+  UNUSED (graphHandle);
   switch (option) {
   case NC_RO_GRAPH_INPUT_TENSOR_DESCRIPTORS:
     if (this->mFailStage == fail_stage_t::FAIL_GRAPH_GET_INPUT_TENSOR_DESC) {
@@ -343,6 +345,11 @@ NCSDKTensorFilterTestHelper::ncGraphQueueInference (struct ncGraphHandle_t *grap
     struct ncFifoHandle_t **fifoIn, unsigned int inFifoCount,
     struct ncFifoHandle_t **fifoOut, unsigned int outFifoCount)
 {
+  UNUSED (graphHandle);
+  UNUSED (fifoIn);
+  UNUSED (inFifoCount);
+  UNUSED (fifoOut);
+  UNUSED (outFifoCount);
   if (this->mFailStage == fail_stage_t::FAIL_GRAPH_Q_INFER) {
     return NC_ERROR;
   }
@@ -381,6 +388,8 @@ ncStatus_t
 NCSDKTensorFilterTestHelper::ncFifoCreate (
     const char *name, ncFifoType_t type, struct ncFifoHandle_t **fifoHandle)
 {
+  UNUSED (type);
+  UNUSED (fifoHandle);
   if ((this->mFailStage == fail_stage_t::FAIL_FIFO_CREATE_INPUT)
       && !g_strcmp0 (name, NNS_MVNCSDK2_NAME_INPUT_FIFO)) {
     return NC_ERROR;
@@ -400,6 +409,9 @@ NCSDKTensorFilterTestHelper::ncFifoAllocate (struct ncFifoHandle_t *fifoHandle,
     struct ncDeviceHandle_t *device, struct ncTensorDescriptor_t *tensorDesc,
     unsigned int numElem)
 {
+  UNUSED (fifoHandle);
+  UNUSED (device);
+  UNUSED (numElem);
   if ((this->mFailStage == fail_stage_t::FAIL_FIFO_ALLOC_INPUT)
       && (compareTensorDesc (*tensorDesc, *(this->mTensorDescInput)))) {
     return NC_ERROR;
@@ -418,6 +430,10 @@ ncStatus_t
 NCSDKTensorFilterTestHelper::ncFifoSetOption (struct ncFifoHandle_t *fifoHandle,
     int option, const void *data, unsigned int dataLength)
 {
+  UNUSED (fifoHandle);
+  UNUSED (option);
+  UNUSED (data);
+  UNUSED (dataLength);
   return NC_OK;
 }
 
@@ -428,6 +444,10 @@ ncStatus_t
 NCSDKTensorFilterTestHelper::ncFifoGetOption (struct ncFifoHandle_t *fifoHandle,
     int option, void *data, unsigned int *dataLength)
 {
+  UNUSED (fifoHandle);
+  UNUSED (option);
+  UNUSED (data);
+  UNUSED (dataLength);
   return NC_OK;
 }
 
@@ -437,6 +457,7 @@ NCSDKTensorFilterTestHelper::ncFifoGetOption (struct ncFifoHandle_t *fifoHandle,
 ncStatus_t
 NCSDKTensorFilterTestHelper::ncFifoDestroy (struct ncFifoHandle_t **fifoHandle)
 {
+  UNUSED (fifoHandle);
   return NC_OK;
 }
 
@@ -447,6 +468,10 @@ ncStatus_t
 NCSDKTensorFilterTestHelper::ncFifoWriteElem (struct ncFifoHandle_t *fifoHandle,
     const void *inputTensor, unsigned int *inputTensorLength, void *userParam)
 {
+  UNUSED (fifoHandle);
+  UNUSED (inputTensor);
+  UNUSED (inputTensorLength);
+  UNUSED (userParam);
   if (this->mFailStage == fail_stage_t::FAIL_FIFO_WRT_ELEM) {
     return NC_ERROR;
   }
@@ -461,6 +486,10 @@ ncStatus_t
 NCSDKTensorFilterTestHelper::ncFifoReadElem (struct ncFifoHandle_t *fifoHandle,
     void *outputData, unsigned int *outputDataLen, void **userParam)
 {
+  UNUSED (fifoHandle);
+  UNUSED (outputData);
+  UNUSED (outputDataLen);
+  UNUSED (userParam);
   if (this->mFailStage == fail_stage_t::FAIL_FIFO_RD_ELEM) {
     return NC_ERROR;
   }
@@ -474,6 +503,7 @@ NCSDKTensorFilterTestHelper::ncFifoReadElem (struct ncFifoHandle_t *fifoHandle,
 ncStatus_t
 NCSDKTensorFilterTestHelper::ncFifoRemoveElem (struct ncFifoHandle_t *fifoHandle)
 {
+  UNUSED (fifoHandle);
   if (this->mFailStage == fail_stage_t::FAIL_FIFO_RM_ELEM) {
     return NC_ERROR;
   }
index 67a90b1..84c0e52 100644 (file)
@@ -69,10 +69,15 @@ typedef enum _fail_stage_t {
 
 typedef uint32_t ncsdk_ver_t[NC_VERSION_MAX_SIZE];
 
+/**
+ * @brief A helper class for testing the NCSDK tensor filter.
+ */
 class NCSDKTensorFilterTestHelper
 {
 public:
-  /* Make this class as a singletone */
+  /**
+   * @brief Make this class as a singletone
+   */
   static NCSDKTensorFilterTestHelper &getInstance () {
     call_once (NCSDKTensorFilterTestHelper::mOnceFlag, []() {
       mInstance.reset(new NCSDKTensorFilterTestHelper);
@@ -84,7 +89,7 @@ public:
   void release ();
   /* Set/Get fail-stage */
   void setFailStage (const fail_stage_t stage);
-  const fail_stage_t getFailStage ();
+  fail_stage_t getFailStage ();
 
   /* Mock methods that simulate NCSDK2 APIs */
   /* Mock Global APIs */
index d60ccc5..b3b8054 100644 (file)
@@ -1,6 +1,6 @@
 unittest_mvncsdk_helper = shared_library('mvncsdk_test',
   ['NCSDKTensorFilterTestHelper.cc'],
-  dependencies : [glib_dep, gst_base_dep, gst_dep],
+  dependencies : [glib_dep, gst_base_dep, gst_dep, nnstreamer_unittest_deps],
   install: get_option('install-test'),
   install_dir: nnstreamer_libdir
 )