sensord: [svace] change readdir to readdir_r 87/62687/2
authorkibak.yoon <kibak.yoon@samsung.com>
Thu, 17 Mar 2016 08:19:42 +0000 (17:19 +0900)
committerkibak.yoon <kibak.yoon@samsung.com>
Thu, 17 Mar 2016 11:32:26 +0000 (20:32 +0900)
Change-Id: I3736cc026ac64efd05a9ca0b41f1a60daae3a306
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
src/server/sensor_loader.cpp

index dfc8f26..c65915e 100644 (file)
@@ -270,7 +270,10 @@ void sensor_loader::show_sensor_info(void)
 bool sensor_loader::get_paths_from_dir(const string &dir_path, vector<string> &hal_paths)
 {
        DIR *dir = NULL;
-       struct dirent *dir_entry = NULL;
+       struct dirent dir_entry;
+       struct dirent *result;
+       string name;
+       int error;
 
        dir = opendir(dir_path.c_str());
 
@@ -279,10 +282,16 @@ bool sensor_loader::get_paths_from_dir(const string &dir_path, vector<string> &h
                return false;
        }
 
-       string name;
+       while (true) {
+               error = readdir_r(dir, &dir_entry, &result);
+
+               if (error != 0)
+                       continue;
+
+               if (result == NULL)
+                       break;
 
-       while ((dir_entry = readdir(dir))) {
-               name = string(dir_entry->d_name);
+               name = string(dir_entry.d_name);
 
                if (name == "." || name == "..")
                        continue;