[TD_543] fix coverity scan issues in dnode module

This commit is contained in:
Shengliang Guan 2020-06-09 10:35:07 +00:00
parent 14313882a7
commit c96f11e808
3 changed files with 15 additions and 12 deletions

View File

@ -83,11 +83,12 @@ void dnodeCleanupServer() {
} }
static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcIpSet *pIpSet) { static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
SRpcMsg rspMsg; SRpcMsg rspMsg = {
rspMsg.handle = pMsg->handle; .handle = pMsg->handle,
rspMsg.pCont = NULL; .pCont = NULL,
rspMsg.contLen = 0; .contLen = 0
};
if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_RUNING) { if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_RUNING) {
rspMsg.code = TSDB_CODE_RPC_NOT_READY; rspMsg.code = TSDB_CODE_RPC_NOT_READY;
rpcSendResponse(&rspMsg); rpcSendResponse(&rspMsg);

View File

@ -19,6 +19,7 @@
#include "taosdef.h" #include "taosdef.h"
#include "taosmsg.h" #include "taosmsg.h"
#include "tglobal.h" #include "tglobal.h"
#include "tutil.h"
#include "http.h" #include "http.h"
#include "mnode.h" #include "mnode.h"
#include "dnode.h" #include "dnode.h"
@ -108,10 +109,11 @@ void dnodeCleanupShell() {
} }
void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcIpSet *pIpSet) { void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcIpSet *pIpSet) {
SRpcMsg rpcMsg; SRpcMsg rpcMsg = {
rpcMsg.handle = pMsg->handle; .handle = pMsg->handle,
rpcMsg.pCont = NULL; .pCont = NULL,
rpcMsg.contLen = 0; .contLen = 0
};
if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_RUNING) { if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_RUNING) {
dError("RPC %p, shell msg:%s is ignored since dnode not running", pMsg->handle, taosMsg[pMsg->msgType]); dError("RPC %p, shell msg:%s is ignored since dnode not running", pMsg->handle, taosMsg[pMsg->msgType]);
@ -143,7 +145,7 @@ static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char
if (code != TSDB_CODE_RPC_NOT_READY) return code; if (code != TSDB_CODE_RPC_NOT_READY) return code;
SDMAuthMsg *pMsg = rpcMallocCont(sizeof(SDMAuthMsg)); SDMAuthMsg *pMsg = rpcMallocCont(sizeof(SDMAuthMsg));
strcpy(pMsg->user, user); tstrncpy(pMsg->user, user, TSDB_USER_LEN);
SRpcMsg rpcMsg = {0}; SRpcMsg rpcMsg = {0};
rpcMsg.pCont = pMsg; rpcMsg.pCont = pMsg;
@ -201,7 +203,7 @@ void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t sid) {
int16_t numOfTags = htons(pTable->numOfTags); int16_t numOfTags = htons(pTable->numOfTags);
int32_t sid = htonl(pTable->sid); int32_t sid = htonl(pTable->sid);
uint64_t uid = htobe64(pTable->uid); uint64_t uid = htobe64(pTable->uid);
dPrint("table:%s, numOfColumns:%d numOfTags:%d sid:%d uid:%d", pTable->tableId, numOfColumns, numOfTags, sid, uid); dPrint("table:%s, numOfColumns:%d numOfTags:%d sid:%d uid:" PRIu64, pTable->tableId, numOfColumns, numOfTags, sid, uid);
return rpcRsp.pCont; return rpcRsp.pCont;
} }

View File

@ -33,7 +33,7 @@ int32_t main(int32_t argc, char *argv[]) {
printf("config file path overflow"); printf("config file path overflow");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
strcpy(configDir, argv[i]); tstrncpy(configDir, argv[i], TSDB_FILENAME_LEN);
} else { } else {
printf("'-c' requires a parameter, default:%s\n", configDir); printf("'-c' requires a parameter, default:%s\n", configDir);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);