readdir_r() -> readdir() 62/148562/1 accepted/tizen/unified/20170912.191506 submit/tizen/20170908.045327
authorYounho Park <younho.park@samsung.com>
Fri, 8 Sep 2017 06:33:13 +0000 (15:33 +0900)
committerYounho Park <younho.park@samsung.com>
Fri, 8 Sep 2017 06:33:13 +0000 (15:33 +0900)
Change-Id: If6c517c926f2efdca7f35710d7d85148f32d5a66
Signed-off-by: Younho Park <younho.park@samsung.com>
adaptor/auth-adaptor/auth-adaptor.c
adaptor/contact-adaptor/contact-adaptor.c
adaptor/message-adaptor/message-adaptor.c
adaptor/push-adaptor/push-adaptor.c
adaptor/shop-adaptor/shop-adaptor.c
adaptor/storage-adaptor/storage-adaptor.c
server/src/util/service_file_manager.c

index fa8b783cf05400c203415d8f11d267fd66a9fdcb..b7238c93f42e4a92f3a72bd6ac1a2d949cdb46bc 100644 (file)
@@ -554,7 +554,7 @@ static int auth_adaptor_load_plugins_from_directory(auth_adaptor_h adaptor,
 {
        char *plugin_path = NULL;
        DIR *dir = NULL;
-       struct dirent dir_entry, *result = NULL;
+       struct dirent *dir_entry = NULL;
 
        auth_adaptor_debug("Starting load plugins from directory");
 
@@ -570,18 +570,12 @@ static int auth_adaptor_load_plugins_from_directory(auth_adaptor_h adaptor,
        }
 
        int ret = AUTH_ADAPTOR_ERROR_NONE;
-       while (0 == (readdir_r(dir, &dir_entry, &result))) {
-
-               if (NULL == result) {
-                       auth_adaptor_error("Could not open directory %s", plugin_path);
-                       break;
-               }
-
-               if (dir_entry.d_type & DT_DIR) {
+       while (NULL != (dir_entry = readdir(dir))) {
+               if (dir_entry->d_type & DT_DIR) {
                        continue;
                }
 
-               plugin_path = g_strconcat(dir_path, "/", dir_entry.d_name, NULL);
+               plugin_path = g_strconcat(dir_path, "/", dir_entry->d_name, NULL);
                auth_adaptor_plugin_h plugin = auth_adaptor_create_plugin(plugin_path);
 
                if (NULL != plugin) {
index 7b3315a8b72cd66de74c35bc16cc9632f8f49c1a..2535377923c51957061484d1fdb5027d4427a236 100644 (file)
@@ -222,7 +222,7 @@ static int contact_adaptor_load_plugins_from_directory(contact_adaptor_h adaptor
 
        char *plugin_path = NULL;
        DIR *dir = NULL;
-       struct dirent dir_entry, *result = NULL;
+       struct dirent *dir_entry = NULL;
 
        if ((NULL == adaptor) || (NULL == dir_path)) {
                contact_adaptor_error("Invalid argument");
@@ -236,18 +236,13 @@ static int contact_adaptor_load_plugins_from_directory(contact_adaptor_h adaptor
        }
 
        int ret = CONTACT_ADAPTOR_ERROR_NONE;
-       while (0 == (readdir_r(dir, &dir_entry, &result))) {
+       while (NULL != (dir_entry = readdir(dir))) {
 
-               if (NULL == result) {
-                       contact_adaptor_error("Could not open directory %s", plugin_path);
-                       break;
-               }
-
-               if (dir_entry.d_type & DT_DIR) {
+               if (dir_entry->d_type & DT_DIR) {
                        continue;
                }
 
-               plugin_path = g_strconcat(dir_path, "/", dir_entry.d_name, NULL);
+               plugin_path = g_strconcat(dir_path, "/", dir_entry->d_name, NULL);
                contact_adaptor_plugin_h plugin = contact_adaptor_create_plugin(plugin_path);
 
                if (NULL != plugin) {
index fd7d2c31af5ee3bb2af25bfb4d9d2e1958283fb7..ffc97d696b7d90d705d347d8c13a06cec78aba9c 100644 (file)
@@ -727,7 +727,7 @@ static int message_adaptor_load_plugins_from_directory(message_adaptor_h adaptor
 {
        char *plugin_path = NULL;
        DIR *dir = NULL;
-       struct dirent dir_entry, *result = NULL;
+       struct dirent *dir_entry = NULL;
 
        message_adaptor_debug("Starting load plugins from directory");
 
@@ -743,18 +743,13 @@ static int message_adaptor_load_plugins_from_directory(message_adaptor_h adaptor
        }
 
        int ret = MESSAGE_ADAPTOR_ERROR_NONE;
-       while (0 == (readdir_r(dir, &dir_entry, &result))) {
+       while (NULL != (dir_entry = readdir(dir))) {
 
-               if (NULL == result) {
-                       message_adaptor_error("Could not open directory %s", plugin_path);
-                       break;
-               }
-
-               if (dir_entry.d_type & DT_DIR) {
+               if (dir_entry->d_type & DT_DIR) {
                        continue;
                }
 
-               plugin_path = g_strconcat(dir_path, "/", dir_entry.d_name, NULL);
+               plugin_path = g_strconcat(dir_path, "/", dir_entry->d_name, NULL);
                message_adaptor_plugin_h plugin = message_adaptor_create_plugin(plugin_path);
 
                if (NULL != plugin) {
index b5621867be021a5162b7ea69f709da03f3870893..dc8ea6b8273d4fb56b19a3b27a2d9bf94be99d6b 100644 (file)
@@ -220,7 +220,7 @@ static int push_adaptor_load_plugins_from_directory(push_adaptor_h adaptor, cons
 
        char *plugin_path = NULL;
        DIR *dir = NULL;
-       struct dirent dir_entry, *result = NULL;
+       struct dirent *dir_entry = NULL;
 
        if ((NULL == adaptor) || (NULL == dir_path)) {
                push_adaptor_error("Invalid argument");
@@ -234,18 +234,13 @@ static int push_adaptor_load_plugins_from_directory(push_adaptor_h adaptor, cons
        }
 
        int ret = PUSH_ADAPTOR_ERROR_NONE;
-       while (0 == (readdir_r(dir, &dir_entry, &result))) {
+       while (NULL != (dir_entry = readdir(dir))) {
 
-               if (NULL == result) {
-                       push_adaptor_error("Could not open directory %s", plugin_path);
-                       break;
-               }
-
-               if (dir_entry.d_type & DT_DIR) {
+               if (dir_entry->d_type & DT_DIR) {
                        continue;
                }
 
-               plugin_path = g_strconcat(dir_path, "/", dir_entry.d_name, NULL);
+               plugin_path = g_strconcat(dir_path, "/", dir_entry->d_name, NULL);
                push_adaptor_plugin_h plugin = push_adaptor_create_plugin(plugin_path);
 
                if (NULL != plugin) {
index 126c8dde6e42a32552744f377d42102ada213099..32bfa80f1f879f1a566ae7d7b6270533be26cf3d 100644 (file)
@@ -367,7 +367,7 @@ static int shop_adaptor_load_plugins_from_directory(shop_adaptor_h adaptor, cons
 {
        char *plugin_path = NULL;
        DIR *dir = NULL;
-       struct dirent dir_entry, *result = NULL;
+       struct dirent *dir_entry = NULL;
 
        shop_adaptor_debug("Starting load plugins from directory");
 
@@ -383,18 +383,13 @@ static int shop_adaptor_load_plugins_from_directory(shop_adaptor_h adaptor, cons
        }
 
        int ret = SHOP_ADAPTOR_ERROR_NONE;
-       while (0 == (readdir_r(dir, &dir_entry, &result))) {
+       while (NULL != (dir_entry = readdir(dir))) {
 
-               if (NULL == result) {
-                       shop_adaptor_error("Could not open directory %s", plugin_path);
-                       break;
-               }
-
-               if (dir_entry.d_type & DT_DIR) {
+               if (dir_entry->d_type & DT_DIR) {
                        continue;
                }
 
-               plugin_path = g_strconcat(dir_path, "/", dir_entry.d_name, NULL);
+               plugin_path = g_strconcat(dir_path, "/", dir_entry->d_name, NULL);
                shop_adaptor_plugin_h plugin = shop_adaptor_create_plugin(plugin_path);
 
                if (NULL != plugin) {
index e8bad2efa46b71619b085cd652c8ea7107f6f488..546fa83239a0db64481e1fd0fbad43d4d9f78359 100644 (file)
@@ -877,7 +877,7 @@ static int storage_adaptor_load_plugins_from_directory(storage_adaptor_h adaptor
 {
        char *plugin_path = NULL;
        DIR *dir = NULL;
-       struct dirent dir_entry, *result = NULL;
+       struct dirent *dir_entry = NULL;
 
        storage_adaptor_debug("Starting load plugins from directory");
 
@@ -893,18 +893,13 @@ static int storage_adaptor_load_plugins_from_directory(storage_adaptor_h adaptor
        }
 
        int ret = STORAGE_ADAPTOR_ERROR_NONE;
-       while (0 == (readdir_r(dir, &dir_entry, &result))) {
+       while (NULL != (dir_entry = readdir(dir))) {
 
-               if (NULL == result) {
-                       storage_adaptor_error("Could not open directory %s", plugin_path);
-                       break;
-               }
-
-               if (dir_entry.d_type & DT_DIR) {
+               if (dir_entry->d_type & DT_DIR) {
                        continue;
                }
 
-               plugin_path = g_strconcat(dir_path, "/", dir_entry.d_name, NULL);
+               plugin_path = g_strconcat(dir_path, "/", dir_entry->d_name, NULL);
                storage_adaptor_plugin_h plugin = storage_adaptor_create_plugin(plugin_path);
 
                if (NULL != plugin) {
index db4b49a6c39a4a917f4488d3c9a6d946b8c647b2..7deacf739fec6bd4a1e80056dbbb675084ec287c 100644 (file)
@@ -88,7 +88,7 @@ int service_file_get_list(service_file_directory_e directory, char ***file_names
        }
 
        DIR *dirp = NULL;
-       struct dirent dent, *result = NULL;
+       struct dirent *dent = NULL;
 
        dirp = opendir(SERVICE_FILE_PUSH_PATH);
        if (NULL == dirp) {
@@ -97,15 +97,12 @@ int service_file_get_list(service_file_directory_e directory, char ***file_names
        }
 
        GList *_file_list = NULL;
-       while (0 == readdir_r(dirp, &dent, &result)) {
-               if (NULL == result) {
-                       break;
-               }
-               service_adaptor_debug_func("===== entry name [%s]", dent.d_name);
-               if ((0 == strcmp(".", dent.d_name)) || (0 == strcmp("..", dent.d_name))) {
+       while (NULL != (dent = readdir(dirp))) {
+               service_adaptor_debug_func("===== entry name [%s]", dent->d_name);
+               if ((0 == strcmp(".", dent->d_name)) || (0 == strcmp("..", dent->d_name))) {
                        continue;
                }
-               char *file = strdup(dent.d_name);
+               char *file = strdup(dent->d_name);
                if (NULL != file) {
                        _file_list = g_list_append(_file_list, (void *)file);
                }