diff --git a/services/log/init_log.c b/services/log/init_log.c index 678b7f35cbdd6f6ffd0195ce0a2ae09f5eeec7d5..dbadec4bdeca9046079a06bf1bbf2a16d5dc9a62 100644 --- a/services/log/init_log.c +++ b/services/log/init_log.c @@ -71,9 +71,8 @@ void InitLog(const char *tag, InitLogLevel logLevel, const char *fileName, int l return; } - time_t logTime; - time(&logTime); - struct tm *t = gmtime(&logTime); + time_t second = time(0); + struct tm *t = localtime(&second); if (t == NULL) { printf("time is NULL.\n"); return; diff --git a/services/src/init_cmds.c b/services/src/init_cmds.c index d11e0ec35d0f1a8e8f4acd013238be3980d2d112..b3ffe478857a8643e36efdd19c2cd2e5679cb8ae 100644 --- a/services/src/init_cmds.c +++ b/services/src/init_cmds.c @@ -329,10 +329,14 @@ static void DoCopy(const char* cmdContent) out: FreeCmd(&ctx); ctx = NULL; - close(srcFd); - srcFd = -1; - close(dstFd); - dstFd = -1; + if (srcFd >= 0) { + close(srcFd); + srcFd = -1; + } + if (dstFd >= 0) { + close(dstFd); + dstFd = -1; + } return; }