diff options
-rw-r--r-- | src/block/vfat.c | 7 | ||||
-rw-r--r-- | src/core/common.c | 10 | ||||
-rw-r--r-- | src/libdeviced/deviced-util.c | 6 | ||||
-rw-r--r-- | src/time/time-handler.c | 20 |
4 files changed, 28 insertions, 15 deletions
diff --git a/src/block/vfat.c b/src/block/vfat.c index 430ac52b..61cba2ec 100644 --- a/src/block/vfat.c +++ b/src/block/vfat.c @@ -64,7 +64,7 @@ static int vfat_check(const char *devpath) switch (r) { case 0: _I("filesystem check completed OK"); - break; + return 0; case 2: _I("file system check failed (not a FAT filesystem)"); errno = ENODATA; @@ -75,15 +75,14 @@ static int vfat_check(const char *devpath) continue; } _I("failing check after rechecks, but file system modified"); - break; + errno = EIO; + return -1; default: _I("filesystem check failed (unknown exit code %d)", r); errno = EIO; return -1; } } while (1); - - return 0; } static bool vfat_match(const char *devpath) diff --git a/src/core/common.c b/src/core/common.c index e1cdad01..4297b9f7 100644 --- a/src/core/common.c +++ b/src/core/common.c @@ -374,9 +374,11 @@ int mount_check(const char *path) void print_time(const char *prefix) { struct timeval tv; - struct tm *tm; + struct tm tm; + struct tm *ret; gettimeofday(&tv, NULL); - tm = localtime(&(tv.tv_sec)); - _D("%s --> %d:%02d:%02d %d", - prefix, tm->tm_hour, tm->tm_min, tm->tm_sec, tv.tv_usec); + ret = localtime_r(&(tv.tv_sec), &tm); + if (ret) + _D("%s --> %d:%02d:%02d %d", + prefix, tm.tm_hour, tm.tm_min, tm.tm_sec, tv.tv_usec); } diff --git a/src/libdeviced/deviced-util.c b/src/libdeviced/deviced-util.c index 16629055..f9a71f4d 100644 --- a/src/libdeviced/deviced-util.c +++ b/src/libdeviced/deviced-util.c @@ -37,6 +37,7 @@ API int deviced_get_pid(const char *execpath) { DIR *dp; + struct dirent entry; struct dirent *dentry; int pid = -1, fd; char buf[BUFF_MAX]; @@ -49,7 +50,10 @@ API int deviced_get_pid(const char *execpath) return -1; } - while ((dentry = readdir(dp)) != NULL) { + if ((readdir_r(dp, &entry, &dentry)) != 0) + dentry = NULL; + + while (dentry != NULL) { if (!isdigit(dentry->d_name[0])) continue; diff --git a/src/time/time-handler.c b/src/time/time-handler.c index e0065a3f..85f8c7eb 100644 --- a/src/time/time-handler.c +++ b/src/time/time-handler.c @@ -87,8 +87,10 @@ int handle_timezone(char *str) int ret; struct stat sts; time_t now; - struct tm *ts; + struct tm ts; + struct tm *ts2; const char *sympath, *tzpath; + char buf[256]; if (str == NULL) return -1; @@ -105,8 +107,11 @@ int handle_timezone(char *str) /* FIXME for debugging purpose */ time(&now); - ts = localtime(&now); - _D("cur local time is %s", asctime(ts)); + ts2 = localtime_r(&now, &ts); + if (ts2) { + asctime_r(&ts, buf); + _D("cur local time is %s", buf); + } /* unlink current link * eg. rm /opt/etc/localtime */ @@ -126,7 +131,7 @@ int handle_timezone(char *str) * eg. ln -s /usr/share/zoneinfo/Asia/Seoul /opt/etc/localtime */ ret = symlink(tzpath, sympath); if (ret < 0) { - _E("symlink error : [%d]%s", ret, strerror(errno)); + _E("symlink error : [%d]%s", ret, errno); return -1; } _D("symlink success"); @@ -134,8 +139,11 @@ int handle_timezone(char *str) tzset(); /* FIXME for debugging purpose */ - ts = localtime(&now); - _D("new local time is %s", asctime(ts)); + ts2 = localtime_r(&now, &ts); + if (ts2) { + asctime_r(&ts, buf); + _D("new local time is %s", buf); + } return 0; } |