Replace 'readdir_r' with 'readdir' 22/105022/1 accepted/tizen/common/20161219.151857 accepted/tizen/ivi/20161219.021800 accepted/tizen/mobile/20161219.021627 accepted/tizen/tv/20161219.021700 accepted/tizen/wearable/20161219.021732 submit/tizen/20161216.095153
authorInkyun Kil <inkyun.kil@samsung.com>
Thu, 15 Dec 2016 06:06:56 +0000 (15:06 +0900)
committerInkyun Kil <inkyun.kil@samsung.com>
Thu, 15 Dec 2016 06:34:50 +0000 (15:34 +0900)
'readdir_r' is deprecated since version 2.24 glibc.
By upgrading TOOLCHAIN for platform, it should be replaced by 'readdir'

Change-Id: I802ccd1cca6d9504948140a9c72000c9960b3ea1
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
plugin/app2sd/common/src/app2sd_utils.c
plugin/app2sd/server/app2sd_interface.c
plugin/app2sd/server/app2sd_internals_utils.c

index e2e1a8d..270f5fc 100644 (file)
@@ -50,18 +50,17 @@ char *_app2sd_get_encoded_name(const char *pkgid, uid_t uid)
 int _app2sd_delete_directory(const char *dirname)
 {
        DIR *dp = NULL;
-       struct dirent ep;
-       struct dirent *er = NULL;
+       struct dirent *ep = NULL;
        char abs_filename[FILENAME_MAX] = { 0, };
        int ret = 0;
 
        dp = opendir(dirname);
        if (dp != NULL) {
-               while (readdir_r(dp, &ep, &er) == 0 && er != NULL) {
+               while ((ep = readdir(dp)) != NULL) {
                        struct stat stFileInfo;
 
                        snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname,
-                               ep.d_name);
+                               ep->d_name);
 
                        if (lstat(abs_filename, &stFileInfo) < 0) {
                                perror(abs_filename);
@@ -70,8 +69,8 @@ int _app2sd_delete_directory(const char *dirname)
                        }
 
                        if (S_ISDIR(stFileInfo.st_mode)) {
-                               if (strcmp(ep.d_name, ".")
-                                   && strcmp(ep.d_name, "..")) {
+                               if (strcmp(ep->d_name, ".")
+                                   && strcmp(ep->d_name, "..")) {
                                        ret = _app2sd_delete_directory(abs_filename);
                                        if (ret < 0) {
                                                (void)closedir(dp);
index 40e2cf8..d5fd1d7 100644 (file)
@@ -1353,15 +1353,13 @@ int app2sd_usr_force_clean(const char *pkgid, uid_t uid)
 int app2sd_enable_full_pkg(void)
 {
        int ret = APP2EXT_SUCCESS;
-       int rc = 0;
        char buf[FILENAME_MAX] = { 0, };
        char app2sd_path[FILENAME_MAX] = { 0, };
        char loopback_device[FILENAME_MAX] = { 0, };
        char *sdpath = NULL;
        char *pkgid = NULL;
        DIR *dir = NULL;
-       struct dirent entry;
-       struct dirent *result = NULL;
+       struct dirent *entry = NULL;
        uid_t uid = 0;
 
        /* check whether MMC is present or not */
@@ -1388,14 +1386,12 @@ int app2sd_enable_full_pkg(void)
                return APP2EXT_ERROR_SQLITE_REGISTRY;
        }
 
-       for (rc = readdir_r(dir, &entry, &result);
-               rc == 0 && result != NULL;
-               rc = readdir_r(dir, &entry, &result)) {
-               if (strcmp(entry.d_name, ".") == 0 ||
-                       strcmp(entry.d_name, "..") == 0)
+       while ((entry = readdir(dir)) != NULL) {
+               if (strcmp(entry->d_name, ".") == 0 ||
+                       strcmp(entry->d_name, "..") == 0)
                        continue;
                snprintf(loopback_device, FILENAME_MAX - 1, "%s/%s",
-                       app2sd_path, entry.d_name);
+                       app2sd_path, entry->d_name);
                ret = _app2sd_get_info_from_db(loopback_device,
                        &pkgid, &uid);
                if (ret) {
index 1640af3..f85380e 100644 (file)
@@ -142,22 +142,21 @@ void _app2sd_delete_symlink(const char *dirname)
 {
        int ret = 0;
        DIR *dp = NULL;
-       struct dirent ep;
-       struct dirent *er = NULL;
+       struct dirent *ep = NULL;
        char abs_filename[FILENAME_MAX] = { 0, };
 
        _D("start clean_symlink [%s]", dirname);
 
        dp = opendir(dirname);
        if (dp != NULL) {
-               while (readdir_r(dp, &ep, &er) == 0 && er != NULL) {
+               while ((ep = readdir(dp)) != NULL) {
                        char mmc_path[PATH_MAX] = {0};
 
-                       if (!strcmp(ep.d_name, ".") || !strcmp(ep.d_name, ".."))
+                       if (!strcmp(ep->d_name, ".") || !strcmp(ep->d_name, ".."))
                                continue;
 
                        /*get realpath find symlink to ".mmc" and unlink it*/
-                       snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname, ep.d_name);
+                       snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname, ep->d_name);
                        char *path = realpath(abs_filename, mmc_path);
                        if (!path)
                                _E("realpath failed");
@@ -244,17 +243,16 @@ unsigned long long _app2sd_calculate_dir_size(char *dirname)
 {
        static unsigned long long total = 0;
        DIR *dp = NULL;
-       struct dirent ep;
-       struct dirent *er = NULL;
+       struct dirent *ep = NULL;
        char abs_filename[FILENAME_MAX] = { 0, };;
 
        dp = opendir(dirname);
        if (dp != NULL) {
-               while (readdir_r(dp, &ep, &er) == 0 && er != NULL) {
+               while ((ep = readdir(dp)) != NULL) {
                        struct stat stFileInfo;
 
                        snprintf(abs_filename, FILENAME_MAX, "%s/%s", dirname,
-                                ep.d_name);
+                                ep->d_name);
 
                        if (stat(abs_filename, &stFileInfo) < 0)
                                perror(abs_filename);
@@ -262,8 +260,8 @@ unsigned long long _app2sd_calculate_dir_size(char *dirname)
                                total += stFileInfo.st_size;
 
                                if (S_ISDIR(stFileInfo.st_mode)) {
-                                       if (strcmp(ep.d_name, ".")
-                                           && strcmp(ep.d_name, "..")) {
+                                       if (strcmp(ep->d_name, ".")
+                                           && strcmp(ep->d_name, "..")) {
                                                _app2sd_calculate_dir_size
                                                    (abs_filename);
                                        }