Code clean, fix svace issues.
- check null string when getting caps from edge handle
- fix mem leak case
- fix invalid data comparison
Signed-off-by: Jaeyun <jy1210.jung@samsung.com>
switch (tensor_merge->mode) {
case GTT_LINEAR:
{
- tensor_merge->data_linear.direction =
+ gint idx;
+
+ idx =
find_key_strv (gst_tensor_merge_linear_string, tensor_merge->option);
- if (tensor_merge->data_linear.direction < 0)
+ if (idx < 0)
return FALSE;
+
+ tensor_merge->data_linear.direction = (tensor_merge_linear_mode) idx;
tensor_merge->loaded = TRUE;
}
break;
g_free (self->in_caps_str);
self->in_caps_str = gst_caps_to_string (caps);
nns_edge_get_info (self->edge_h, "CAPS", &prev_caps_str);
+ if (!prev_caps_str)
+ prev_caps_str = g_strdup ("");
new_caps_str = g_strconcat (prev_caps_str, self->in_caps_str, NULL);
nns_edge_set_info (self->edge_h, "CAPS", new_caps_str);
g_free (prev_caps_str);
data_h = g_async_queue_try_pop (self->msg_queue);
if (data_h) {
- out_buf = gst_buffer_new ();
- if (NNS_EDGE_ERROR_NONE != nns_edge_data_get_count (data_h, &num_data)) {
+ ret = nns_edge_data_get_count (data_h, &num_data);
+ if (ret != NNS_EDGE_ERROR_NONE || num_data == 0) {
nns_loge ("Failed to get the number of memories of the edge data.");
res = GST_FLOW_ERROR;
goto done;
}
+
+ out_buf = gst_buffer_new ();
for (i = 0; i < num_data; i++) {
void *data = NULL;
size_t data_len;
gst_tensor_query_server_add_data (char *id)
{
GstTensorQueryServer *data = NULL;
+ int ret;
data = gst_tensor_query_server_get_handle (id);
data->id = id;
data->configured = FALSE;
- if (0 != nns_edge_create_handle (id, "TEMP_SERVER_TOPIC", &data->edge_h)) {
+ ret = nns_edge_create_handle (id, "TEMP_SERVER_TOPIC", &data->edge_h);
+ if (ret != NNS_EDGE_ERROR_NONE) {
GST_ERROR ("Failed to get nnstreamer edge handle.");
gst_tensor_query_server_remove_data (data);
return NULL;
#include <string.h>
#include "tensor_query_serversink.h"
-#include "nnstreamer_util.h"
GST_DEBUG_CATEGORY_STATIC (gst_tensor_query_serversink_debug);
#define GST_CAT_DEFAULT gst_tensor_query_serversink_debug
caps_str = gst_caps_to_string (caps);
nns_edge_get_info (sink->edge_h, "CAPS", &prev_caps_str);
+ if (!prev_caps_str)
+ prev_caps_str = g_strdup ("");
new_caps_str = g_strdup_printf ("%s@query_server_sink_caps@%s",
prev_caps_str, caps_str);
nns_edge_set_info (sink->edge_h, "CAPS", new_caps_str);
{
GstTensorQueryServerSink *sink = GST_TENSOR_QUERY_SERVERSINK (bsink);
GstMetaQuery *meta_query;
- nns_edge_data_h data_h = NULL;
+ nns_edge_data_h data_h;
guint i, num_mems = 0;
gint ret;
GstMemory *mem[NNS_TENSOR_SIZE_LIMIT];
if (!gst_memory_map (mem[i], &map[i], GST_MAP_READ)) {
ml_loge ("Cannot map the %uth memory in gst-buffer.", i);
num_mems = i;
+ nns_edge_data_destroy (data_h);
goto done;
}
nns_edge_data_add (data_h, map[i].data, map[i].size, NULL);
nns_edge_respond (sink->edge_h, data_h);
nns_edge_data_destroy (data_h);
- data_h = NULL;
} else {
nns_logw ("Cannot get tensor query meta. Drop buffers!\n");
sink->metaless_frame_count++;
GstBuffer *buffer = NULL;
guint i, num_data;
GstMetaQuery *meta_query;
+ int ret;
data_h = g_async_queue_pop (src->msg_queue);
nns_loge ("Failed to get message from the server message queue");
return NULL;
}
- buffer = gst_buffer_new ();
- if (NNS_EDGE_ERROR_NONE != nns_edge_data_get_count (data_h, &num_data)) {
+ ret = nns_edge_data_get_count (data_h, &num_data);
+ if (ret != NNS_EDGE_ERROR_NONE || num_data == 0) {
nns_loge ("Failed to get the number of memories of the edge data.");
- gst_buffer_unref (buffer);
- return NULL;
+ goto done;
}
+
+ buffer = gst_buffer_new ();
for (i = 0; i < num_data; i++) {
void *data = NULL;
size_t data_len = 0;
g_free));
}
- if (buffer) {
- meta_query = gst_buffer_add_meta_query (buffer);
- if (meta_query) {
- char *val;
- int ret;
-
- ret = nns_edge_data_get_info (data_h, "client_id", &val);
- if (NNS_EDGE_ERROR_NONE != ret) {
- gst_buffer_unref (buffer);
- buffer = NULL;
- } else {
- meta_query->client_id = g_ascii_strtoll (val, NULL, 10);
- g_free (val);
- }
+ meta_query = gst_buffer_add_meta_query (buffer);
+ if (meta_query) {
+ char *val;
+
+ ret = nns_edge_data_get_info (data_h, "client_id", &val);
+ if (NNS_EDGE_ERROR_NONE != ret) {
+ gst_buffer_unref (buffer);
+ buffer = NULL;
+ } else {
+ meta_query->client_id = g_ascii_strtoll (val, NULL, 10);
+ g_free (val);
}
}
- nns_edge_data_destroy (data_h);
+done:
+ nns_edge_data_destroy (data_h);
return buffer;
}
caps_str = gst_caps_to_string (caps);
nns_edge_get_info (src->edge_h, "CAPS", &prev_caps_str);
+ if (!prev_caps_str)
+ prev_caps_str = g_strdup ("");
new_caps_str = g_strdup_printf ("%s@query_server_src_caps@%s",
prev_caps_str, caps_str);
nns_edge_set_info (src->edge_h, "CAPS", new_caps_str);
}
*outbuf = _gst_tensor_query_serversrc_get_buffer (src);
- if (!outbuf) {
+ if (*outbuf == NULL) {
nns_loge ("Failed to get buffer to push to the tensor query serversrc.");
return GST_FLOW_ERROR;
}