From bcc80e21a19998addc526e6afaafc49c11abc517 Mon Sep 17 00:00:00 2001 From: chen Date: Fri, 26 Aug 2022 15:42:51 +0800 Subject: [PATCH] codex Signed-off-by: chen --- interfaces/innerkits/nativetoken/src/nativetoken.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interfaces/innerkits/nativetoken/src/nativetoken.c b/interfaces/innerkits/nativetoken/src/nativetoken.c index fd6e7e340..cf888363a 100644 --- a/interfaces/innerkits/nativetoken/src/nativetoken.c +++ b/interfaces/innerkits/nativetoken/src/nativetoken.c @@ -327,7 +327,7 @@ static int32_t GetAplLevel(const char *aplStr) static void WriteToFile(const cJSON *root) { - ssize_t strLen; + size_t strLen; ssize_t writtenLen; char *jsonStr = NULL; @@ -347,8 +347,8 @@ static void WriteToFile(const cJSON *root) strLen = strlen(jsonStr); writtenLen = write(fd, (void *)jsonStr, (size_t)strLen); close(fd); - if (writtenLen != strLen) { - AT_LOG_ERROR("[ATLIB-%s]:write failed, writtenLen is %zu.", __func__, writtenLen); + if (writtenLen < 0 || (size_t)writtenLen != strLen) { + AT_LOG_ERROR("[ATLIB-%s]:write failed, writtenLen is %zd.", __func__, writtenLen); break; } } while (0); -- Gitee