refactor(sync): fix coverity scan error
This commit is contained in:
parent
be29bb0d62
commit
fd9a612d50
|
@ -171,7 +171,7 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {
|
|||
pSyncNode->pLogStore->syncLogUpdateCommitIndex(pSyncNode->pLogStore, pSyncNode->commitIndex);
|
||||
|
||||
// execute fsm
|
||||
if (pSyncNode->pFsm != NULL) {
|
||||
if (pSyncNode != NULL && pSyncNode->pFsm != NULL) {
|
||||
int32_t code = syncNodeDoCommit(pSyncNode, beginIndex, endIndex, pSyncNode->state);
|
||||
if (code != 0) {
|
||||
sNError(pSyncNode, "advance commit index error, do commit begin:%" PRId64 ", end:%" PRId64, beginIndex,
|
||||
|
|
|
@ -64,7 +64,7 @@ SSyncRaftEntry* syncEntryBuildFromRpcMsg(const SRpcMsg* pMsg, SyncTerm term, Syn
|
|||
}
|
||||
|
||||
SSyncRaftEntry* syncEntryBuildFromAppendEntries(const SyncAppendEntries* pMsg) {
|
||||
SSyncRaftEntry* pEntry = syncEntryBuild(pMsg->dataLen);
|
||||
SSyncRaftEntry* pEntry = syncEntryBuild((int32_t)(pMsg->dataLen));
|
||||
if (pEntry == NULL) return NULL;
|
||||
|
||||
memcpy(pEntry, pMsg->data, pMsg->dataLen);
|
||||
|
@ -91,15 +91,14 @@ SSyncRaftEntry* syncEntryBuildNoop(SyncTerm term, SyncIndex index, int32_t vgId)
|
|||
|
||||
void syncEntryDestory(SSyncRaftEntry* pEntry) {
|
||||
if (pEntry != NULL) {
|
||||
taosMemoryFree(pEntry);
|
||||
|
||||
sTrace("free entry: %p", pEntry);
|
||||
taosMemoryFree(pEntry);
|
||||
}
|
||||
}
|
||||
|
||||
void syncEntry2OriginalRpc(const SSyncRaftEntry* pEntry, SRpcMsg* pRpcMsg) {
|
||||
pRpcMsg->msgType = pEntry->originalRpcType;
|
||||
pRpcMsg->contLen = pEntry->dataLen;
|
||||
pRpcMsg->contLen = (int32_t)(pEntry->dataLen);
|
||||
pRpcMsg->pCont = rpcMallocCont(pRpcMsg->contLen);
|
||||
memcpy(pRpcMsg->pCont, pEntry->data, pRpcMsg->contLen);
|
||||
}
|
||||
|
@ -339,7 +338,8 @@ int32_t raftEntryCacheGetEntry(struct SRaftEntryCache* pCache, SyncIndex index,
|
|||
SSyncRaftEntry* pEntry = NULL;
|
||||
int32_t code = raftEntryCacheGetEntryP(pCache, index, &pEntry);
|
||||
if (code == 1) {
|
||||
*ppEntry = taosMemoryMalloc((int64_t)(pEntry->bytes));
|
||||
int32_t bytes = (int32_t)pEntry->bytes;
|
||||
*ppEntry = taosMemoryMalloc((int64_t)bytes);
|
||||
memcpy(*ppEntry, pEntry, pEntry->bytes);
|
||||
(*ppEntry)->rid = -1;
|
||||
} else {
|
||||
|
|
|
@ -91,7 +91,7 @@ int32_t syncNodeReplicateOne(SSyncNode* pSyncNode, SRaftId* pDestId, bool snapsh
|
|||
if (code == 0) {
|
||||
ASSERT(pEntry != NULL);
|
||||
|
||||
code = syncBuildAppendEntries(&rpcMsg, pEntry->bytes, pSyncNode->vgId);
|
||||
code = syncBuildAppendEntries(&rpcMsg, (int32_t)(pEntry->bytes), pSyncNode->vgId);
|
||||
ASSERT(code == 0);
|
||||
|
||||
pMsg = rpcMsg.pCont;
|
||||
|
|
|
@ -229,7 +229,10 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo
|
|||
int32_t writeLen = vsnprintf(eventLog, sizeof(eventLog), format, argpointer);
|
||||
va_end(argpointer);
|
||||
|
||||
int32_t aqItems = pNode->pFsm->FpApplyQueueItems(pNode->pFsm);
|
||||
int32_t aqItems = 0;
|
||||
if (pNode != NULL && pNode->pFsm != NULL && pNode->pFsm->FpApplyQueueItems != NULL) {
|
||||
aqItems = pNode->pFsm->FpApplyQueueItems(pNode->pFsm);
|
||||
}
|
||||
|
||||
// restore error code
|
||||
terrno = errCode;
|
||||
|
|
Loading…
Reference in New Issue