From 78941a1ca86363ddcb7bab93f6ecf801aed35a1f Mon Sep 17 00:00:00 2001 From: zhong_ning Date: Wed, 21 Jul 2021 16:48:21 +0800 Subject: [PATCH] fix code style Signed-off-by: zhong_ning --- services/log/init_log.c | 5 ++--- services/src/init_cmds.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/services/log/init_log.c b/services/log/init_log.c index 678b7f35..dbadec4b 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 d11e0ec3..b3ffe478 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; } -- GitLab