From e6b403148724a67761da5bb80c88d64f4901fd4e Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 12 Jan 2023 16:04:57 +0800 Subject: [PATCH] fix: coverity issues --- source/dnode/mnode/impl/src/mndSma.c | 14 ++++++++------ source/dnode/mnode/impl/src/mndSync.c | 5 +++++ source/util/src/tworker.c | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndSma.c b/source/dnode/mnode/impl/src/mndSma.c index 1aa93c6b6f..fe0dc9e857 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -201,12 +201,14 @@ static SSdbRow *mndSmaActionDecode(SSdbRaw *pRaw) { terrno = 0; _OVER: - if (terrno != 0 && pSma != NULL) { - mError("sma:%s, failed to decode from raw:%p since %s", pSma->name, pRaw, terrstr()); - taosMemoryFreeClear(pSma->expr); - taosMemoryFreeClear(pSma->tagsFilter); - taosMemoryFreeClear(pSma->sql); - taosMemoryFreeClear(pSma->ast); + if (terrno != 0) { + if (pSma != NULL) { + mError("sma:%s, failed to decode from raw:%p since %s", pSma->name, pRaw, terrstr()); + taosMemoryFreeClear(pSma->expr); + taosMemoryFreeClear(pSma->tagsFilter); + taosMemoryFreeClear(pSma->sql); + taosMemoryFreeClear(pSma->ast); + } taosMemoryFreeClear(pRow); return NULL; } diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index 66d9bdd684..7dc0912403 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -271,6 +271,11 @@ SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) { int32_t mndInitSync(SMnode *pMnode) { SSyncMgmt *pMgmt = &pMnode->syncMgmt; taosThreadMutexInit(&pMgmt->lock, NULL); + taosThreadMutexLock(&pMgmt->lock); + pMgmt->transId = 0; + pMgmt->transSec = 0; + pMgmt->transSeq = 0; + taosThreadMutexUnlock(&pMgmt->lock); SSyncInfo syncInfo = { .snapshotStrategy = SYNC_STRATEGY_STANDARD_SNAPSHOT, diff --git a/source/util/src/tworker.c b/source/util/src/tworker.c index bb2d59463d..5581931178 100644 --- a/source/util/src/tworker.c +++ b/source/util/src/tworker.c @@ -227,8 +227,8 @@ STaosQueue *tAutoQWorkerAllocQueue(SAutoQWorkerPool *pool, void *ahandle, FItem uError("worker:%s:%d failed to create", pool->name, curWorkerNum); taosMemoryFree(worker); taosCloseQueue(queue); - terrno = TSDB_CODE_OUT_OF_MEMORY; taosThreadMutexUnlock(&pool->mutex); + terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } worker->id = curWorkerNum; -- GitLab