From a8d4aef955a5afaaacea03c0cd495298eda08ed9 Mon Sep 17 00:00:00 2001 From: "SukHyung, Kang" Date: Fri, 18 Mar 2016 10:33:24 +0900 Subject: Use thread-safe functions Change-Id: I2011ebc0bf534098f2732ab05d65d2bc12d1253c Signed-off-by: SukHyung, Kang --- src/widget_conf.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/widget_conf.c b/src/widget_conf.c index e1bc98d..9ce3364 100644 --- a/src/widget_conf.c +++ b/src/widget_conf.c @@ -705,7 +705,8 @@ static char *parse_handler(const char *buffer) static char *find_input_device_by_path(const char *name) { DIR *dir; - struct dirent *entry; + struct dirent entry; + struct dirent *result; char path[PATH_MAX]; char *ptr; int len; @@ -725,13 +726,14 @@ static char *find_input_device_by_path(const char *name) ptr = path + len; len = PATH_MAX - len - 1; - while ((entry = readdir(dir))) { - if (entry->d_name[0] == '.' && - (entry->d_name[1] == '\0' || (entry->d_name[1] == '.' && entry->d_name[2] == '\0'))) { + while ((readdir_r(dir, &entry, &result) == 0) && (result != NULL)) { + if (result->d_name[0] == '.' && + (result->d_name[1] == '\0' + || (result->d_name[1] == '.' && result->d_name[2] == '\0'))) { continue; } - strncpy(ptr, entry->d_name, len); + strncpy(ptr, result->d_name, len); ptr[len] = '\0'; fd = open(path, O_RDONLY); -- cgit v1.2.3