From 7ccfb7c3ec36dc9ff498a3bf9776b18bb6d509de Mon Sep 17 00:00:00 2001 From: fan Date: Sun, 26 Jun 2022 18:36:22 +0800 Subject: [PATCH] fix: fix some warnings by Coverity Scan in rpcMain.c (#14267) --- src/rpc/src/rpcMain.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 95931fcbc6..84d8dc842b 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -361,8 +361,8 @@ void *rpcMallocCont(int contLen) { void rpcFreeCont(void *cont) { if (cont) { char *temp = ((char *)cont) - sizeof(SRpcHead) - sizeof(SRpcReqContext); - free(temp); tTrace("free mem: %p", temp); + free(temp); } } @@ -573,8 +573,8 @@ void rpcCancelRequest(int64_t rid) { static void rpcFreeMsg(void *msg) { if ( msg ) { char *temp = (char *)msg - sizeof(SRpcReqContext); - free(temp); tTrace("free mem: %p", temp); + free(temp); } } @@ -736,7 +736,7 @@ static SRpcConn *rpcAllocateServerConn(SRpcInfo *pRpc, SRecvInfo *pRecv) { memcpy(pConn->user, pHead->user, tListLen(pConn->user)); pConn->pRpc = pRpc; pConn->sid = sid; - pConn->tranId = (uint16_t)(rand() & 0xFFFF); + pConn->tranId = (uint16_t)(random() & 0xFFFF); pConn->ownId = htonl(pConn->sid); pConn->linkUid = pHead->linkUid; if (pRpc->afp) { @@ -1116,7 +1116,7 @@ static void *rpcProcessMsgFromPeer(SRecvInfo *pRecv) { if (pHead->msgType + 1 > 1 && pHead->msgType+1 < TSDB_MSG_TYPE_MAX) { tDebug("%s %p %p, %s is sent with error code:0x%x", pRpc->label, pConn, (void *)pHead->ahandle, taosMsg[pHead->msgType+1], code); } else { - tError("%s %p %p, %s is sent with error code:0x%x", pRpc->label, pConn, (void *)pHead->ahandle, taosMsg[pHead->msgType], code); + tError("%s %p %p, UnkownmsgType is sent with error code:0x%x", pRpc->label, pConn, (void *)pHead->ahandle, code); } } } else { // msg is passed to app only parsing is ok @@ -1172,6 +1172,7 @@ static void rpcProcessIncomingMsg(SRpcConn *pConn, SRpcHead *pHead, SRpcReqConte SRpcMsg rMsg = {.handle = rpcMsg.handle, .pCont = NULL, .contLen = 0}; rpcSendResponse(&rMsg); rpcFreeCont(rpcMsg.pCont); + rpcFreeMsg(pHead); return; } break; -- GitLab