From ea5a2a694649a88d5b7428aa2bdcf875e5291cd4 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 25 Sep 2024 17:45:10 +0800 Subject: [PATCH] ehn: remove void --- source/common/src/cos.c | 5 +- source/common/src/tglobal.c | 51 ++++++++++--------- source/common/src/trow.c | 6 ++- source/common/src/ttime.c | 28 +++++----- source/libs/index/inc/indexUtil.h | 34 ++++++------- source/libs/stream/src/streamBackendRocksdb.c | 16 ++++-- source/libs/transport/src/thttp.c | 12 +++-- source/libs/transport/src/tmsgcb.c | 4 +- source/libs/transport/src/trans.c | 11 ++-- source/libs/transport/src/transCli.c | 28 +++++++--- source/libs/transport/src/transComm.c | 11 +++- source/libs/transport/src/transSvr.c | 19 +++++-- source/libs/wal/src/walMgmt.c | 4 +- source/libs/wal/src/walRead.c | 17 +++++-- source/libs/wal/src/walWrite.c | 16 ++++-- 15 files changed, 171 insertions(+), 91 deletions(-) diff --git a/source/common/src/cos.c b/source/common/src/cos.c index 88f97a498d..9d472a5284 100644 --- a/source/common/src/cos.c +++ b/source/common/src/cos.c @@ -1292,7 +1292,10 @@ int32_t s3DeleteObjects(const char *object_name[], int nobject) { void s3DeleteObjectsByPrefix(const char *prefix) { SArray *objectArray = getListByPrefix(prefix); if (objectArray == NULL) return; - (void)s3DeleteObjects(TARRAY_DATA(objectArray), TARRAY_SIZE(objectArray)); + int32_t code = s3DeleteObjects(TARRAY_DATA(objectArray), TARRAY_SIZE(objectArray)); + if (code) { + uError("failed to delete objects with prefix %s", prefix); + } taosArrayDestroyEx(objectArray, s3FreeObjectKey); } diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index a3220706c7..2aef97ed1b 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -2299,11 +2299,14 @@ static int taosLogVarComp(void const *lp, void const *rp) { return strcasecmp(lpVar->name, rpVar->name); } -static int32_t taosCheckAndSetDebugFlag(int32_t *pFlagPtr, char *name, int32_t flag, SArray *noNeedToSetVars) { +static void taosCheckAndSetDebugFlag(int32_t *pFlagPtr, char *name, int32_t flag, SArray *noNeedToSetVars) { if (noNeedToSetVars != NULL && taosArraySearch(noNeedToSetVars, name, taosLogVarComp, TD_EQ) != NULL) { - TAOS_RETURN(TSDB_CODE_SUCCESS); + return; } - return taosSetDebugFlag(pFlagPtr, name, flag); + if (taosSetDebugFlag(pFlagPtr, name, flag) != 0) { + uError("failed to set flag %s to %d", name, flag); + } + return; } int32_t taosSetGlobalDebugFlag(int32_t flag) { return taosSetAllDebugFlag(tsCfg, flag); } @@ -2320,29 +2323,29 @@ static int32_t taosSetAllDebugFlag(SConfig *pCfg, int32_t flag) { pItem->i32 = flag; noNeedToSetVars = pItem->array; - (void)taosCheckAndSetDebugFlag(&simDebugFlag, "simDebugFlag", flag, noNeedToSetVars); - (void)taosCheckAndSetDebugFlag(&uDebugFlag, "uDebugFlag", flag, noNeedToSetVars); - (void)taosCheckAndSetDebugFlag(&rpcDebugFlag, "rpcDebugFlag", flag, noNeedToSetVars); - (void)taosCheckAndSetDebugFlag(&qDebugFlag, "qDebugFlag", flag, noNeedToSetVars); + taosCheckAndSetDebugFlag(&simDebugFlag, "simDebugFlag", flag, noNeedToSetVars); + taosCheckAndSetDebugFlag(&uDebugFlag, "uDebugFlag", flag, noNeedToSetVars); + taosCheckAndSetDebugFlag(&rpcDebugFlag, "rpcDebugFlag", flag, noNeedToSetVars); + taosCheckAndSetDebugFlag(&qDebugFlag, "qDebugFlag", flag, noNeedToSetVars); - (void)taosCheckAndSetDebugFlag(&jniDebugFlag, "jniDebugFlag", flag, noNeedToSetVars); - (void)taosCheckAndSetDebugFlag(&cDebugFlag, "cDebugFlag", flag, noNeedToSetVars); + taosCheckAndSetDebugFlag(&jniDebugFlag, "jniDebugFlag", flag, noNeedToSetVars); + taosCheckAndSetDebugFlag(&cDebugFlag, "cDebugFlag", flag, noNeedToSetVars); - (void)taosCheckAndSetDebugFlag(&dDebugFlag, "dDebugFlag", flag, noNeedToSetVars); - (void)taosCheckAndSetDebugFlag(&vDebugFlag, "vDebugFlag", flag, noNeedToSetVars); - (void)taosCheckAndSetDebugFlag(&mDebugFlag, "mDebugFlag", flag, noNeedToSetVars); - (void)taosCheckAndSetDebugFlag(&wDebugFlag, "wDebugFlag", flag, noNeedToSetVars); - (void)taosCheckAndSetDebugFlag(&sDebugFlag, "sDebugFlag", flag, noNeedToSetVars); - (void)taosCheckAndSetDebugFlag(&tsdbDebugFlag, "tsdbDebugFlag", flag, noNeedToSetVars); - (void)taosCheckAndSetDebugFlag(&tqDebugFlag, "tqDebugFlag", flag, noNeedToSetVars); - (void)taosCheckAndSetDebugFlag(&fsDebugFlag, "fsDebugFlag", flag, noNeedToSetVars); - (void)taosCheckAndSetDebugFlag(&udfDebugFlag, "udfDebugFlag", flag, noNeedToSetVars); - (void)taosCheckAndSetDebugFlag(&smaDebugFlag, "smaDebugFlag", flag, noNeedToSetVars); - (void)taosCheckAndSetDebugFlag(&idxDebugFlag, "idxDebugFlag", flag, noNeedToSetVars); - (void)taosCheckAndSetDebugFlag(&tdbDebugFlag, "tdbDebugFlag", flag, noNeedToSetVars); - (void)taosCheckAndSetDebugFlag(&metaDebugFlag, "metaDebugFlag", flag, noNeedToSetVars); - (void)taosCheckAndSetDebugFlag(&stDebugFlag, "stDebugFlag", flag, noNeedToSetVars); - (void)taosCheckAndSetDebugFlag(&sndDebugFlag, "sndDebugFlag", flag, noNeedToSetVars); + taosCheckAndSetDebugFlag(&dDebugFlag, "dDebugFlag", flag, noNeedToSetVars); + taosCheckAndSetDebugFlag(&vDebugFlag, "vDebugFlag", flag, noNeedToSetVars); + taosCheckAndSetDebugFlag(&mDebugFlag, "mDebugFlag", flag, noNeedToSetVars); + taosCheckAndSetDebugFlag(&wDebugFlag, "wDebugFlag", flag, noNeedToSetVars); + taosCheckAndSetDebugFlag(&sDebugFlag, "sDebugFlag", flag, noNeedToSetVars); + taosCheckAndSetDebugFlag(&tsdbDebugFlag, "tsdbDebugFlag", flag, noNeedToSetVars); + taosCheckAndSetDebugFlag(&tqDebugFlag, "tqDebugFlag", flag, noNeedToSetVars); + taosCheckAndSetDebugFlag(&fsDebugFlag, "fsDebugFlag", flag, noNeedToSetVars); + taosCheckAndSetDebugFlag(&udfDebugFlag, "udfDebugFlag", flag, noNeedToSetVars); + taosCheckAndSetDebugFlag(&smaDebugFlag, "smaDebugFlag", flag, noNeedToSetVars); + taosCheckAndSetDebugFlag(&idxDebugFlag, "idxDebugFlag", flag, noNeedToSetVars); + taosCheckAndSetDebugFlag(&tdbDebugFlag, "tdbDebugFlag", flag, noNeedToSetVars); + taosCheckAndSetDebugFlag(&metaDebugFlag, "metaDebugFlag", flag, noNeedToSetVars); + taosCheckAndSetDebugFlag(&stDebugFlag, "stDebugFlag", flag, noNeedToSetVars); + taosCheckAndSetDebugFlag(&sndDebugFlag, "sndDebugFlag", flag, noNeedToSetVars); taosArrayClear(noNeedToSetVars); // reset array diff --git a/source/common/src/trow.c b/source/common/src/trow.c index 626d1141e0..2b95e96130 100644 --- a/source/common/src/trow.c +++ b/source/common/src/trow.c @@ -354,8 +354,10 @@ bool tdSKvRowGetVal(STSRow *pRow, col_id_t colId, col_id_t colIdx, SCellVal *pVa } void *pBitmap = tdGetBitmapAddrKv(pRow, tdRowGetNCols(pRow)); - (void)tdGetKvRowValOfCol(pVal, pRow, pBitmap, pColIdx->offset, - POINTER_DISTANCE(pColIdx, TD_ROW_COL_IDX(pRow)) / sizeof(SKvRowIdx)); + if (tdGetKvRowValOfCol(pVal, pRow, pBitmap, pColIdx->offset, + POINTER_DISTANCE(pColIdx, TD_ROW_COL_IDX(pRow)) / sizeof(SKvRowIdx)) != TSDB_CODE_SUCCESS) { + return false; + } return true; } diff --git a/source/common/src/ttime.c b/source/common/src/ttime.c index 7e8749ef8b..98e46ab672 100644 --- a/source/common/src/ttime.c +++ b/source/common/src/ttime.c @@ -30,7 +30,9 @@ static int64_t m_deltaUtc = 0; void deltaToUtcInitOnce() { struct tm tm = {0}; - (void)taosStrpTime("1970-01-01 00:00:00", (const char*)("%Y-%m-%d %H:%M:%S"), &tm); + if (taosStrpTime("1970-01-01 00:00:00", (const char*)("%Y-%m-%d %H:%M:%S"), &tm) != 0) { + uError("failed to parse time string"); + } m_deltaUtc = (int64_t)taosMktime(&tm); // printf("====delta:%lld\n\n", seconds); } @@ -689,10 +691,10 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) { int64_t numOfMonth = (unit == 'y') ? duration * 12 : duration; int64_t fraction = t % TSDB_TICK_PER_SECOND(precision); - struct tm tm; - time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision)); - (void)taosLocalTime(&tt, &tm, NULL); - int32_t mon = tm.tm_year * 12 + tm.tm_mon + (int32_t)numOfMonth; + struct tm tm; + time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision)); + struct tm* ptm = taosLocalTime(&tt, &tm, NULL); + int32_t mon = tm.tm_year * 12 + tm.tm_mon + (int32_t)numOfMonth; tm.tm_year = mon / 12; tm.tm_mon = mon % 12; int daysOfMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; @@ -750,13 +752,13 @@ int32_t taosTimeCountIntervalForFill(int64_t skey, int64_t ekey, int64_t interva skey /= (int64_t)(TSDB_TICK_PER_SECOND(precision)); ekey /= (int64_t)(TSDB_TICK_PER_SECOND(precision)); - struct tm tm; - time_t t = (time_t)skey; - (void)taosLocalTime(&t, &tm, NULL); - int32_t smon = tm.tm_year * 12 + tm.tm_mon; + struct tm tm; + time_t t = (time_t)skey; + struct tm* ptm = taosLocalTime(&t, &tm, NULL); + int32_t smon = tm.tm_year * 12 + tm.tm_mon; t = (time_t)ekey; - (void)taosLocalTime(&t, &tm, NULL); + ptm = taosLocalTime(&t, &tm, NULL); int32_t emon = tm.tm_year * 12 + tm.tm_mon; if (unit == 'y') { @@ -778,9 +780,9 @@ int64_t taosTimeTruncate(int64_t ts, const SInterval* pInterval) { if (IS_CALENDAR_TIME_DURATION(pInterval->slidingUnit)) { start /= (int64_t)(TSDB_TICK_PER_SECOND(precision)); - struct tm tm; - time_t tt = (time_t)start; - (void)taosLocalTime(&tt, &tm, NULL); + struct tm tm; + time_t tt = (time_t)start; + struct tm* ptm = taosLocalTime(&tt, &tm, NULL); tm.tm_sec = 0; tm.tm_min = 0; tm.tm_hour = 0; diff --git a/source/libs/index/inc/indexUtil.h b/source/libs/index/inc/indexUtil.h index 61c16e1217..9eb8001d17 100644 --- a/source/libs/index/inc/indexUtil.h +++ b/source/libs/index/inc/indexUtil.h @@ -21,29 +21,29 @@ extern "C" { #endif -#define SERIALIZE_MEM_TO_BUF(buf, key, mem) \ - do { \ - TAOS_UNUSED(memcpy((void *)buf, (void *)(&key->mem), sizeof(key->mem))); \ - buf += sizeof(key->mem); \ +#define SERIALIZE_MEM_TO_BUF(buf, key, mem) \ + do { \ + (void)memcpy((void *)buf, (void *)(&key->mem), sizeof(key->mem)); \ + buf += sizeof(key->mem); \ } while (0) -#define SERIALIZE_STR_MEM_TO_BUF(buf, key, mem, len) \ - do { \ - TAOS_UNUSED(memcpy((void *)buf, (void *)key->mem, len)); \ - buf += len; \ +#define SERIALIZE_STR_MEM_TO_BUF(buf, key, mem, len) \ + do { \ + (void)memcpy((void *)buf, (void *)key->mem, len); \ + buf += len; \ } while (0) -#define SERIALIZE_VAR_TO_BUF(buf, var, type) \ - do { \ - type c = var; \ - TAOS_UNUSED(memcpy((void *)buf, (void *)&c, sizeof(c))); \ - buf += sizeof(c); \ +#define SERIALIZE_VAR_TO_BUF(buf, var, type) \ + do { \ + type c = var; \ + (void)memcpy((void *)buf, (void *)&c, sizeof(c)); \ + buf += sizeof(c); \ } while (0) -#define SERIALIZE_STR_VAR_TO_BUF(buf, var, len) \ - do { \ - TAOS_UNUSED(memcpy((void *)buf, (void *)var, len)); \ - buf += len; \ +#define SERIALIZE_STR_VAR_TO_BUF(buf, var, len) \ + do { \ + (void)memcpy((void *)buf, (void *)var, len); \ + buf += len; \ } while (0) #define INDEX_MERGE_ADD_DEL(src, dst, tgt) \ diff --git a/source/libs/stream/src/streamBackendRocksdb.c b/source/libs/stream/src/streamBackendRocksdb.c index 9c3a94e7dc..d55bf19c87 100644 --- a/source/libs/stream/src/streamBackendRocksdb.c +++ b/source/libs/stream/src/streamBackendRocksdb.c @@ -427,7 +427,9 @@ void cleanDir(const char* pPath, const char* id) { if (taosIsDir(pPath)) { taosRemoveDir(pPath); - TAOS_UNUSED(taosMkDir(pPath)); + if (taosMkDir(pPath) != 0) { + stError("%s failed to create dir:%s", id, pPath); + } stInfo("%s clear dir:%s, succ", id, pPath); } } @@ -833,8 +835,12 @@ int32_t streamBackendInit(const char* streamPath, int64_t chkpId, int32_t vgId, pHandle->list = tdListNew(sizeof(SCfComparator)); TSDB_CHECK_NULL(pHandle->list, code, lino, _EXIT, terrno); - TAOS_UNUSED(taosThreadMutexInit(&pHandle->mutex, NULL)); - TAOS_UNUSED(taosThreadMutexInit(&pHandle->cfMutex, NULL)); + code = taosThreadMutexInit(&pHandle->mutex, NULL); + TSDB_CHECK_CODE(code, lino, _EXIT); + + code = taosThreadMutexInit(&pHandle->cfMutex, NULL); + TSDB_CHECK_CODE(code, lino, _EXIT); + pHandle->cfInst = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); TSDB_CHECK_NULL(pHandle->cfInst, code, lino, _EXIT, terrno); @@ -2583,7 +2589,9 @@ STaskDbWrapper* taskDbOpenImpl(const char* key, char* statePath, char* dbPath) { pTaskDb->idstr = key ? taosStrdup(key) : NULL; pTaskDb->path = statePath ? taosStrdup(statePath) : NULL; - TAOS_UNUSED(taosThreadMutexInit(&pTaskDb->mutex, NULL)); + code = taosThreadMutexInit(&pTaskDb->mutex, NULL); + TSDB_CHECK_CODE(code, lino, _EXIT); + taskDbInitChkpOpt(pTaskDb); taskDbInitOpt(pTaskDb); diff --git a/source/libs/transport/src/thttp.c b/source/libs/transport/src/thttp.c index 4ac49e929c..3a90fae1ab 100644 --- a/source/libs/transport/src/thttp.c +++ b/source/libs/transport/src/thttp.c @@ -352,7 +352,9 @@ static void httpAsyncCb(uv_async_t* handle) { static int32_t BATCH_SIZE = 20; int32_t count = 0; - TAOS_UNUSED(taosThreadMutexLock(&item->mtx)); + if ((taosThreadMutexLock(&item->mtx)) != 0) { + tError("http-report failed to lock mutex"); + } httpMayDiscardMsg(http, item); while (!QUEUE_IS_EMPTY(&item->qmsg) && count++ < BATCH_SIZE) { @@ -360,7 +362,9 @@ static void httpAsyncCb(uv_async_t* handle) { QUEUE_REMOVE(h); QUEUE_PUSH(&wq, h); } - TAOS_UNUSED(taosThreadMutexUnlock(&item->mtx)); + if (taosThreadMutexUnlock(&item->mtx) != 0) { + tError("http-report failed to unlock mutex"); + } httpTrace(&wq); @@ -848,7 +852,9 @@ void taosDestroyHttpChan(int64_t chanId) { return; } - TAOS_UNUSED(taosThreadJoin(load->thread, NULL)); + if (taosThreadJoin(load->thread, NULL) != 0) { + tTrace("http-report failed to join thread, chanId %" PRId64 "", chanId); + } httpModuleDestroy(load); diff --git a/source/libs/transport/src/tmsgcb.c b/source/libs/transport/src/tmsgcb.c index 5685ac55ae..4c969003a9 100644 --- a/source/libs/transport/src/tmsgcb.c +++ b/source/libs/transport/src/tmsgcb.c @@ -59,7 +59,9 @@ int32_t tmsgSendSyncReq(const SEpSet* epSet, SRpcMsg* pMsg) { void tmsgSendRsp(SRpcMsg* pMsg) { #if 1 - (void)rpcSendResponse(pMsg); + if (rpcSendResponse(pMsg) != 0) { + tError("failed to send response"); + } #else return (*defaultMsgCb.sendRspFp)(pMsg); #endif diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c index 9ba1c3d677..394083a3bd 100644 --- a/source/libs/transport/src/trans.c +++ b/source/libs/transport/src/trans.c @@ -113,7 +113,7 @@ void* rpcOpen(const SRpcInit* pInit) { } int64_t refId = transAddExHandle(transGetInstMgt(), pRpc); - (void)transAcquireExHandle(transGetInstMgt(), refId); + void* tmp = transAcquireExHandle(transGetInstMgt(), refId); pRpc->refId = refId; return (void*)refId; _end: @@ -127,8 +127,13 @@ void rpcClose(void* arg) { if (arg == NULL) { return; } - (void)transRemoveExHandle(transGetInstMgt(), (int64_t)arg); - (void)transReleaseExHandle(transGetInstMgt(), (int64_t)arg); + if (transRemoveExHandle(transGetInstMgt(), (int64_t)arg) != 0) { + tError("failed to remove rpc handle"); + } + + if (transReleaseExHandle(transGetInstMgt(), (int64_t)arg) != 0) { + tError("failed to release rpc handle"); + } tInfo("end to close rpc"); return; } diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 30582594ba..ea77dbf432 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -2107,9 +2107,15 @@ static void cliAsyncCb(uv_async_t* handle) { // batch process to avoid to lock/unlock frequently queue wq; - TAOS_UNUSED(taosThreadMutexLock(&item->mtx)); + if (taosThreadMutexLock(&item->mtx) != 0) { + tError("failed to lock mutex, reason:%s", tstrerror(terrno)); + } + QUEUE_MOVE(&item->qmsg, &wq); - TAOS_UNUSED(taosThreadMutexUnlock(&item->mtx)); + + if (taosThreadMutexUnlock(&item->mtx) != 0) { + tError("failed to unlock mutex, reason:%s", tstrerror(terrno)); + } int8_t supportBatch = pTransInst->supportBatch; if (supportBatch == 0) { @@ -2299,7 +2305,9 @@ static int32_t createThrdObj(void* trans, SCliThrd** ppThrd) { } QUEUE_INIT(&pThrd->msg); - TAOS_UNUSED(taosThreadMutexInit(&pThrd->msgMtx, NULL)); + if (taosThreadMutexInit(&pThrd->msgMtx, NULL) != 0) { + TAOS_CHECK_GOTO(terrno, NULL, _end); + } pThrd->loop = (uv_loop_t*)taosMemoryMalloc(sizeof(uv_loop_t)); if (pThrd->loop == NULL) { @@ -2406,7 +2414,10 @@ static void destroyThrdObj(SCliThrd* pThrd) { return; } - TAOS_UNUSED(taosThreadJoin(pThrd->thread, NULL)); + if (taosThreadJoin(pThrd->thread, NULL) != 0) { + tTrace("failed to join thread, reason:%s", tstrerror(terrno)); + } + CLI_RELEASE_UV(pThrd->loop); TAOS_UNUSED(taosThreadMutexDestroy(&pThrd->msgMtx)); TRANS_DESTROY_ASYNC_POOL_MSG(pThrd->asyncPool, SCliMsg, destroyCmsgWrapper, (void*)pThrd); @@ -3358,8 +3369,13 @@ _exception: transReleaseExHandle(transGetInstMgt(), (int64_t)shandle); if (code != 0) { if (transpointId != 0) { - (void)transReleaseExHandle(transGetRefMgt(), transpointId); - (void)transRemoveExHandle(transGetRefMgt(), transpointId); + if (transReleaseExHandle(transGetRefMgt(), transpointId) != 0) { + tError("failed to release refId %" PRId64 "", transpointId); + } + + if (transRemoveExHandle(transGetRefMgt(), transpointId) != 0) { + tError("failed to remove refId %" PRId64 "", transpointId); + } } taosMemoryFree(pCli); } diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index e1371fbffa..77f7765627 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -272,7 +272,11 @@ int32_t transAsyncPoolCreate(uv_loop_t* loop, int sz, void* arg, AsyncCB cb, SAs } item->pThrd = arg; QUEUE_INIT(&item->qmsg); - TAOS_UNUSED(taosThreadMutexInit(&item->mtx, NULL)); + code = taosThreadMutexInit(&item->mtx, NULL); + if (code) { + taosMemoryFree(item); + break; + } async->data = item; err = uv_async_init(loop, async, cb); @@ -328,7 +332,10 @@ int transAsyncSend(SAsyncPool* pool, queue* q) { uv_async_t* async = &(pool->asyncs[idx]); SAsyncItem* item = async->data; - TAOS_UNUSED(taosThreadMutexLock(&item->mtx)); + if (taosThreadMutexLock(&item->mtx) != 0) { + tError("failed to lock mutex"); + } + QUEUE_PUSH(&item->qmsg, q); TAOS_UNUSED(taosThreadMutexUnlock(&item->mtx)); int ret = uv_async_send(async); diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index f8f8878f86..1f1cc7bb35 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -759,9 +759,15 @@ void uvWorkerAsyncCb(uv_async_t* handle) { queue wq; // batch process to avoid to lock/unlock frequently - TAOS_UNUSED(taosThreadMutexLock(&item->mtx)); + if (taosThreadMutexLock(&item->mtx) != 0) { + tError("failed to lock mutex"); + } + QUEUE_MOVE(&item->qmsg, &wq); - TAOS_UNUSED(taosThreadMutexUnlock(&item->mtx)); + + if (taosThreadMutexUnlock(&item->mtx) != 0) { + tError("failed to unlock mutex"); + } while (!QUEUE_IS_EMPTY(&wq)) { queue* head = QUEUE_HEAD(&wq); @@ -1637,7 +1643,10 @@ void destroyWorkThrd(SWorkThrd* pThrd) { } if (pThrd->inited) { sendQuitToWorkThrd(pThrd); - TAOS_UNUSED(taosThreadJoin(pThrd->thread, NULL)); + if ((taosThreadJoin(pThrd->thread, NULL)) != 0) { + tError("failed to join work-thread"); + } + SRV_RELEASE_UV(pThrd->loop); TRANS_DESTROY_ASYNC_POOL_MSG(pThrd->asyncPool, SSvrMsg, destroySmsgWrapper, NULL); } @@ -1657,7 +1666,9 @@ void transCloseServer(void* arg) { if (srv->inited) { tDebug("send quit msg to accept thread"); TAOS_UNUSED(uv_async_send(srv->pAcceptAsync)); - TAOS_UNUSED(taosThreadJoin(srv->thread, NULL)); + if (taosThreadJoin(srv->thread, NULL) != 0) { + tError("failed to join accept-thread"); + } SRV_RELEASE_UV(srv->loop); for (int i = 0; i < srv->numOfThreads; i++) { diff --git a/source/libs/wal/src/walMgmt.c b/source/libs/wal/src/walMgmt.c index 2d9ca4cce3..3b23a2db80 100644 --- a/source/libs/wal/src/walMgmt.c +++ b/source/libs/wal/src/walMgmt.c @@ -104,7 +104,7 @@ SWal *walOpen(const char *path, SWalCfg *pCfg) { } // set config - TAOS_UNUSED(memcpy(&pWal->cfg, pCfg, sizeof(SWalCfg))); + (void)memcpy(&pWal->cfg, pCfg, sizeof(SWalCfg)); pWal->fsyncSeq = pCfg->fsyncPeriod / 1000; if (pWal->cfg.retentionSize > 0) { @@ -155,7 +155,7 @@ SWal *walOpen(const char *path, SWalCfg *pCfg) { pWal->lastRollSeq = -1; // init write buffer - TAOS_UNUSED(memset(&pWal->writeHead, 0, sizeof(SWalCkHead))); + (void)memset(&pWal->writeHead, 0, sizeof(SWalCkHead)); pWal->writeHead.head.protoVer = WAL_PROTO_VER; pWal->writeHead.magic = WAL_MAGIC; diff --git a/source/libs/wal/src/walRead.c b/source/libs/wal/src/walRead.c index 9cf5bcbf09..d3df76f687 100644 --- a/source/libs/wal/src/walRead.c +++ b/source/libs/wal/src/walRead.c @@ -41,7 +41,11 @@ SWalReader *walOpenReader(SWal *pWal, SWalFilterCond *cond, int64_t id) { pReader->cond.enableRef = 0; } - TAOS_UNUSED(taosThreadMutexInit(&pReader->mutex, NULL)); + terrno = taosThreadMutexInit(&pReader->mutex, NULL); + if (terrno) { + taosMemoryFree(pReader); + return NULL; + } pReader->pHead = taosMemoryMalloc(sizeof(SWalCkHead)); if (pReader->pHead == NULL) { @@ -401,7 +405,9 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) { TAOS_RETURN(TSDB_CODE_WAL_LOG_NOT_EXIST); } - TAOS_UNUSED(taosThreadMutexLock(&pReader->mutex)); + if (taosThreadMutexLock(&pReader->mutex) != 0) { + wError("vgId:%d, failed to lock mutex", pReader->pWal->cfg.vgId); + } if (pReader->curVersion != ver) { code = walReaderSeekVer(pReader, ver); @@ -537,7 +543,7 @@ int32_t decryptBody(SWalCfg *cfg, SWalCkHead *pHead, int32_t plainBodyLen, const // wDebug("CBC_Decrypt cryptedBodyLen:%d, plainBodyLen:%d, %s", count, plainBodyLen, func); - TAOS_UNUSED(memcpy(pHead->head.body, newBody, plainBodyLen)); + (void)memcpy(pHead->head.body, newBody, plainBodyLen); taosMemoryFree(newBody); } @@ -546,7 +552,10 @@ int32_t decryptBody(SWalCfg *cfg, SWalCkHead *pHead, int32_t plainBodyLen, const } void walReadReset(SWalReader *pReader) { - TAOS_UNUSED(taosThreadMutexLock(&pReader->mutex)); + if ((taosThreadMutexLock(&pReader->mutex)) != 0) { + wError("vgId:%d, failed to lock mutex", pReader->pWal->cfg.vgId); + } + TAOS_UNUSED(taosCloseFile(&pReader->pIdxFile)); TAOS_UNUSED(taosCloseFile(&pReader->pLogFile)); pReader->curFileFirstVer = -1; diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c index bb6dbbeeb6..b89c233465 100644 --- a/source/libs/wal/src/walWrite.c +++ b/source/libs/wal/src/walWrite.c @@ -185,10 +185,14 @@ int32_t walRollback(SWal *pWal, int64_t ver) { walBuildLogName(pWal, pInfo->firstVer, fnameStr); wDebug("vgId:%d, wal remove file %s for rollback", pWal->cfg.vgId, fnameStr); - TAOS_UNUSED(taosRemoveFile(fnameStr)); + if (taosRemoveFile(fnameStr) != 0) { + wWarn("vgId:%d, failed to remove file %s for rollback since %s", pWal->cfg.vgId, fnameStr, terrstr()); + } walBuildIdxName(pWal, pInfo->firstVer, fnameStr); wDebug("vgId:%d, wal remove file %s for rollback", pWal->cfg.vgId, fnameStr); - TAOS_UNUSED(taosRemoveFile(fnameStr)); + if (taosRemoveFile(fnameStr) != 0) { + wWarn("vgId:%d, failed to remove file %s for rollback since %s", pWal->cfg.vgId, fnameStr, terrstr()); + } } } @@ -460,7 +464,9 @@ int32_t walEndSnapshot(SWal *pWal) { } for (SWalFileInfo *iter = pWal->fileInfoSet->pData; iter <= pUntil; iter++) { deleteCnt++; - TAOS_UNUSED(taosArrayPush(pWal->toDeleteFiles, iter)); + if (taosArrayPush(pWal->toDeleteFiles, iter) == NULL) { + wError("vgId:%d, failed to push file info to delete list", pWal->cfg.vgId); + } } // make new array, remove files @@ -603,8 +609,8 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy TAOS_CHECK_GOTO(terrno, &lino, _exit); } - TAOS_UNUSED(memset(newBody, 0, cyptedBodyLen)); - TAOS_UNUSED(memcpy(newBody, body, plainBodyLen)); + (void)memset(newBody, 0, cyptedBodyLen); + (void)memcpy(newBody, body, plainBodyLen); newBodyEncrypted = taosMemoryMalloc(cyptedBodyLen); if (newBodyEncrypted == NULL) {