Fix Svace issues 57/74457/1 accepted/tizen/mobile/20160615.002018 submit/tizen_mobile/20160614.090437
authorgs86.lee <gs86.lee@samsung.com>
Tue, 14 Jun 2016 08:58:34 +0000 (17:58 +0900)
committergs86.lee <gs86.lee@samsung.com>
Tue, 14 Jun 2016 08:58:34 +0000 (17:58 +0900)
Change-Id: I171ac95f46649f23ee7a4095d13b298148a305ac

sample/sticker_icon.c
src/group_icon_info.c
src/icon_info.c

index 7e7f167..78e1990 100644 (file)
@@ -89,6 +89,7 @@ static icon_info_s *_icon_info_create_directory(const char *dir_path)
 {
        icon_info_s *icon_info = NULL;
        DIR *dir_info = NULL;
+       struct dirent ent_struct;
        struct dirent *dir_entry = NULL;
        int ret = 0;
 
@@ -104,12 +105,13 @@ static icon_info_s *_icon_info_create_directory(const char *dir_path)
        dir_info = opendir(dir_path);
        goto_if(!dir_info, error);
 
-       while ((dir_entry = readdir(dir_info))) {
+       while (!readdir_r(dir_info, &ent_struct, &dir_entry) && dir_entry) {
                icon_image_s *icon_image = NULL;
                char *d_name = NULL;
                char *filename = NULL;
                char *ext = NULL;
                char *tmp = NULL;
+               char *save_ptr = NULL;
                char full_path[PATH_LEN] = {0, };
                char thumbnail_file[PATH_LEN] = {0, };
                struct stat stat_buf = {0, };
@@ -133,13 +135,13 @@ static icon_info_s *_icon_info_create_directory(const char *dir_path)
                icon_image->file = strdup(full_path);
                goto_if(!icon_image->file, not_sticker);
 
-               filename = strtok(d_name, ".");
+               filename = strtok_r(d_name, ".", &save_ptr);
                goto_if(!filename, not_sticker);
 
-               ext = strtok(NULL, ".");
+               ext = strtok_r(NULL, ".", &save_ptr);
                goto_if(!ext, not_sticker);
 
-               tmp = strtok(filename, "_");
+               tmp = strtok_r(filename, "_", &save_ptr);
                goto_if(!tmp, not_sticker);
 
                if (!icon_info->keyword) {
@@ -147,7 +149,7 @@ static icon_info_s *_icon_info_create_directory(const char *dir_path)
                        goto_if(!icon_info->keyword, not_sticker);
                }
 
-               if ((tmp = strtok(NULL, "_"))) {
+               if ((tmp = strtok_r(NULL, "_", &save_ptr))) {
                        if (!strcmp(tmp, STICKER_IMG_NAME_TOKEN_SUB)) {
                                goto not_sticker;
                        } else if (!strcmp(tmp, STICKER_IMG_NAME_TOKEN_TH)) {
@@ -168,27 +170,27 @@ static icon_info_s *_icon_info_create_directory(const char *dir_path)
                        }
                } else goto next;
 
-               if ((tmp = strtok(NULL, "_")))
+               if ((tmp = strtok_r(NULL, "_", &save_ptr)))
                        icon_image->diff_time = atoi(tmp);
                else
                        goto next;
 
-               if ((tmp = strtok(NULL, "_")))
+               if ((tmp = strtok_r(NULL, "_", &save_ptr)))
                        icon_info->repeat = atoi(tmp);
                else
                        goto next;
 
-               if ((tmp = strtok(NULL, "_")))
+               if ((tmp = strtok_r(NULL, "_", &save_ptr)))
                        icon_info->interval = atoi(tmp);
                else
                        goto next;
 
-               if ((tmp = strtok(NULL, "_")))
+               if ((tmp = strtok_r(NULL, "_", &save_ptr)))
                        icon_info->play_type = atoi(tmp);
                else
                        goto next;
 
-               if ((tmp = strtok(NULL, "_")))
+               if ((tmp = strtok_r(NULL, "_", &save_ptr)))
                        icon_info->th_frame = atoi(tmp);
 
 next:
index c2416e7..6a40e75 100644 (file)
@@ -124,6 +124,7 @@ static char *__strdup_tab_thumbnail_path(const char *dir_path)
        char file_path[PATH_LEN] = {0, };
        char *tab_thumbnail = NULL;
        DIR *dir_info = NULL;
+       struct dirent ent_struct;
        struct dirent *dir_entry = NULL;
        struct stat stat_buf = {0, };
        int ret = 0;
@@ -133,7 +134,7 @@ static char *__strdup_tab_thumbnail_path(const char *dir_path)
        dir_info = opendir(dir_path);
        retv_if(!dir_info, NULL);
 
-       while ((dir_entry = readdir(dir_info))) {
+       while (!readdir_r(dir_info, &ent_struct, &dir_entry) && dir_entry) {
                if (!strcmp(".", dir_entry->d_name) || !strcmp("..", dir_entry->d_name))
                        continue;
 
@@ -164,6 +165,7 @@ static char *__strdup_tab_thumbnail_path(const char *dir_path)
 static Eina_List *__append_preset_group_icon_info_list(Eina_List *group_icon_info_list, const char *preset_dir_path, sqlite3 *db)
 {
        DIR *dir_info = NULL;
+       struct dirent ent_struct;
        struct dirent *dir_entry = NULL;
        struct stat stat_buf;
        int max = 0;
@@ -177,7 +179,7 @@ static Eina_List *__append_preset_group_icon_info_list(Eina_List *group_icon_inf
        retv_if(!dir_info, group_icon_info_list);
 
        max = eina_list_count(group_icon_info_list);
-       while ((dir_entry = readdir(dir_info))) {
+       while (!readdir_r(dir_info, &ent_struct, &dir_entry) && dir_entry) {
                group_icon_info_s *group_icon_info = NULL;
                char dir_path[PATH_LEN] = {0, };
                char icon_path[PATH_LEN] = {0, };
index 010dee4..3f4c2ee 100644 (file)
@@ -53,6 +53,7 @@ static icon_info_s *__icon_info_parse_directory(const char *dir_path)
 {
        icon_info_s *icon_info = NULL;
        DIR *dir_info = NULL;
+       struct dirent ent_struct;
        struct dirent *dir_entry = NULL;
        int ret = 0;
 
@@ -68,12 +69,13 @@ static icon_info_s *__icon_info_parse_directory(const char *dir_path)
        dir_info = opendir(dir_path);
        goto_if(!dir_info, error);
 
-       while ((dir_entry = readdir(dir_info))) {
+       while (!readdir_r(dir_info, &ent_struct, &dir_entry) && dir_entry) {
                icon_info_image_s *icon_info_image = NULL;
                char *d_name = NULL;
                char *filename = NULL;
                char *ext = NULL;
                char *tmp = NULL;
+               char *save_ptr = NULL;
                char full_path[PATH_LEN] = {0, };
                char thumbnail_file[PATH_LEN] = {0, };
                struct stat stat_buf = {0, };
@@ -92,13 +94,13 @@ static icon_info_s *__icon_info_parse_directory(const char *dir_path)
                icon_info_image->file = strdup(full_path);
                goto_if(!icon_info_image->file, not_sticker);
 
-               filename = strtok(d_name, ".");
+               filename = strtok_r(d_name, ".", &save_ptr);
                goto_if(!filename, not_sticker);
 
-               ext = strtok(NULL, ".");
+               ext = strtok_r(NULL, ".", &save_ptr);
                goto_if(!ext, not_sticker);
 
-               tmp = strtok(filename, "_");
+               tmp = strtok_r(filename, "_", &save_ptr);
                goto_if(!tmp, not_sticker);
 
                if (!icon_info->keyword) {
@@ -106,7 +108,7 @@ static icon_info_s *__icon_info_parse_directory(const char *dir_path)
                        goto_if(!icon_info->keyword, not_sticker);
                }
 
-               if ((tmp = strtok(NULL, "_"))) {
+               if ((tmp = strtok_r(NULL, "_", &save_ptr))) {
                        if (!strcmp(tmp, STICKER_IMG_NAME_TOKEN_SUB)) {
                                goto not_sticker;
                        } else if (!strcmp(tmp, STICKER_IMG_NAME_TOKEN_TH)) {
@@ -128,23 +130,23 @@ static icon_info_s *__icon_info_parse_directory(const char *dir_path)
                        }
                } else goto next;
 
-               if ((tmp = strtok(NULL, "_")))
+               if ((tmp = strtok_r(NULL, "_", &save_ptr)))
                        icon_info_image->diff_time = atoi(tmp);
                else goto next;
 
-               if ((tmp = strtok(NULL, "_")))
+               if ((tmp = strtok_r(NULL, "_", &save_ptr)))
                        icon_info->repeat = atoi(tmp);
                else goto next;
 
-               if ((tmp = strtok(NULL, "_")))
+               if ((tmp = strtok_r(NULL, "_", &save_ptr)))
                        icon_info->interval = atoi(tmp);
                else goto next;
 
-               if ((tmp = strtok(NULL, "_")))
+               if ((tmp = strtok_r(NULL, "_", &save_ptr)))
                        icon_info->play_type = atoi(tmp);
                else goto next;
 
-               if ((tmp = strtok(NULL, "_")))
+               if ((tmp = strtok_r(NULL, "_", &save_ptr)))
                        icon_info->th_frame = atoi(tmp);
 
 next:
@@ -314,6 +316,7 @@ Eina_List *_icon_info_list_create_preset_package(const char *dir_path)
 {
        Eina_List *icon_info_list = NULL;
        DIR *dir_info = NULL;
+       struct dirent ent_struct;
        struct dirent *dir_entry = NULL;
        struct stat stat_buf;
        int ret = 0;
@@ -323,7 +326,7 @@ Eina_List *_icon_info_list_create_preset_package(const char *dir_path)
        dir_info = opendir(dir_path);
        retv_if(!dir_info, NULL);
 
-       while ((dir_entry = readdir(dir_info))) {
+       while (!readdir_r(dir_info, &ent_struct, &dir_entry) && dir_entry) {
                char icon_path[PATH_LEN] = {0, };
                snprintf(icon_path, sizeof(icon_path), "%s/%s", dir_path, dir_entry->d_name);