Recently ahub static checker reports typecast issue of integer variable.
Update param type and check null ptr to fix svace issue.
Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
decoder_sub_bounding_boxes_sources += files(
-'mobilenetssd.cc',
+ 'mobilenetssd.cc',
'mobilenetssdpp.cc',
'ovdetection.cc',
'yolo.cc',
{
guint i;
- guint size = sizeof (crop_region); /**Assuming crop_region is a structure with four integer fields */
- guint *out_data = (guint *)out_info->data;
+ gsize size = sizeof (crop_region); /**Assuming crop_region is a structure with four integer fields */
+ guint *out_data = (guint *) out_info->data;
crop_region region;
guint maxx = MIN (results->len, data->num);
for (i = 0; i < maxx; i++) {
typedef struct {
char **labels; /**< The list of loaded labels. Null if not loaded */
guint total_labels; /**< The number of loaded labels */
- guint max_word_length; /**< The max size of labels */
+ gsize max_word_length; /**< The max size of labels */
} imglabel_t;
extern void
lua_tensor *lt = *((lua_tensor **) luaL_checkudata (L, 1, "lua_tensor"));
int tidx = luaL_checkint (L, 2) - 1;
- uint element_size = gst_tensor_get_element_size (lt->type);
+ gsize element_size = gst_tensor_get_element_size (lt->type);
if (tidx < 0 || (size_t) tidx * element_size >= lt->size)
throw std::runtime_error ("Invalid index for tensor");
int tidx = luaL_checkint (L, 2) - 1;
double value = luaL_checknumber (L, 3);
- uint element_size = gst_tensor_get_element_size (lt->type);
+ gsize element_size = gst_tensor_get_element_size (lt->type);
if (tidx < 0 || (size_t) tidx * element_size >= lt->size)
throw std::runtime_error ("Invalid index for tensor");
}
/* set data size */
- blocksize = gst_tensor_info_get_size (self->src_spec);
+ blocksize = (guint) gst_tensor_info_get_size (self->src_spec);
gst_base_src_set_blocksize (src, blocksize);
self->running = TRUE;
g_assert (self->src_spec); /* It should be valid if configured */
/* We don't have multi-tensor (tensors with num-tensors > 1) */
- buffer_size = gst_tensor_info_get_size (self->src_spec);
+ buffer_size = (guint) gst_tensor_info_get_size (self->src_spec);
mem = gst_allocator_alloc (NULL, buffer_size, NULL);
if (mem == NULL) {
GST_ERROR_OBJECT (self,
GstMemory *mem;
GstMapInfo map;
int src_dim;
+ guint data_size;
UNUSED (offset);
_LOCK (self);
goto exit;
}
- if (size != gst_tensor_info_get_size (self->src_spec)) {
+ data_size = (guint) gst_tensor_info_get_size (self->src_spec);
+ if (size != data_size) {
GST_ERROR_OBJECT (self,
- "gst_tensor_src_tizensensor_fill() requires size value (%u) to be matched with the configurations of sensors (%lu)",
- size, (unsigned long) gst_tensor_info_get_size (self->src_spec));
+ "gst_tensor_src_tizensensor_fill() requires size value (%u) to be matched with the configurations of sensors (%u).",
+ size, data_size);
retval = GST_FLOW_ERROR;
goto exit;
}
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)",
+ "The number of values (%d) mismatches the metadata (%d).",
event->value_count, src_dim);
retval = GST_FLOW_ERROR;
goto exit_unmap;
GstCaps *fixed_caps; /**< to get meta info */
JsonObject *json_object; /**< JSON object */
- JsonArray *sample_offset_array; /**< offset array of sample */
- JsonArray *tensor_size_array; /**< size array of flexible tensor */
+ JsonArray *sample_offset_array; /**< offset array of sample */
+ JsonArray *tensor_size_array; /**< size array of flexible tensor */
JsonArray *tensor_count_array; /**< array for the number of cumulative tensors */
- guint cumulative_tensors; /**< the number of cumulated tensors */
+ guint cumulative_tensors; /**< the number of cumulated tensors */
gboolean is_static_tensors;
gint fd; /**< open file descriptor*/
GstDataRepoDataType data_type; /**< data type */
gint total_samples; /**< The number of total samples, in the case of multi-files, it is used as an index. */
guint64 fd_offset; /**< offset of fd */
- guint sample_size; /**< size of one sample */
+ gsize sample_size; /**< size of one sample */
/* property */
- gchar *filename; /**< filename */
+ gchar *filename; /**< filename */
gchar *json_filename; /**< "JSON file path to store the meta information */
};
/* https://gstreamer.freedesktop.org/documentation/additional/design/mediatype-video-raw.html?gi-language=c */
src->sample_size = (guint) GST_VIDEO_INFO_SIZE (&video_info);
- GST_DEBUG_OBJECT (src, "format(%s), width(%d), height(%d): %u byte/frame",
+ GST_DEBUG_OBJECT (src, "format(%s), width(%d), height(%d): %zd byte/frame",
gst_structure_get_string (s, "format"),
GST_VIDEO_INFO_WIDTH (&video_info),
GST_VIDEO_INFO_HEIGHT (&video_info), src->sample_size);
src->sample_size = channel * (depth / 8) * rate;
GST_DEBUG_OBJECT (src,
- "format(%s), depth(%d), rate(%d), channel(%d): %u bps",
+ "format(%s), depth(%d), rate(%d), channel(%d): %zd bps",
gst_structure_get_string (s, "format"), depth, rate, channel,
src->sample_size);
break;
src->tensors_offset[i] = src->sample_size;
_info = gst_tensors_info_get_nth_info (&src->config.info, i);
src->tensors_size[i] = gst_tensor_info_get_size (_info);
- GST_DEBUG_OBJECT (src, "offset[%u]: %u", i, src->tensors_offset[i]);
- GST_DEBUG_OBJECT (src, "size[%u]: %u", i, src->tensors_size[i]);
+ GST_DEBUG_OBJECT (src, "offset[%u]: %zd", i, src->tensors_offset[i]);
+ GST_DEBUG_OBJECT (src, "size[%u]: %zd", i, src->tensors_size[i]);
src->sample_size += src->tensors_size[i];
}
break;
GstFlowReturn ret = GST_FLOW_OK;
guint i = 0, seq_idx = 0;
GstBuffer *buf;
- guint to_read, byte_read;
- int read_size;
+ gsize to_read, byte_read;
+ gssize read_size;
guint8 *data;
GstMemory *mem = NULL;
GstMapInfo info;
}
GST_INFO_OBJECT (src, "sequence index: %d", seq_idx);
- GST_INFO_OBJECT (src, "tensor_size[%d]: %d", seq_idx,
+ GST_INFO_OBJECT (src, "tensor_size[%d]: %zd", seq_idx,
src->tensors_size[seq_idx]);
- GST_INFO_OBJECT (src, "tensors_offset[%d]: %d", seq_idx,
+ GST_INFO_OBJECT (src, "tensors_offset[%d]: %zd", seq_idx,
src->tensors_offset[seq_idx]);
/** offset and sample_offset(byte size) are from 0.
while (to_read > 0) {
GST_LOG_OBJECT (src,
- "Reading %d bytes at offset 0x%" G_GINT64_MODIFIER "x (%d size)",
+ "Reading %zd bytes at offset 0x%" G_GINT64_MODIFIER "x (%zd size)",
to_read, src->fd_offset + byte_read,
(guint) src->fd_offset + byte_read);
errno = 0;
read_size = read (src->fd, data + byte_read, to_read);
- GST_LOG_OBJECT (src, "Read: %d", read_size);
+ GST_LOG_OBJECT (src, "Read: %zd", read_size);
if (read_size < 0) {
if (errno == EAGAIN || errno == EINTR)
continue;
GstMapInfo info;
GstTensorMetaInfo meta;
GstTensorInfo tinfo;
- guint to_read, byte_read;
- int read_size;
+ gsize to_read, byte_read;
+ gssize read_size;
guint8 *data;
guint tensor_count;
guint tensor_size;
to_read = tensor_size;
while (to_read > 0) {
GST_LOG_OBJECT (src,
- "Reading %d bytes at offset 0x%" G_GINT64_MODIFIER "x (%lld size)",
+ "Reading %zd bytes at offset 0x%" G_GINT64_MODIFIER "x (%lld size)",
to_read, src->fd_offset + byte_read, (long long) src->fd_offset);
errno = 0;
read_size = read (src->fd, data + byte_read, to_read);
- GST_LOG_OBJECT (src, "Read: %d", read_size);
+ GST_LOG_OBJECT (src, "Read: %zd", read_size);
if (read_size < 0) {
if (errno == EAGAIN || errno == EINTR)
continue;
{
GstFlowReturn ret = GST_FLOW_OK;
GstBuffer *buf;
- guint to_read, byte_read;
- int read_size;
+ gsize to_read, byte_read;
+ gssize read_size;
guint8 *data;
GstMemory *mem;
GstMapInfo info;
byte_read = 0;
to_read = src->sample_size;
while (to_read > 0) {
- GST_LOG_OBJECT (src, "Reading %d bytes at offset 0x%" G_GINT64_MODIFIER "x",
+ GST_LOG_OBJECT (src, "Reading %zd bytes at offset 0x%" G_GINT64_MODIFIER "x",
to_read, src->fd_offset + byte_read);
errno = 0;
read_size = read (src->fd, data + byte_read, to_read);
- GST_LOG_OBJECT (src, "Read: %d", read_size);
+ GST_LOG_OBJECT (src, "Read: %zd", read_size);
if (read_size < 0) {
if (errno == EAGAIN || errno == EINTR)
continue;
goto error;
}
src->sample_size = json_object_get_int_member (object, "sample_size");
- GST_INFO_OBJECT (src, "sample_size: %d", src->sample_size);
+ GST_INFO_OBJECT (src, "sample_size: %zd", src->sample_size);
}
if (src->data_type == GST_DATA_REPO_DATA_TENSOR &&
guint64 fd_offset; /**< offset of fd */
guint64 start_offset; /**< start offset to read */
guint64 last_offset; /**< last offset to read */
- guint tensors_size[NNS_TENSOR_SIZE_LIMIT]; /**< each tensors size in a sample */
- guint tensors_offset[NNS_TENSOR_SIZE_LIMIT]; /**< each tensors offset in a sample */
+ gsize tensors_size[NNS_TENSOR_SIZE_LIMIT]; /**< each tensors size in a sample */
+ gsize tensors_offset[NNS_TENSOR_SIZE_LIMIT]; /**< each tensors offset in a sample */
gint current_sample_index; /**< current index of sample or file to read */
gboolean first_epoch_is_done;
guint total_samples; /**< The number of total samples */
guint num_samples; /**< The number of samples to be used out of the total samples in the file */
- guint sample_size; /**< size of one sample */
+ gsize sample_size; /**< size of one sample */
GstDataRepoDataType data_type; /**< media type */
/* property */
memset (cinfo, 0, sizeof (tensor_crop_info_s));
- cinfo->num = dsize / (esize * 4);
- cinfo->num = MIN (cinfo->num, NNS_TENSOR_SIZE_LIMIT);
+ cinfo->num = MIN (dsize / (esize * 4), NNS_TENSOR_SIZE_LIMIT);
for (i = 0; i < cinfo->num; i++) {
pos = map.data + hsize + (esize * 4 * i);
static gchar *
gst_tensor_src_iio_get_generic_name (const gchar * channel_name)
{
- guint digit_len = 1;
+ gsize digit_len = 1;
gchar *generic_name;
- guint channel_name_len = strlen (channel_name);
+ gsize channel_name_len = strlen (channel_name);
while (g_ascii_isdigit (channel_name[channel_name_len - digit_len])) {
digit_len++;
values[1]);
filter->data_arithmetic.per_channel_arith = TRUE;
filter->data_arithmetic.ch_dim =
- g_ascii_strtoull (values[1], NULL, 10);
+ (guint) g_ascii_strtoull (values[1], NULL, 10);
}
g_strfreev (values);
gchar **strv = g_strsplit (options[i], ":", 2);
if (g_ascii_strcasecmp (strv[0], "left") == 0) {
filter->data_padding.pad[PADDING_LEFT] =
- g_ascii_strtoull (strv[1], NULL, 10);
+ (guint) g_ascii_strtoull (strv[1], NULL, 10);
} else if (g_ascii_strcasecmp (strv[0], "right") == 0) {
- filter->data_padding.pad[PADDING_RIGHT]
- = g_ascii_strtoull (strv[1], NULL, 10);
+ filter->data_padding.pad[PADDING_RIGHT] =
+ (guint) g_ascii_strtoull (strv[1], NULL, 10);
} else if (g_ascii_strcasecmp (strv[0], "top") == 0) {
filter->data_padding.pad[PADDING_TOP] =
- g_ascii_strtoull (strv[1], NULL, 10);
+ (guint) g_ascii_strtoull (strv[1], NULL, 10);
} else if (g_ascii_strcasecmp (strv[0], "bottom") == 0) {
- filter->data_padding.pad[PADDING_BOTTOM]
- = g_ascii_strtoull (strv[1], NULL, 10);
+ filter->data_padding.pad[PADDING_BOTTOM] =
+ (guint) g_ascii_strtoull (strv[1], NULL, 10);
} else if (g_ascii_strcasecmp (strv[0], "front") == 0) {
- filter->data_padding.pad[PADDING_FRONT]
- = g_ascii_strtoull (strv[1], NULL, 10);
+ filter->data_padding.pad[PADDING_FRONT] =
+ (guint) g_ascii_strtoull (strv[1], NULL, 10);
} else if (g_ascii_strcasecmp (strv[0], "back") == 0) {
filter->data_padding.pad[PADDING_BACK] =
- g_ascii_strtoull (strv[1], NULL, 10);
+ (guint) g_ascii_strtoull (strv[1], NULL, 10);
} else if (g_ascii_strcasecmp (strv[0], "layout") == 0) {
if (g_ascii_strcasecmp (strv[1], "NHWC") == 0)
filter->data_padding.layout = _NNS_LAYOUT_NHWC;
gst_tensor_buffer_append_memory (GstBuffer * buffer, GstMemory * memory,
const GstTensorInfo * info)
{
- guint num_mems, offset, new_mem_index;
+ guint num_mems, new_mem_index;
GstMemory *new_memory = NULL, *last_memory = NULL;
- gsize new_mem_size, last_mem_size;
+ gsize offset, new_mem_size, last_mem_size;
GstMapInfo new_memory_map, last_memory_map, incoming_memory_map;
GstTensorExtraInfo *extra_info;
GstTensorMetaInfo meta;
bitmap_t bmp;
int x, y;
uint16_t width, height, *ptr16;
- size_t size;
+ size_t size, strn;
char byte;
char header[26]; /** gen24bBMP.py gives you 24B headered bmp file */
int ret;
char *pngfilename;
- unsigned int strn;
/** Read the .bmp file (argv[1]) */
if (argc < 2 || argc > 3) {
void SetUp () override
{
host.h_name = g_strdup ("github.com");
- host.h_aliases = (char **) calloc (1, sizeof (char *));
+ host.h_aliases = g_new0 (gchar *, 1);
host.h_aliases[0] = g_strdup ("www.github.com");
host.h_addrtype = AF_INET;
host.h_length = 4;
- host.h_addr_list = (char **) calloc (1, sizeof (char *));
+ host.h_addr_list = g_new0 (gchar *, 1);
host.h_addr_list[0] = g_strdup ("52.78.231.108");
}
/**
GstMemory *in_mem, *out_mem;
GstBuffer *out_buf = NULL;
GstMapInfo in_info;
- guint mem_size;
+ gsize mem_size;
gpointer mem_data;
guint *received = (guint *) data;
GstTensorInfo *_info;
g_test_data.tensors_config.info.num_tensors = mem_blocks;
for (i = 0; i < mem_blocks; i++) {
GstMemory *mem = gst_buffer_peek_memory (buffer, i);
- guint mem_size = gst_memory_get_sizes (mem, NULL, NULL);
+ guint mem_size = (guint) gst_memory_get_sizes (mem, NULL, NULL);
g_test_data.tensors_config.info.info[i].type = _NNS_UINT8;
g_test_data.tensors_config.info.info[i].dimension[0] = mem_size;
gint32 *sdata32;
guint64 *udata64;
gint64 *sdata64;
- gint data_size;
+ gsize data_size;
gchar *scan_el_data;
gint location = 0;
gint enabled = 0;