Replace deprecated readdir_r with readdir 23/106023/4 accepted/tizen/common/20161227.192120 accepted/tizen/ivi/20161226.131243 accepted/tizen/mobile/20161226.131204 accepted/tizen/tv/20161226.131210 accepted/tizen/wearable/20161226.131219 submit/tizen/20161226.013211 submit/tizen/20170106.082227 submit/tizen/20170106.082921
authorKyungwook Tak <k.tak@samsung.com>
Wed, 21 Dec 2016 09:22:55 +0000 (18:22 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Mon, 26 Dec 2016 00:28:15 +0000 (09:28 +0900)
Change-Id: I47574d8c7523b5976e79adefa2a6cf290fe705db
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
tadcore/TADCInterface/TADC_IF.cpp

index 6033592..2095ef7 100644 (file)
@@ -36,6 +36,7 @@
 
 #include <dirent.h>
 
+#include <cerrno>
 #include <memory>
 
 #include "DUIDGenerator.h"
@@ -338,9 +339,7 @@ int AddCertSTOREFromDir(X509_STORE *pstStore, const char *dirPath)
        int ret = 0;
 
        DIR *dir = NULL;
-       struct dirent entry;
-       struct dirent *result;
-       int error;
+       struct dirent *result = nullptr;
        char file_path_buff[512];
 
        if (pstStore == NULL || dirPath == NULL) {
@@ -358,23 +357,25 @@ int AddCertSTOREFromDir(X509_STORE *pstStore, const char *dirPath)
        }
 
        while (true) {
-               error = readdir_r(dir, &entry, &result);
-
-               if (error != 0) {
-                       DRM_TAPPS_EXCEPTION("fail to read entries from a directory(%s)!", dirPath);
-                       ret = -1;
-                       goto error;
+               errno = 0;
+               result = readdir(dir);
+               if (result == NULL) {
+                       if (errno != 0) {
+                               DRM_TAPPS_EXCEPTION("fail to read entries from a directory(%s)!",
+                                                                       dirPath);
+                               ret = -1;
+                               goto error;
+                       } else {
+                               // end of stream
+                               break;
+                       }
                }
 
-               // readdir_r returns NULL in *result if the end
-               // of the directory stream is reached
-               if (result == NULL)
-                       break;
-
-               if (entry.d_type == DT_REG) { // regular file
+               if (result->d_type == DT_REG) {
+                       // regular file
                        memset(file_path_buff, 0, sizeof(file_path_buff));
                        snprintf(file_path_buff, sizeof(file_path_buff), "%s/%s", dirPath,
-                                        entry.d_name);
+                                        result->d_name);
 
                        if (AddCertSTOREFromFile(pstStore, file_path_buff) == 0) {
                                DRM_TAPPS_LOG("Add root cert : file=%s", file_path_buff);