Fix build error due to toolchain upgrade (gcc6 -> gcc9) 99/220999/3 accepted/tizen/unified/20200109.065519 submit/tizen/20200107.042736 submit/tizen/20200108.064707
authorGilbok Lee <gilbok.lee@samsung.com>
Fri, 27 Dec 2019 05:26:38 +0000 (14:26 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Fri, 27 Dec 2019 05:32:09 +0000 (14:32 +0900)
: -Werror=format-truncation

[Version] 0.1.15 (same as version wriiten in spec file)
[Issue Type] ToolChain

Change-Id: Ia6fda9b4271cef000cfe1e338dd139e645ac19a0

packaging/capi-media-video-util.spec
test/video_util_test.c

index a3a6974..a28049e 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-video-util
 Summary:    A Video Utility library in Tizen Native API
-Version:    0.1.14
+Version:    0.1.15
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index 388a8b4..e62a0de 100644 (file)
@@ -45,7 +45,7 @@ enum {
 };
 
 static video_util_h video_h = NULL;
-char g_uri[MAX_STRING_LEN] = { 0, };
+gchar *g_out = NULL;
 
 int g_menu_state = CURRENT_STATUS_MAINMENU;
 int g_handle_num = 1;
@@ -59,7 +59,6 @@ int fps = 10;
 unsigned long start_position = 0;
 unsigned long duration = 5000;
 int make_video_cnt = 1;
-char g_out[MAX_STRING_LEN] = { 0, };
 
 typedef struct {
        video_util_h video_h;
@@ -72,10 +71,12 @@ test_util_s *_util_s;
 
 
 static void display_sub_basic();
-void _video_util_start_transcoding(test_util_s *util_s);
+static void _video_util_start_transcoding(test_util_s *util_s);
+static void _reset_var();
 
 void _quit_program(void)
 {
+       _reset_var();
        exit(0);
 }
 
@@ -179,10 +180,10 @@ void _transcode_progress_cb(unsigned long current_position, unsigned long durati
        return;
 }
 
-void _video_util_start_transcoding(test_util_s *util_s)
+static void _video_util_start_transcoding(test_util_s *util_s)
 {
        int ret = VIDEO_UTIL_ERROR_NONE;
-       char output_file_path[MAX_STRING_LEN] = { 0, };
+       gchar *output_file_path = NULL;
 
        if (!video_h) {
                LOGE("video_util handle is NULL, please set format after create");
@@ -230,29 +231,32 @@ void _video_util_start_transcoding(test_util_s *util_s)
                return;
        }
 
-       memset(output_file_path, 0x00, MAX_STRING_LEN);
-
-       snprintf(output_file_path, MAX_STRING_LEN, "%s_%d.%s", g_out, util_s->idx, format ? "mp4" : "3gp");
+       output_file_path = g_strdup_printf("%s_%d.%s", g_out, util_s->idx, format ? "mp4" : "3gp");
+       g_free(g_out);
+       g_out = NULL;
 
        LOGI("input start_time: %lu, duration: %lu, output_file_path: %s", util_s->start_time, util_s->duration, output_file_path);
        ret = video_util_start_transcoding(util_s->video_h, util_s->start_time, util_s->duration, output_file_path, _transcode_progress_cb, _transcode_completed_cb, util_s);
-
        if (ret != VIDEO_UTIL_ERROR_NONE) {
                LOGE("video_util_start_transcoding is failed (%d)", ret);
+               g_free(output_file_path);
                return;
        }
 
+       g_free(output_file_path);
        return;
 }
 
-void _reset_var()
+static void _reset_var()
 {
        if (video_h) {
                video_util_destroy(video_h);
                video_h = NULL;
        }
-       memset(g_uri, 0x00, MAX_STRING_LEN);
-       memset(g_out, 0x00, MAX_STRING_LEN);
+
+       g_free(g_out);
+       g_out = NULL;
+
        g_menu_state = CURRENT_STATUS_MAINMENU;
        g_handle_num = 1;
        format = VIDEO_UTIL_FILE_FORMAT_3GP;
@@ -271,6 +275,7 @@ static void input_filename(char *filename)
 {
        int len = strlen(filename);
        int ret = VIDEO_UTIL_ERROR_NONE;
+       gchar *g_uri = NULL;
 
        if (len < 0 || len > MAX_STRING_LEN - 1) {
                LOGE("Input file name is wrong");
@@ -293,16 +298,17 @@ static void input_filename(char *filename)
                return;
        }
 
-       strncpy(g_uri, filename, sizeof(g_uri) - 1);
-       g_uri[sizeof(g_uri) - 1] = '\0';
+       g_uri = g_strndup(filename, len);
 
        ret = video_util_set_file_path(video_h, g_uri);
-
        if (ret != VIDEO_UTIL_ERROR_NONE) {
                LOGE("video_util_set_file_path is failed");
+               g_free(g_uri);
                return;
        }
 
+       g_free(g_uri);
+
        _supported_spec_check(video_h);
 }
 
@@ -617,8 +623,8 @@ static void interpret(char *cmd)
        case CURRENT_STATUS_SET_OUTFILENAME:
                {
                        LOGI("output file is %s", g_out);
-                       snprintf(g_out, MAX_STRING_LEN, "/opt/usr/media/%s", cmd);
-                       g_out[MAX_STRING_LEN - 1] = '\0';
+                       g_free(g_out);
+                       g_out = g_strdup_printf("/opt/usr/media/%s", cmd);
                        LOGI("output file is %s", g_out);
                        reset_menu_state();
                        break;