From 5d0cc08e9a0e2c5020cd8a12b180d1b3aef7ada4 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 9 Jun 2020 08:52:36 +0000 Subject: [PATCH] [TD_543] fix coverity scan, cid:290455 286428 286450 287977 287995 290226 --- src/dnode/src/dnodeMain.c | 8 +++----- src/dnode/src/dnodeMgmt.c | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/dnode/src/dnodeMain.c b/src/dnode/src/dnodeMain.c index 73bc2923b2..91f146dde4 100644 --- a/src/dnode/src/dnodeMain.c +++ b/src/dnode/src/dnodeMain.c @@ -61,12 +61,10 @@ static const SDnodeComponent tsDnodeComponents[] = { }; static int dnodeCreateDir(const char *dir) { - struct stat dirstat; - if (stat(dir, &dirstat) < 0) { - if (mkdir(dir, 0755) != 0 && errno != EEXIST) { - return -1; - } + if (mkdir(dir, 0755) != 0 && errno != EEXIST) { + return -1; } + return 0; } diff --git a/src/dnode/src/dnodeMgmt.c b/src/dnode/src/dnodeMgmt.c index 4b448837fe..e260e7ec81 100644 --- a/src/dnode/src/dnodeMgmt.c +++ b/src/dnode/src/dnodeMgmt.c @@ -177,10 +177,12 @@ void dnodeDispatchToMgmtQueue(SRpcMsg *pMsg) { memcpy(item, pMsg, sizeof(SRpcMsg)); taosWriteQitem(tsMgmtQueue, 1, item); } else { - SRpcMsg rsp; - rsp.handle = pMsg->handle; - rsp.pCont = NULL; - rsp.code = TSDB_CODE_DND_OUT_OF_MEMORY; + SRpcMsg rsp = { + .handle = pMsg->handle, + .pCont = NULL, + .code = TSDB_CODE_DND_OUT_OF_MEMORY + }; + rpcSendResponse(&rsp); rpcFreeCont(pMsg->pCont); } @@ -188,9 +190,9 @@ void dnodeDispatchToMgmtQueue(SRpcMsg *pMsg) { static void *dnodeProcessMgmtQueue(void *param) { SRpcMsg *pMsg; - SRpcMsg rsp; + SRpcMsg rsp = {0}; int type; - void *handle; + void * handle; while (1) { if (taosReadQitemFromQset(tsMgmtQset, &type, (void **) &pMsg, &handle) == 0) { @@ -251,6 +253,7 @@ static int32_t dnodeOpenVnodes() { if (status != TSDB_CODE_SUCCESS) { dPrint("Get dnode list failed"); + free(vnodeList); return status; } @@ -290,6 +293,7 @@ static void dnodeCloseVnodes() { if (status != TSDB_CODE_SUCCESS) { dPrint("Get dnode list failed"); + free(vnodeList); return; } @@ -456,6 +460,7 @@ static bool dnodeReadMnodeInfos() { return false; } + content[len] = 0; cJSON* root = cJSON_Parse(content); if (root == NULL) { dError("failed to read mnodeIpList.json, invalid json format"); @@ -628,6 +633,7 @@ static bool dnodeReadDnodeCfg() { return false; } + content[len] = 0; cJSON* root = cJSON_Parse(content); if (root == NULL) { dError("failed to read dnodeCfg.json, invalid json format");