diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 30c11c09ce..57a7453eac 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -390,7 +390,7 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg return NULL; } - tSerializeSCreateVnodeReq(pReq, contLen, &createReq); + (void)tSerializeSCreateVnodeReq(pReq, contLen, &createReq); *pContLen = contLen; return pReq; } @@ -436,7 +436,7 @@ static void *mndBuildAlterVnodeConfigReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pV pHead->contLen = htonl(contLen); pHead->vgId = htonl(pVgroup->vgId); - tSerializeSAlterVnodeConfigReq((char *)pReq + sizeof(SMsgHead), contLen, &alterReq); + (void)tSerializeSAlterVnodeConfigReq((char *)pReq + sizeof(SMsgHead), contLen, &alterReq); *pContLen = contLen; return pReq; } @@ -514,7 +514,7 @@ static void *mndBuildAlterVnodeReplicaReq(SMnode *pMnode, SDbObj *pDb, SVgObj *p return NULL; } - tSerializeSAlterVnodeReplicaReq(pReq, contLen, &alterReq); + (void)tSerializeSAlterVnodeReplicaReq(pReq, contLen, &alterReq); *pContLen = contLen; return pReq; } @@ -587,7 +587,7 @@ static void *mndBuildCheckLearnCatchupReq(SMnode *pMnode, SDbObj *pDb, SVgObj *p return NULL; } - tSerializeSAlterVnodeReplicaReq(pReq, contLen, &req); + (void)tSerializeSAlterVnodeReplicaReq(pReq, contLen, &req); *pContLen = contLen; return pReq; } @@ -611,7 +611,7 @@ static void *mndBuildDisableVnodeWriteReq(SMnode *pMnode, SDbObj *pDb, int32_t v return NULL; } - tSerializeSDisableVnodeWriteReq(pReq, contLen, &disableReq); + (void)tSerializeSDisableVnodeWriteReq(pReq, contLen, &disableReq); *pContLen = contLen; return pReq; } @@ -639,7 +639,7 @@ static void *mndBuildAlterVnodeHashRangeReq(SMnode *pMnode, int32_t srcVgId, SVg return NULL; } - tSerializeSAlterVnodeHashRangeReq(pReq, contLen, &alterReq); + (void)tSerializeSAlterVnodeHashRangeReq(pReq, contLen, &alterReq); *pContLen = contLen; return pReq; } @@ -664,7 +664,7 @@ void *mndBuildDropVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVgOb return NULL; } - tSerializeSDropVnodeReq(pReq, contLen, &dropReq); + (void)tSerializeSDropVnodeReq(pReq, contLen, &dropReq); *pContLen = contLen; return pReq; } @@ -699,7 +699,7 @@ static bool mndBuildDnodesArrayFp(SMnode *pMnode, void *pObj, void *p1, void *p2 } if (online && pDnode->numOfSupportVnodes > 0) { - taosArrayPush(pArray, pDnode); + if (taosArrayPush(pArray, pDnode) == NULL) return false; } return true; } @@ -907,7 +907,7 @@ SEpSet mndGetVgroupEpset(SMnode *pMnode, const SVgObj *pVgroup) { epset.inUse = epset.numOfEps; } - addEpIntoEpSet(&epset, pDnode->fqdn, pDnode->port); + (void)addEpIntoEpSet(&epset, pDnode->fqdn, pDnode->port); mndReleaseDnode(pMnode, pDnode); } epsetSort(&epset); @@ -930,7 +930,7 @@ SEpSet mndGetVgroupEpsetById(SMnode *pMnode, int32_t vgId) { epset.inUse = epset.numOfEps; } - addEpIntoEpSet(&epset, pDnode->fqdn, pDnode->port); + (void)addEpIntoEpSet(&epset, pDnode->fqdn, pDnode->port); mndReleaseDnode(pMnode, pDnode); } @@ -965,26 +965,26 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p cols = 0; SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->vgId, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->vgId, false); SName name = {0}; char db[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; - tNameFromString(&name, pVgroup->dbName, T_NAME_ACCT | T_NAME_DB); - tNameGetDbName(&name, varDataVal(db)); + (void)tNameFromString(&name, pVgroup->dbName, T_NAME_ACCT | T_NAME_DB); + (void)tNameGetDbName(&name, varDataVal(db)); varDataSetLen(db, strlen(varDataVal(db))); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)db, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)db, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->numOfTables, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->numOfTables, false); // default 3 replica, add 1 replica if move vnode for (int32_t i = 0; i < 4; ++i) { pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); if (i < pVgroup->replica) { int16_t dnodeId = (int16_t)pVgroup->vnodeGid[i].dnodeId; - colDataSetVal(pColInfo, numOfRows, (const char *)&dnodeId, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&dnodeId, false); bool exist = false; bool online = false; @@ -1038,7 +1038,7 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p STR_WITH_MAXSIZE_TO_VARSTR(buf1, role, pShow->pMeta->pSchemas[cols].bytes); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)buf1, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)buf1, false); } else { colDataSetNULL(pColInfo, numOfRows); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); @@ -1048,19 +1048,19 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); int32_t cacheUsage = (int32_t)pVgroup->cacheUsage; - colDataSetVal(pColInfo, numOfRows, (const char *)&cacheUsage, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&cacheUsage, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->numOfCachedTables, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->numOfCachedTables, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->isTsma, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->isTsma, false); // pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); // if (pDb == NULL || pDb->compactStartTime <= 0) { // colDataSetNULL(pColInfo, numOfRows); // } else { - // colDataSetVal(pColInfo, numOfRows, (const char *)&pDb->compactStartTime, false); + // (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pDb->compactStartTime, false); // } numOfRows++; @@ -1158,10 +1158,10 @@ static int32_t mndRetrieveVnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB cols = 0; pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pGid->dnodeId, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pGid->dnodeId, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->vgId, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->vgId, false); // db_name const char *dbname = mndGetDbStr(pVgroup->dbName); @@ -1172,7 +1172,7 @@ static int32_t mndRetrieveVnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB STR_WITH_MAXSIZE_TO_VARSTR(b1, "NULL", TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE); } pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)b1, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)b1, false); // dnode is online? SDnodeObj *pDnode = mndAcquireDnode(pMnode, pGid->dnodeId); @@ -1186,18 +1186,18 @@ static int32_t mndRetrieveVnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB ESyncState syncState = (isDnodeOnline) ? pGid->syncState : TAOS_SYNC_STATE_OFFLINE; STR_TO_VARSTR(buf, syncStr(syncState)); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)buf, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)buf, false); int64_t roleTimeMs = (isDnodeOnline) ? pGid->roleTimeMs : 0; pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&roleTimeMs, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&roleTimeMs, false); int64_t startTimeMs = (isDnodeOnline) ? pGid->startTimeMs : 0; pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&startTimeMs, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&startTimeMs, false); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); - colDataSetVal(pColInfo, numOfRows, (const char *)&pGid->syncRestore, false); + (void)colDataSetVal(pColInfo, numOfRows, (const char *)&pGid->syncRestore, false); numOfRows++; sdbRelease(pSdb, pDnode); @@ -2452,7 +2452,7 @@ static void *mndBuildSForceBecomeFollowerReq(SMnode *pMnode, SVgObj *pVgroup, in pHead->contLen = htonl(contLen); pHead->vgId = htonl(pVgroup->vgId); - tSerializeSForceBecomeFollowerReq((char *)pReq + sizeof(SMsgHead), contLen, &balanceReq); + (void)tSerializeSForceBecomeFollowerReq((char *)pReq + sizeof(SMsgHead), contLen, &balanceReq); *pContLen = contLen; return pReq; } @@ -3366,7 +3366,7 @@ static void *mndBuildCompactVnodeReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgrou pHead->contLen = htonl(contLen); pHead->vgId = htonl(pVgroup->vgId); - tSerializeSCompactVnodeReq((char *)pReq + sizeof(SMsgHead), contLen, &compactReq); + (void)tSerializeSCompactVnodeReq((char *)pReq + sizeof(SMsgHead), contLen, &compactReq); *pContLen = contLen; return pReq; } diff --git a/source/dnode/mnode/sdb/src/sdb.c b/source/dnode/mnode/sdb/src/sdb.c index c1d4ba7893..7244f2d7c9 100644 --- a/source/dnode/mnode/sdb/src/sdb.c +++ b/source/dnode/mnode/sdb/src/sdb.c @@ -46,7 +46,7 @@ SSdb *sdbInit(SSdbOpt *pOption) { } for (ESdbType i = 0; i < SDB_MAX; ++i) { - taosThreadRwlockInit(&pSdb->locks[i], NULL); + (void)taosThreadRwlockInit(&pSdb->locks[i], NULL); pSdb->maxId[i] = 0; pSdb->tableVer[i] = 0; pSdb->keyTypes[i] = SDB_KEY_INT32; @@ -60,7 +60,7 @@ SSdb *sdbInit(SSdbOpt *pOption) { pSdb->commitTerm = -1; pSdb->commitConfig = -1; pSdb->pMnode = pOption->pMnode; - taosThreadMutexInit(&pSdb->filelock, NULL); + (void)taosThreadMutexInit(&pSdb->filelock, NULL); mInfo("sdb init success"); return pSdb; } @@ -68,7 +68,7 @@ SSdb *sdbInit(SSdbOpt *pOption) { void sdbCleanup(SSdb *pSdb) { mInfo("start to cleanup sdb"); - sdbWriteFile(pSdb, 0); + (void)sdbWriteFile(pSdb, 0); if (pSdb->currDir != NULL) { taosMemoryFreeClear(pSdb->currDir); @@ -99,14 +99,14 @@ void sdbCleanup(SSdb *pSdb) { taosHashClear(hash); taosHashCleanup(hash); - taosThreadRwlockDestroy(&pSdb->locks[i]); + (void)taosThreadRwlockDestroy(&pSdb->locks[i]); pSdb->hashObjs[i] = NULL; memset(&pSdb->locks[i], 0, sizeof(pSdb->locks[i])); mInfo("sdb table:%s is cleaned up", sdbTableName(i)); } - taosThreadMutexDestroy(&pSdb->filelock); + (void)taosThreadMutexDestroy(&pSdb->filelock); taosMemoryFree(pSdb); mInfo("sdb is cleaned up"); } @@ -188,19 +188,19 @@ void sdbGetCommitInfo(SSdb *pSdb, int64_t *index, int64_t *term, int64_t *config void sdbWriteLock(SSdb *pSdb, int32_t type) { TdThreadRwlock *pLock = &pSdb->locks[type]; // mTrace("sdb table:%d start write lock:%p", type, pLock); - taosThreadRwlockWrlock(pLock); + (void)taosThreadRwlockWrlock(pLock); // mTrace("sdb table:%d stop write lock:%p", type, pLock); } void sdbReadLock(SSdb *pSdb, int32_t type) { TdThreadRwlock *pLock = &pSdb->locks[type]; // mTrace("sdb table:%d start read lock:%p", type, pLock); - taosThreadRwlockRdlock(pLock); + (void)taosThreadRwlockRdlock(pLock); // mTrace("sdb table:%d stop read lock:%p", type, pLock); } void sdbUnLock(SSdb *pSdb, int32_t type) { TdThreadRwlock *pLock = &pSdb->locks[type]; // mTrace("sdb table:%d unlock:%p", type, pLock); - taosThreadRwlockUnlock(pLock); + (void)taosThreadRwlockUnlock(pLock); } diff --git a/source/dnode/mnode/sdb/src/sdbFile.c b/source/dnode/mnode/sdb/src/sdbFile.c index 0952fbe7a3..6fb395e63f 100644 --- a/source/dnode/mnode/sdb/src/sdbFile.c +++ b/source/dnode/mnode/sdb/src/sdbFile.c @@ -258,7 +258,7 @@ static int32_t sdbReadFileImp(SSdb *pSdb) { if (code != 0) { mError("failed to read sdb file:%s head since %s", file, tstrerror(code)); taosMemoryFree(pRaw); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); return -1; } @@ -361,14 +361,14 @@ static int32_t sdbReadFileImp(SSdb *pSdb) { pSdb->commitTerm, pSdb->commitConfig); _OVER: - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); sdbFreeRaw(pRaw); TAOS_RETURN(code); } int32_t sdbReadFile(SSdb *pSdb) { - taosThreadMutexLock(&pSdb->filelock); + (void)taosThreadMutexLock(&pSdb->filelock); sdbResetData(pSdb); int32_t code = sdbReadFileImp(pSdb); @@ -377,7 +377,7 @@ int32_t sdbReadFile(SSdb *pSdb) { sdbResetData(pSdb); } - taosThreadMutexUnlock(&pSdb->filelock); + (void)taosThreadMutexUnlock(&pSdb->filelock); return code; } @@ -404,7 +404,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) { code = sdbWriteFileHead(pSdb, pFile); if (code != 0) { mError("failed to write sdb file:%s head since %s", tmpfile, tstrerror(code)); - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); return -1; } @@ -507,7 +507,9 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) { } } - taosCloseFile(&pFile); + if (taosCloseFile(&pFile) != 0) { + code = taosRenameFile(tmpfile, curfile); + } if (code == 0) { code = taosRenameFile(tmpfile, curfile); @@ -541,7 +543,7 @@ int32_t sdbWriteFile(SSdb *pSdb, int32_t delta) { return 0; } - taosThreadMutexLock(&pSdb->filelock); + (void)taosThreadMutexLock(&pSdb->filelock); if (pSdb->pWal != NULL) { if (pSdb->sync > 0) { code = syncBeginSnapshot(pSdb->sync, pSdb->applyIndex); @@ -560,7 +562,7 @@ int32_t sdbWriteFile(SSdb *pSdb, int32_t delta) { if (code != 0) { mError("failed to write sdb file since %s", tstrerror(code)); } - taosThreadMutexUnlock(&pSdb->filelock); + (void)taosThreadMutexUnlock(&pSdb->filelock); return code; } @@ -602,7 +604,7 @@ static void sdbCloseIter(SSdbIter *pIter) { if (pIter == NULL) return; if (pIter->file != NULL) { - taosCloseFile(&pIter->file); + (void)taosCloseFile(&pIter->file); pIter->file = NULL; } @@ -624,18 +626,18 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter, int64_t *index, int64_t *ter char datafile[PATH_MAX] = {0}; snprintf(datafile, sizeof(datafile), "%s%ssdb.data", pSdb->currDir, TD_DIRSEP); - taosThreadMutexLock(&pSdb->filelock); + (void)taosThreadMutexLock(&pSdb->filelock); int64_t commitIndex = pSdb->commitIndex; int64_t commitTerm = pSdb->commitTerm; int64_t commitConfig = pSdb->commitConfig; if (taosCopyFile(datafile, pIter->name) < 0) { - taosThreadMutexUnlock(&pSdb->filelock); + (void)taosThreadMutexUnlock(&pSdb->filelock); code = TAOS_SYSTEM_ERROR(errno); mError("failed to copy sdb file %s to %s since %s", datafile, pIter->name, tstrerror(code)); sdbCloseIter(pIter); TAOS_RETURN(code); } - taosThreadMutexUnlock(&pSdb->filelock); + (void)taosThreadMutexUnlock(&pSdb->filelock); pIter->file = taosOpenFile(pIter->name, TD_FILE_READ); if (pIter->file == NULL) { @@ -725,7 +727,10 @@ int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply, int64_t index, i goto _OVER; } - taosCloseFile(&pIter->file); + if (taosCloseFile(&pIter->file) != 0) { + code = TAOS_SYSTEM_ERROR(errno); + goto _OVER; + } pIter->file = NULL; char datafile[PATH_MAX] = {0}; diff --git a/source/dnode/mnode/sdb/src/sdbHash.c b/source/dnode/mnode/sdb/src/sdbHash.c index 4043ff6a12..03b45c25b4 100644 --- a/source/dnode/mnode/sdb/src/sdbHash.c +++ b/source/dnode/mnode/sdb/src/sdbHash.c @@ -176,7 +176,7 @@ static int32_t sdbInsertRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow * if (code != 0) { if (terrno == 0) terrno = TSDB_CODE_MND_TRANS_UNKNOW_ERROR; code = terrno; - taosHashRemove(hash, pRow->pObj, keySize); + (void)taosHashRemove(hash, pRow->pObj, keySize); sdbFreeRow(pSdb, pRow, false); terrno = code; sdbUnLock(pSdb, type); @@ -239,10 +239,10 @@ static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow * SSdbRow *pOldRow = *ppOldRow; pOldRow->status = pRaw->status; - atomic_add_fetch_32(&pOldRow->refCount, 1); + (void)atomic_add_fetch_32(&pOldRow->refCount, 1); sdbPrintOper(pSdb, pOldRow, "delete"); - taosHashRemove(hash, pOldRow->pObj, keySize); + TAOS_CHECK_RETURN(taosHashRemove(hash, pOldRow->pObj, keySize)); pSdb->tableVer[pOldRow->type]++; sdbUnLock(pSdb, type); @@ -309,7 +309,7 @@ void *sdbAcquireAll(SSdb *pSdb, ESdbType type, const void *pKey, bool onlyReady) SSdbRow *pRow = *ppRow; switch (pRow->status) { case SDB_STATUS_READY: - atomic_add_fetch_32(&pRow->refCount, 1); + (void)atomic_add_fetch_32(&pRow->refCount, 1); pRet = pRow->pObj; sdbPrintOper(pSdb, pRow, "acquire"); break; @@ -327,7 +327,7 @@ void *sdbAcquireAll(SSdb *pSdb, ESdbType type, const void *pKey, bool onlyReady) if (pRet == NULL) { if (!onlyReady) { terrno = 0; - atomic_add_fetch_32(&pRow->refCount, 1); + (void)atomic_add_fetch_32(&pRow->refCount, 1); pRet = pRow->pObj; sdbPrintOper(pSdb, pRow, "acquire"); } @@ -395,7 +395,7 @@ void *sdbFetch(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj) { continue; } - atomic_add_fetch_32(&pRow->refCount, 1); + (void)atomic_add_fetch_32(&pRow->refCount, 1); sdbPrintOper(pSdb, pRow, "fetch"); *ppObj = pRow->pObj; break; @@ -423,7 +423,7 @@ void *sdbFetchAll(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj, ESdbStat continue; } - atomic_add_fetch_32(&pRow->refCount, 1); + (void)atomic_add_fetch_32(&pRow->refCount, 1); sdbPrintOper(pSdb, pRow, "fetch"); *ppObj = pRow->pObj; *status = pRow->status; diff --git a/source/dnode/mnode/sdb/src/sdbRow.c b/source/dnode/mnode/sdb/src/sdbRow.c index c078e7eb21..da5a232851 100644 --- a/source/dnode/mnode/sdb/src/sdbRow.c +++ b/source/dnode/mnode/sdb/src/sdbRow.c @@ -42,7 +42,7 @@ void sdbFreeRow(SSdb *pSdb, SSdbRow *pRow, bool callFunc) { // remove attached object such as trans SdbDeleteFp deleteFp = pSdb->deleteFps[pRow->type]; if (deleteFp != NULL) { - (*deleteFp)(pSdb, pRow->pObj, callFunc); + (void)(*deleteFp)(pSdb, pRow->pObj, callFunc); } sdbPrintOper(pSdb, pRow, "free"); diff --git a/source/libs/tdb/inc/tdb.h b/source/libs/tdb/inc/tdb.h index d3a5711352..0935e87ab0 100644 --- a/source/libs/tdb/inc/tdb.h +++ b/source/libs/tdb/inc/tdb.h @@ -48,7 +48,7 @@ int32_t tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyC int8_t rollback); int32_t tdbTbClose(TTB *pTb); bool tdbTbExist(const char *tbname, TDB *pEnv); -int tdbTbDropByName(const char *tbname, TDB *pEnv, TXN* pTxn); +int tdbTbDropByName(const char *tbname, TDB *pEnv, TXN *pTxn); int32_t tdbTbDrop(TTB *pTb); int32_t tdbTbInsert(TTB *pTb, const void *pKey, int keyLen, const void *pVal, int valLen, TXN *pTxn); int32_t tdbTbDelete(TTB *pTb, const void *pKey, int kLen, TXN *pTxn); @@ -80,10 +80,10 @@ int32_t tdbTbcUpsert(TBC *pTbc, const void *pKey, int nKey, const void *pData, i int32_t tdbTxnOpen(TXN *pTxn, int64_t txnid, void *(*xMalloc)(void *, size_t), void (*xFree)(void *, void *), void *xArg, int flags); int32_t tdbTxnCloseImpl(TXN *pTxn); -#define tdbTxnClose(pTxn) \ - do { \ - tdbTxnCloseImpl(pTxn); \ - (pTxn) = NULL; \ +#define tdbTxnClose(pTxn) \ + do { \ + (void)tdbTxnCloseImpl(pTxn); \ + (pTxn) = NULL; \ } while (0) // other diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index f86ed69fc3..487ec1dac5 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -122,7 +122,7 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPg zArg.pBt = pBt; ret = tdbPagerFetchPage(pPager, &pgno, &pPage, tdbBtreeInitPage, &zArg, txn); if (ret < 0) { - tdbAbort(pEnv, txn); + (void)tdbAbort(pEnv, txn); tdbOsFree(pBt); return ret; } @@ -130,7 +130,7 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPg ret = tdbPagerWrite(pPager, pPage); if (ret < 0) { tdbError("failed to write page since %s", terrstr()); - tdbAbort(pEnv, txn); + (void)tdbAbort(pEnv, txn); tdbOsFree(pBt); return ret; } @@ -143,7 +143,7 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPg ret = tdbTbInsert(pPager->pEnv->pMainDb, tbname, strlen(tbname) + 1, &pBt->info, sizeof(pBt->info), txn); if (ret < 0) { - tdbAbort(pEnv, txn); + (void)tdbAbort(pEnv, txn); tdbOsFree(pBt); return ret; } @@ -194,14 +194,14 @@ int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, in int idx; int c; - tdbBtcOpen(&btc, pBt, pTxn); + (void)tdbBtcOpen(&btc, pBt, pTxn); tdbTrace("tdb insert, btc: %p, pTxn: %p", &btc, pTxn); // move to the position to insert ret = tdbBtcMoveTo(&btc, pKey, kLen, &c); if (ret < 0) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-insert: btc move to failed with ret: %d.", ret); return ret; } @@ -213,7 +213,7 @@ int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, in btc.idx++; } else if (c == 0) { // dup key not allowed with insert - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-insert: dup key. pKey: %p, kLen: %d, btc: %p, pTxn: %p", pKey, kLen, &btc, pTxn); return TSDB_CODE_DUP_KEY; } @@ -221,12 +221,12 @@ int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, in ret = tdbBtcUpsert(&btc, pKey, kLen, pVal, vLen, 1); if (ret < 0) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-insert: btc upsert failed with ret: %d.", ret); return ret; } - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); return 0; } @@ -246,20 +246,20 @@ int tdbBtreeDelete(SBTree *pBt, const void *pKey, int kLen, TXN *pTxn) { // move the cursor ret = tdbBtcMoveTo(&btc, pKey, kLen, &c); if (ret < 0) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-delete: btc move to failed with ret: %d.", ret); return ret; } if (btc.idx < 0 || c != 0) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); return TSDB_CODE_NOT_FOUND; } // delete the key ret = tdbBtcDelete(&btc); if (ret < 0) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); return ret; } /* @@ -274,7 +274,7 @@ int tdbBtreeDelete(SBTree *pBt, const void *pKey, int kLen, TXN *pTxn) { btc.coder.ofps = NULL; } */ - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); return 0; } @@ -343,20 +343,20 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL ret = tdbBtcMoveTo(&btc, pKey, kLen, &cret); if (ret < 0) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-pget: btc move to failed with ret: %d.", ret); return ret; } if (btc.idx < 0 || cret) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); return TSDB_CODE_NOT_FOUND; } pCell = tdbPageGetCell(btc.pPage, btc.idx); ret = tdbBtreeDecodeCell(btc.pPage, pCell, &cd, btc.pTxn, pBt); if (ret < 0) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-pget: decode cell failed with ret: %d.", ret); return ret; } @@ -364,7 +364,7 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL if (ppKey) { pTKey = tdbRealloc(*ppKey, cd.kLen); if (pTKey == NULL) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-pget: realloc pTKey failed."); return terrno; } @@ -376,7 +376,7 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL if (ppVal) { pTVal = tdbRealloc(*ppVal, cd.vLen); if (pTVal == NULL) { - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); tdbError("tdb/btree-pget: realloc pTVal failed."); return terrno; } @@ -397,7 +397,7 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL tdbTrace("tdb pget end, btc decoder: %p/0x%x, local decoder:%p", &btc.coder, btc.coder.freeKV, &cd); - tdbBtcClose(&btc); + (void)tdbBtcClose(&btc); return 0; } @@ -512,7 +512,7 @@ static int tdbBtreeBalanceDeeper(SBTree *pBt, SPage *pRoot, SPage **ppChild, TXN } // Copy the root page content to the child page - tdbPageCopy(pRoot, pChild, 0); + (void)tdbPageCopy(pRoot, pChild, 0); // Reinitialize the root page zArg.flags = TDB_BTREE_ROOT; @@ -602,7 +602,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx if (i < nOlds - 1) { ((SPgno *)pDivCell[i])[0] = ((SIntHdr *)pOlds[i]->pData)->pgno; ((SIntHdr *)pOlds[i]->pData)->pgno = 0; - tdbPageInsertCell(pOlds[i], TDB_PAGE_TOTAL_CELLS(pOlds[i]), pDivCell[i], szDivCell[i], 1); + (void)tdbPageInsertCell(pOlds[i], TDB_PAGE_TOTAL_CELLS(pOlds[i]), pDivCell[i], szDivCell[i], 1); } } rPgno = ((SIntHdr *)pOlds[nOlds - 1]->pData)->pgno; @@ -626,14 +626,14 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx } } - tdbPageDropCell(pParent, sIdx, pTxn, pBt); + (void)tdbPageDropCell(pParent, sIdx, pTxn, pBt); if (!childNotLeaf) { SArray *ofps = pParent->pPager->ofps; if (ofps) { for (int i = 0; i < TARRAY_SIZE(ofps); ++i) { SPage *ofp = *(SPage **)taosArrayGet(ofps, i); - tdbPagerInsertFreePage(pParent->pPager, ofp, pTxn); + (void)tdbPagerInsertFreePage(pParent->pPager, ofp, pTxn); } if (destroyOfps) { @@ -791,9 +791,9 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx iarg.pBt = pBt; iarg.flags = TDB_BTREE_PAGE_GET_FLAGS(pOlds[0]); for (int i = 0; i < nOlds; i++) { - tdbPageCreate(pOlds[0]->pageSize, &pOldsCopy[i], tdbDefaultMalloc, NULL); - tdbBtreeInitPage(pOldsCopy[i], &iarg, 0); - tdbPageCopy(pOlds[i], pOldsCopy[i], 0); + (void)tdbPageCreate(pOlds[0]->pageSize, &pOldsCopy[i], tdbDefaultMalloc, NULL); + (void)tdbBtreeInitPage(pOldsCopy[i], &iarg, 0); + (void)tdbPageCopy(pOlds[i], pOldsCopy[i], 0); pOlds[i]->nOverflow = 0; } @@ -818,7 +818,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx } if (nNewCells < infoNews[iNew].cnt) { - tdbPageInsertCell(pNews[iNew], nNewCells, pCell, szCell, 0); + (void)tdbPageInsertCell(pNews[iNew], nNewCells, pCell, szCell, 0); nNewCells++; // insert parent page @@ -835,9 +835,9 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx int szNewCell; SPgno pgno; pgno = TDB_PAGE_PGNO(pNews[iNew]); - tdbBtreeEncodeCell(pParent, cd.pKey, cd.kLen, (void *)&pgno, sizeof(SPgno), pNewCell, &szNewCell, pTxn, - pBt); - tdbPageInsertCell(pParent, sIdx++, pNewCell, szNewCell, 0); + (void)tdbBtreeEncodeCell(pParent, cd.pKey, cd.kLen, (void *)&pgno, sizeof(SPgno), pNewCell, &szNewCell, + pTxn, pBt); + (void)tdbPageInsertCell(pParent, sIdx++, pNewCell, szNewCell, 0); tdbOsFree(pNewCell); if (TDB_CELLDECODER_FREE_VAL(&cd)) { @@ -869,7 +869,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx return TSDB_CODE_FAILED; } ((SPgno *)pCell)[0] = TDB_PAGE_PGNO(pNews[iNew]); - tdbPageInsertCell(pParent, sIdx++, pCell, szCell, 0); + (void)tdbPageInsertCell(pParent, sIdx++, pCell, szCell, 0); // move to next new page iNew++; @@ -892,12 +892,12 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx pIntHdr->pgno = TDB_PAGE_PGNO(pNews[nNews - 1]); } else { ((SPgno *)pDivCell[nOlds - 1])[0] = TDB_PAGE_PGNO(pNews[nNews - 1]); - tdbPageInsertCell(pParent, sIdx, pDivCell[nOlds - 1], szDivCell[nOlds - 1], 0); + (void)tdbPageInsertCell(pParent, sIdx, pDivCell[nOlds - 1], szDivCell[nOlds - 1], 0); } } for (int i = 0; i < nOlds; i++) { - tdbPageDestroy(pOldsCopy[i], tdbDefaultFree, NULL); + (void)tdbPageDestroy(pOldsCopy[i], tdbDefaultFree, NULL); } } @@ -905,13 +905,13 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx i8 flags = TDB_BTREE_ROOT | TDB_BTREE_PAGE_IS_LEAF(pNews[0]); // copy content to the parent page tdbBtreeInitPage(pParent, &(SBtreeInitPageArg){.flags = flags, .pBt = pBt}, 0); - tdbPageCopy(pNews[0], pParent, 1); + (void)tdbPageCopy(pNews[0], pParent, 1); if (!TDB_BTREE_PAGE_IS_LEAF(pNews[0])) { ((SIntHdr *)(pParent->pData))->pgno = ((SIntHdr *)(pNews[0]->pData))->pgno; } - tdbPagerInsertFreePage(pBt->pPager, pNews[0], pTxn); + (void)tdbPagerInsertFreePage(pBt->pPager, pNews[0], pTxn); } for (int i = 0; i < 3; i++) { @@ -922,7 +922,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx for (pageIdx = 0; pageIdx < nOlds; ++pageIdx) { if (pageIdx >= nNews) { - tdbPagerInsertFreePage(pBt->pPager, pOlds[pageIdx], pTxn); + (void)tdbPagerInsertFreePage(pBt->pPager, pOlds[pageIdx], pTxn); } tdbPagerReturnPage(pBt->pPager, pOlds[pageIdx], pTxn); } @@ -1986,7 +1986,7 @@ int tdbBtcMoveToNext(SBTC *pBtc) { return 0; } - tdbBtcMoveUpward(pBtc); + (void)tdbBtcMoveUpward(pBtc); pBtc->idx++; if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) { @@ -2029,7 +2029,7 @@ int tdbBtcMoveToPrev(SBTC *pBtc) { return 0; } - tdbBtcMoveUpward(pBtc); + (void)tdbBtcMoveUpward(pBtc); pBtc->idx--; if (pBtc->idx >= 0) { break; @@ -2040,7 +2040,7 @@ int tdbBtcMoveToPrev(SBTC *pBtc) { for (;;) { if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) break; - tdbBtcMoveDownward(pBtc); + (void)tdbBtcMoveDownward(pBtc); if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) { pBtc->idx = TDB_PAGE_TOTAL_CELLS(pBtc->pPage) - 1; } else { @@ -2119,7 +2119,7 @@ int tdbBtcGet(SBTC *pBtc, const void **ppKey, int *kLen, const void **ppVal, int } pCell = tdbPageGetCell(pBtc->pPage, pBtc->idx); - tdbBtreeDecodeCell(pBtc->pPage, pCell, &pBtc->coder, pBtc->pTxn, pBtc->pBt); + (void)tdbBtreeDecodeCell(pBtc->pPage, pCell, &pBtc->coder, pBtc->pTxn, pBtc->pBt); if (ppKey) { *ppKey = (void *)pBtc->coder.pKey; @@ -2165,13 +2165,13 @@ int tdbBtcDelete(SBTC *pBtc) { destroyOfps = true; } - tdbPageDropCell(pBtc->pPage, idx, pBtc->pTxn, pBtc->pBt); + (void)tdbPageDropCell(pBtc->pPage, idx, pBtc->pTxn, pBtc->pBt); SArray *ofps = pBtc->pPage->pPager->ofps; if (ofps) { for (int i = 0; i < TARRAY_SIZE(ofps); ++i) { SPage *ofp = *(SPage **)taosArrayGet(ofps, i); - tdbPagerInsertFreePage(pBtc->pPage->pPager, ofp, pBtc->pTxn); + (void)tdbPagerInsertFreePage(pBtc->pPage->pPager, ofp, pBtc->pTxn); } if (destroyOfps) { @@ -2184,7 +2184,7 @@ int tdbBtcDelete(SBTC *pBtc) { if (idx == nCells - 1) { if (idx) { pBtc->idx--; - tdbBtcGet(pBtc, &pKey, &nKey, NULL, NULL); + (void)tdbBtcGet(pBtc, &pKey, &nKey, NULL, NULL); // loop to update the interial page pgno = TDB_PAGE_PGNO(pBtc->pPage); @@ -2202,7 +2202,7 @@ int tdbBtcDelete(SBTC *pBtc) { // update the cell with new key pCell = tdbOsMalloc(nKey + 9); - tdbBtreeEncodeCell(pPage, pKey, nKey, &pgno, sizeof(pgno), pCell, &szCell, pBtc->pTxn, pBtc->pBt); + (void)tdbBtreeEncodeCell(pPage, pKey, nKey, &pgno, sizeof(pgno), pCell, &szCell, pBtc->pTxn, pBtc->pBt); ret = tdbPageUpdateCell(pPage, idx, pCell, szCell, pBtc->pTxn, pBtc->pBt); if (ret < 0) { @@ -2429,7 +2429,7 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) { // compare first cell pBtc->idx = lidx; - tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL); + (void)tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL); c = pBt->kcmpr(pKey, kLen, pTKey, tkLen); if (c <= 0) { ridx = lidx - 1; @@ -2439,7 +2439,7 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) { // compare last cell if (lidx <= ridx) { pBtc->idx = ridx; - tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL); + (void)tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL); c = pBt->kcmpr(pKey, kLen, pTKey, tkLen); if (c >= 0) { lidx = ridx + 1; @@ -2454,7 +2454,7 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) { if (lidx > ridx) break; pBtc->idx = (lidx + ridx) >> 1; - tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL); + (void)tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL); c = pBt->kcmpr(pKey, kLen, pTKey, tkLen); if (c < 0) { // pKey < cd.pKey @@ -2476,7 +2476,7 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) { if (c > 0) { pBtc->idx += 1; } - tdbBtcMoveDownward(pBtc); + (void)tdbBtcMoveDownward(pBtc); } } diff --git a/source/libs/tdb/src/db/tdbDb.c b/source/libs/tdb/src/db/tdbDb.c index 47a7b6fe7a..825a6e2b94 100644 --- a/source/libs/tdb/src/db/tdbDb.c +++ b/source/libs/tdb/src/db/tdbDb.c @@ -101,10 +101,10 @@ int tdbClose(TDB *pDb) { for (pPager = pDb->pgrList; pPager; pPager = pDb->pgrList) { pDb->pgrList = pPager->pNext; - tdbPagerClose(pPager); + (void)tdbPagerClose(pPager); } - tdbPCacheClose(pDb->pCache); + (void)tdbPCacheClose(pDb->pCache); tdbOsFree(pDb->pgrHash); tdbOsFree(pDb); } diff --git a/source/libs/tdb/src/db/tdbPCache.c b/source/libs/tdb/src/db/tdbPCache.c index 6cb5f89758..c1a2943bee 100644 --- a/source/libs/tdb/src/db/tdbPCache.c +++ b/source/libs/tdb/src/db/tdbPCache.c @@ -44,10 +44,10 @@ static void tdbPCacheAddPageToHash(SPCache *pCache, SPage *pPage); static void tdbPCacheUnpinPage(SPCache *pCache, SPage *pPage); static int tdbPCacheCloseImpl(SPCache *pCache); -static void tdbPCacheInitLock(SPCache *pCache) { tdbMutexInit(&(pCache->mutex), NULL); } -static void tdbPCacheDestroyLock(SPCache *pCache) { tdbMutexDestroy(&(pCache->mutex)); } -static void tdbPCacheLock(SPCache *pCache) { tdbMutexLock(&(pCache->mutex)); } -static void tdbPCacheUnlock(SPCache *pCache) { tdbMutexUnlock(&(pCache->mutex)); } +static void tdbPCacheInitLock(SPCache *pCache) { (void)tdbMutexInit(&(pCache->mutex), NULL); } +static void tdbPCacheDestroyLock(SPCache *pCache) { (void)tdbMutexDestroy(&(pCache->mutex)); } +static void tdbPCacheLock(SPCache *pCache) { (void)tdbMutexLock(&(pCache->mutex)); } +static void tdbPCacheUnlock(SPCache *pCache) { (void)tdbMutexUnlock(&(pCache->mutex)); } int tdbPCacheOpen(int pageSize, int cacheSize, SPCache **ppCache) { int32_t code = 0; @@ -74,7 +74,7 @@ int tdbPCacheOpen(int pageSize, int cacheSize, SPCache **ppCache) { _exit: if (code) { tdbError("%s failed at %s:%d since %s", __func__, __FILE__, __LINE__, tstrerror(code)); - tdbPCacheClose(pCache); + (void)tdbPCacheClose(pCache); *ppCache = NULL; } else { *ppCache = pCache; @@ -84,7 +84,7 @@ _exit: int tdbPCacheClose(SPCache *pCache) { if (pCache) { - tdbPCacheCloseImpl(pCache); + (void)tdbPCacheCloseImpl(pCache); tdbOsFree(pCache->aPage); tdbOsFree(pCache); } @@ -149,7 +149,7 @@ static int tdbPCacheAlterImpl(SPCache *pCache, int32_t nPage) { SPage *pPage = *ppPage; *ppPage = pPage->pFreeNext; pCache->aPage[pPage->id] = NULL; - tdbPageDestroy(pPage, tdbDefaultFree, NULL); + (void)tdbPageDestroy(pPage, tdbDefaultFree, NULL); pCache->nFree--; } else { ppPage = &(*ppPage)->pFreeNext; @@ -209,7 +209,7 @@ static void tdbPCacheFreePage(SPCache *pCache, SPage *pPage) { tdbTrace("pcache/free2 page: %p/%d, pgno:%d, ", pPage, pPage->id, TDB_PAGE_PGNO(pPage)); tdbPCacheRemovePageFromHash(pCache, pPage); - tdbPageDestroy(pPage, tdbDefaultFree, NULL); + (void)tdbPageDestroy(pPage, tdbDefaultFree, NULL); } } @@ -268,7 +268,7 @@ void tdbPCacheRelease(SPCache *pCache, SPage *pPage, TXN *pTxn) { tdbPCacheRemovePageFromHash(pCache, pPage); } - tdbPageDestroy(pPage, pTxn->xFree, pTxn->xArg); + (void)tdbPageDestroy(pPage, pTxn->xFree, pTxn->xArg); } // } } @@ -349,7 +349,7 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, TXN *pTxn) for (int nLoops = 0;;) { if (pPageH->pPager) break; if (++nLoops > 1000) { - sched_yield(); + (void)sched_yield(); nLoops = 0; } } @@ -432,7 +432,7 @@ static void tdbPCacheUnpinPage(SPCache *pCache, SPage *pPage) { tdbTrace("pcache destroy page: %p/%d/%d", pPage, TDB_PAGE_PGNO(pPage), pPage->id); tdbPCacheRemovePageFromHash(pCache, pPage); - tdbPageDestroy(pPage, tdbDefaultFree, NULL); + (void)tdbPageDestroy(pPage, tdbDefaultFree, NULL); } } @@ -518,14 +518,14 @@ static int tdbPCacheCloseImpl(SPCache *pCache) { // free free page for (SPage *pPage = pCache->pFree; pPage;) { SPage *pPageT = pPage->pFreeNext; - tdbPageDestroy(pPage, tdbDefaultFree, NULL); + (void)tdbPageDestroy(pPage, tdbDefaultFree, NULL); pPage = pPageT; } for (int32_t iBucket = 0; iBucket < pCache->nHash; iBucket++) { for (SPage *pPage = pCache->pgHash[iBucket]; pPage;) { SPage *pPageT = pPage->pHashNext; - tdbPageDestroy(pPage, tdbDefaultFree, NULL); + (void)tdbPageDestroy(pPage, tdbDefaultFree, NULL); pPage = pPageT; } } diff --git a/source/libs/tdb/src/db/tdbPage.c b/source/libs/tdb/src/db/tdbPage.c index 322b735163..26c1c108d2 100644 --- a/source/libs/tdb/src/db/tdbPage.c +++ b/source/libs/tdb/src/db/tdbPage.c @@ -64,7 +64,7 @@ int tdbPageCreate(int pageSize, SPage **ppPage, void *(*xMalloc)(void *, size_t) memset(ptr, 0, size); pPage = (SPage *)(ptr + pageSize); - TDB_INIT_PAGE_LOCK(pPage); + (void)TDB_INIT_PAGE_LOCK(pPage); pPage->pageSize = pageSize; pPage->pData = ptr; if (pageSize < 65536) { @@ -194,7 +194,7 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl iOvfl++; } else { // page must has enough space to hold the cell locally - tdbPageAllocate(pPage, szCell, &pNewCell); + (void)tdbPageAllocate(pPage, szCell, &pNewCell); memcpy(pNewCell, pCell, szCell); @@ -220,7 +220,7 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl } int tdbPageUpdateCell(SPage *pPage, int idx, SCell *pCell, int szCell, TXN *pTxn, SBTree *pBt) { - tdbPageDropCell(pPage, idx, pTxn, pBt); + (void)tdbPageDropCell(pPage, idx, pTxn, pBt); return tdbPageInsertCell(pPage, idx, pCell, szCell, 0); } @@ -259,7 +259,7 @@ int tdbPageDropCell(SPage *pPage, int idx, TXN *pTxn, SBTree *pBt) { lidx = idx - iOvfl; pCell = TDB_PAGE_CELL_AT(pPage, lidx); szCell = (*pPage->xCellSize)(pPage, pCell, 1, pTxn, pBt); - tdbPageFree(pPage, lidx, pCell, szCell); + (void)tdbPageFree(pPage, lidx, pCell, szCell); TDB_PAGE_NCELLS_SET(pPage, nCells - 1); for (; iOvfl < pPage->nOverflow; iOvfl++) { diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c index 414ca42a02..01c9132b54 100644 --- a/source/libs/tdb/src/db/tdbPager.c +++ b/source/libs/tdb/src/db/tdbPager.c @@ -107,7 +107,7 @@ static int hashset_add(hashset_t set, void *item) { set->nitems = 0; for (size_t i = 0; i < old_capacity; ++i) { - hashset_add_member(set, (void *)old_items[i]); + (void)hashset_add_member(set, (void *)old_items[i]); } tdbOsFree(old_items); } @@ -223,7 +223,7 @@ int tdbPagerOpen(SPCache *pCache, const char *fileName, SPager **ppPager) { int tdbPagerClose(SPager *pPager) { if (pPager) { - tdbOsClose(pPager->fd); + (void)tdbOsClose(pPager->fd); tdbOsFree(pPager); } return 0; @@ -236,14 +236,14 @@ int tdbPagerWrite(SPager *pPager, SPage *pPage) { if (pPage->isDirty) return 0; // ref page one more time so the page will not be release - tdbRefPage(pPage); + (void)tdbRefPage(pPage); tdbTrace("pager/mdirty page %p/%d/%d", pPage, TDB_PAGE_PGNO(pPage), pPage->id); // Set page as dirty pPage->isDirty = 1; tdbTrace("tdb/pager-write: put page: %p %d to dirty tree: %p", pPage, TDB_PAGE_PGNO(pPage), &pPager->rbt); - tRBTreePut(&pPager->rbt, (SRBTreeNode *)pPage); + (void)tRBTreePut(&pPager->rbt, (SRBTreeNode *)pPage); // Write page to journal if neccessary if (TDB_PAGE_PGNO(pPage) <= pPager->dbOrigSize && @@ -256,7 +256,7 @@ int tdbPagerWrite(SPager *pPager, SPage *pPage) { } if (pPager->pActiveTxn->jPageSet) { - hashset_add(pPager->pActiveTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); + (void)hashset_add(pPager->pActiveTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); } } @@ -352,7 +352,7 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) { tRBTreeDrop(&pPager->rbt, (SRBTreeNode *)pPage); if (pTxn->jPageSet) { - hashset_remove(pTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); + (void)hashset_remove(pTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); } tdbTrace("tdb/pager-commit: remove page: %p %d from dirty tree: %p", pPage, TDB_PAGE_PGNO(pPage), &pPager->rbt); @@ -590,7 +590,7 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) { pPage->isDirty = 0; tRBTreeDrop(&pPager->rbt, (SRBTreeNode *)pPage); - hashset_remove(pTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); + (void)hashset_remove(pTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); tdbPCacheMarkFree(pPager->pCache, pPage); tdbPCacheRelease(pPager->pCache, pPage, pTxn); } @@ -712,7 +712,7 @@ int tdbPagerFetchPage(SPager *pPager, SPgno *ppgno, SPage **ppPage, int (*initPa memcpy(&pgid, pPager->fid, TDB_FILE_ID_LEN); pgid.pgno = pgno; while ((pPage = tdbPCacheFetch(pPager->pCache, &pgid, pTxn)) == NULL) { - tdbPagerFlushPage(pPager, pTxn); + (void)tdbPagerFlushPage(pPager, pTxn); } tdbTrace("tdbttl fetch pager:%p", pPage->pPager); @@ -815,7 +815,7 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) { code = tdbTbcMoveToFirst(pCur); if (code) { tdbError("tdb/remove-free-page: moveto first failed with ret: %d.", code); - tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); return 0; } @@ -825,7 +825,7 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) { code = tdbTbcGet(pCur, (const void **)&pKey, &nKey, NULL, NULL); if (code < 0) { // tdbError("tdb/remove-free-page: tbc get failed with ret: %d.", code); - tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); return 0; } @@ -836,10 +836,10 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) { code = tdbTbcDelete(pCur); if (code < 0) { tdbError("tdb/remove-free-page: tbc delete failed with ret: %d.", code); - tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); return 0; } - tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); return 0; } @@ -892,7 +892,7 @@ static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage lcode = TDB_TRY_LOCK_PAGE(pPage); if (lcode == P_LOCK_SUCC) { if (TDB_PAGE_INITIALIZED(pPage)) { - TDB_UNLOCK_PAGE(pPage); + (void)TDB_UNLOCK_PAGE(pPage); return 0; } @@ -906,7 +906,7 @@ static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage tdbTrace("tdb/pager:%p, pgno:%d, nRead:%" PRId64, pPager, pgno, nRead); if (nRead < pPage->pageSize) { tdbError("tdb/pager:%p, pgno:%d, nRead:%" PRId64 "pgSize:%" PRId32, pPager, pgno, nRead, pPage->pageSize); - TDB_UNLOCK_PAGE(pPage); + (void)TDB_UNLOCK_PAGE(pPage); return TAOS_SYSTEM_ERROR(errno); } @@ -953,7 +953,7 @@ static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage if (ret < 0) { tdbError("tdb/pager:%p, pgno:%d, nRead:%" PRId64 "pgSize:%" PRId32 " init page failed.", pPager, pgno, nRead, pPage->pageSize); - TDB_UNLOCK_PAGE(pPage); + (void)TDB_UNLOCK_PAGE(pPage); return ret; } @@ -961,7 +961,7 @@ static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage pPage->pPager = pPager; - TDB_UNLOCK_PAGE(pPage); + (void)TDB_UNLOCK_PAGE(pPage); } else if (lcode == P_LOCK_BUSY) { nLoops = 0; for (;;) { @@ -1162,7 +1162,7 @@ int tdbPagerRestoreJournals(SPager *pPager) { char *name = tdbDirEntryBaseName(tdbGetDirEntryName(pDirEntry)); if (strncmp(TDB_MAINDB_NAME "-journal", name, 16) == 0) { int64_t txnId = -1; - sscanf(name, TDB_MAINDB_NAME "-journal.%" PRId64, &txnId); + (void)sscanf(name, TDB_MAINDB_NAME "-journal.%" PRId64, &txnId); if (taosArrayPush(pTxnList, &txnId) == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -1179,14 +1179,14 @@ int tdbPagerRestoreJournals(SPager *pPager) { code = tdbPagerRestore(pPager, jname); if (code) { taosArrayDestroy(pTxnList); - tdbCloseDir(&pDir); + (void)tdbCloseDir(&pDir); tdbError("failed to restore file due to %s. jFileName:%s", strerror(code), jname); return code; } } taosArrayDestroy(pTxnList); - tdbCloseDir(&pDir); + (void)tdbCloseDir(&pDir); return 0; } @@ -1209,7 +1209,7 @@ int tdbPagerRollback(SPager *pPager) { jname[dirLen] = '/'; memcpy(jname + dirLen + 1, name, strlen(name)); if (tdbOsRemove(jname) < 0 && errno != ENOENT) { - tdbCloseDir(&pDir); + (void)tdbCloseDir(&pDir); tdbError("failed to remove file due to %s. jFileName:%s", strerror(errno), name); return terrno = TAOS_SYSTEM_ERROR(errno); @@ -1217,7 +1217,7 @@ int tdbPagerRollback(SPager *pPager) { } } - tdbCloseDir(&pDir); + (void)tdbCloseDir(&pDir); return 0; } diff --git a/source/libs/tdb/src/db/tdbTable.c b/source/libs/tdb/src/db/tdbTable.c index 365be222ef..d885c38864 100644 --- a/source/libs/tdb/src/db/tdbTable.c +++ b/source/libs/tdb/src/db/tdbTable.c @@ -112,7 +112,7 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF return ret; } } else { - tdbPagerRollback(pPager); + (void)tdbPagerRollback(pPager); } // pTb->pBt @@ -128,7 +128,7 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF int tdbTbClose(TTB *pTb) { if (pTb) { - tdbBtreeClose(pTb->pBt); + (void)tdbBtreeClose(pTb->pBt); tdbOsFree(pTb); } return 0; @@ -202,7 +202,7 @@ int tdbTbInsert(TTB *pTb, const void *pKey, int keyLen, const void *pVal, int va int tdbTbDelete(TTB *pTb, const void *pKey, int kLen, TXN *pTxn) { return tdbBtreeDelete(pTb->pBt, pKey, kLen, pTxn); } int tdbTbUpsert(TTB *pTb, const void *pKey, int kLen, const void *pVal, int vLen, TXN *pTxn) { - tdbTbDelete(pTb, pKey, kLen, pTxn); + (void)tdbTbDelete(pTb, pKey, kLen, pTxn); return tdbTbInsert(pTb, pKey, kLen, pVal, vLen, pTxn); } @@ -224,7 +224,7 @@ int tdbTbcOpen(TTB *pTb, TBC **ppTbc, TXN *pTxn) { return -1; } - tdbBtcOpen(&pTbc->btc, pTb->pBt, pTxn); + (void)tdbBtcOpen(&pTbc->btc, pTb->pBt, pTxn); *ppTbc = pTbc; return 0; @@ -238,7 +238,7 @@ int32_t tdbTbTraversal(TTB *pTb, void *data, return ret; } - tdbTbcMoveToFirst(pCur); + (void)tdbTbcMoveToFirst(pCur); void *pKey = NULL; int kLen = 0; @@ -257,7 +257,7 @@ int32_t tdbTbTraversal(TTB *pTb, void *data, } tdbFree(pKey); tdbFree(pValue); - tdbTbcClose(pCur); + (void)tdbTbcClose(pCur); return 0; } @@ -292,7 +292,7 @@ int tdbTbcUpsert(TBC *pTbc, const void *pKey, int nKey, const void *pData, int n int tdbTbcClose(TBC *pTbc) { if (pTbc) { - tdbBtcClose(&pTbc->btc); + (void)tdbBtcClose(&pTbc->btc); tdbOsFree(pTbc); } diff --git a/source/libs/tdb/src/inc/tdbUtil.h b/source/libs/tdb/src/inc/tdbUtil.h index fe97f9c986..4382513f73 100644 --- a/source/libs/tdb/src/inc/tdbUtil.h +++ b/source/libs/tdb/src/inc/tdbUtil.h @@ -13,6 +13,8 @@ * along with this program. If not, see . */ +#include "tdbInt.h" + #ifndef _TDB_UTIL_H_ #define _TDB_UTIL_H_ @@ -56,8 +58,6 @@ static inline int tdbPutVarInt(u8 *p, int v) { v >>= 7; } - ASSERT(n < 6); - return n; } @@ -79,8 +79,6 @@ static inline int tdbGetVarInt(const u8 *p, int *v) { n++; } - ASSERT(n < 6); - *v = tv; return n; }