From 94d45c3976ee24a8a3232275c197de3ab22b0f49 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Mon, 24 May 2021 11:27:11 +0800 Subject: [PATCH] [TD-3197]: taosdemo and taosdump coverity scan issues. (#6207) Co-authored-by: Shuduo Sang --- src/kit/taosdemo/taosdemo.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index d4faecf1f0..81f48067d0 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -1114,21 +1114,21 @@ static int queryDbExec(TAOS *taos, char *command, QUERY_TYPE type, bool quiet) { static void appendResultBufToFile(char *resultBuf, char *resultFile) { - FILE *fp = NULL; - if (resultFile[0] != 0) { - fp = fopen(resultFile, "at"); - if (fp == NULL) { - errorPrint( - "%s() LN%d, failed to open result file: %s, result will not save to file\n", - __func__, __LINE__, resultFile); - return; + FILE *fp = NULL; + if (resultFile[0] != 0) { + fp = fopen(resultFile, "at"); + if (fp == NULL) { + errorPrint( + "%s() LN%d, failed to open result file: %s, result will not save to file\n", + __func__, __LINE__, resultFile); + return; + } + fprintf(fp, "%s", resultBuf); + tmfclose(fp); } - } - - fprintf(fp, "%s", resultBuf); - tmfclose(fp); } + static void appendResultToFile(TAOS_RES *res, char* resultFile) { TAOS_ROW row = NULL; int num_rows = 0; -- GitLab