fix build warnings 85/164085/2
authorYoungjae Shin <yj99.shin@samsung.com>
Fri, 15 Dec 2017 07:06:24 +0000 (16:06 +0900)
committerMyoungJune Park <mj2004.park@samsung.com>
Fri, 22 Dec 2017 02:52:55 +0000 (11:52 +0900)
Change-Id: I4d21a6a199ab073652e002f3f5be319b9ca30948
Signed-off-by: Youngjae Shin <yj99.shin@samsung.com>
Signed-off-by: MyoungJune Park <mj2004.park@samsung.com>
src/system_settings_multi_callback.c
src/system_settings_ringtones.c
src/system_settings_vconf.c

index 29c5651..a006a73 100644 (file)
@@ -38,9 +38,7 @@ GList* find_callback_node(callback_list *handle, system_settings_changed_cb ptr)
        if (!handle)
                return NULL;
 
-       GList * list = handle->list;
-
-       GList * itr = g_list_first(handle->list);
+       GList *itr = g_list_first(handle->list);
        while (itr != NULL) {
                callback_node* node = (callback_node*)itr->data;
                if (node->callback == ptr)
@@ -100,9 +98,7 @@ int invoke_callback_list(callback_list *handle, system_settings_key_e key)
        if (!handle)
                return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
 
-       GList * list = handle->list;
-
-       GList * itr = g_list_first(handle->list);
+       GList *itr = g_list_first(handle->list);
        while (itr != NULL) {
                callback_node* node = (callback_node*)itr->data;
                if (node->callback)
index d0c1a0f..5cd5bd4 100644 (file)
@@ -18,6 +18,7 @@
  * limitations under the License.
  *
  */
+#include <pthread.h>
 
 #include <system_settings.h>
 #include <system_settings_private.h>
@@ -77,7 +78,8 @@ int get_filelist_from_dir_path(char *path, Eina_List **file_list)
 {
        SETTING_TRACE_BEGIN;
        DIR *pDir = NULL;
-       struct dirent ent, *result;
+       struct dirent *ent;
+       static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 
        if (path == NULL) {
                SETTING_TRACE("dir path is null");
@@ -94,32 +96,29 @@ int get_filelist_from_dir_path(char *path, Eina_List **file_list)
        if (pDir == NULL)
                return -2;
 
-       while (readdir_r(pDir, &ent, &result) == 0) {
-               if (result == NULL)
-                       break;
-
+       pthread_mutex_lock(&mutex);
+       while ((ent = readdir(pDir)) != NULL) {
                fileNodeInfo *pNode = NULL;
 
-               if (strncmp(ent.d_name, ".", 1) == 0
-                               || strcmp(ent.d_name, "..") == 0)
+               if (strncmp(ent->d_name, ".", 1) == 0 || strcmp(ent->d_name, "..") == 0)
                        continue;
 
-               if ((ent.d_type & DT_REG) == 0)
+               if ((ent->d_type & DT_REG) == 0)
                        continue;
 
-               pNode = (fileNodeInfo *) malloc(sizeof(fileNodeInfo));
+               pNode = calloc(1, sizeof(fileNodeInfo));
                if (pNode == NULL)
                        continue;
 
-               memset(pNode, 0, sizeof(fileNodeInfo));
-
                pNode->path = strdup(path);
-               pNode->name = strdup(ent.d_name);
+               pNode->name = strdup(ent->d_name);
                pNode->media_name = get_media_basename(
                                pNode->path, pNode->name);
 
                *file_list = eina_list_append(*file_list, pNode);
        }
+       pthread_mutex_unlock(&mutex);
+
        closedir(pDir);
        //SETTING_TRACE_END;
 
index 85074a2..66b4c3f 100644 (file)
@@ -398,7 +398,7 @@ int system_setting_vconf_set_changed_multi_cb(const char *vconf_key, system_sett
                return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
 
        int ret = vconf_notify_key_changed(vconf_key, vconf_event_cb, (void *)key);
-       if (ret != NULL) {
+       if (ret != 0) {
                LOGE("[%s] INVALID_error , ret = %d, %s", __FUNCTION__, ret, "vconf_notify_key_changed error");
                return SYSTEM_SETTINGS_ERROR_IO_ERROR;
        }
@@ -418,7 +418,7 @@ int system_setting_vconf_unset_changed_multi_cb(const char *vconf_key, system_se
                return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
 
        int ret = vconf_ignore_key_changed(vconf_key, vconf_event_cb);
-       if (ret != NULL) {
+       if (ret != 0) {
                LOGE("[%s] INVALID_error , ret = %d, %s", __FUNCTION__, ret, "vconf_ignore_key_changed error");
                return SYSTEM_SETTINGS_ERROR_IO_ERROR;
        }