enh: refactor return code

This commit is contained in:
Hongze Cheng 2024-07-29 13:06:20 +08:00
parent fc4d758a9f
commit 074be75363
8 changed files with 101 additions and 103 deletions

View File

@ -48,7 +48,7 @@ int32_t tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyC
int8_t rollback); int8_t rollback);
int32_t tdbTbClose(TTB *pTb); int32_t tdbTbClose(TTB *pTb);
bool tdbTbExist(const char *tbname, TDB *pEnv); 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 tdbTbDrop(TTB *pTb);
int32_t tdbTbInsert(TTB *pTb, const void *pKey, int keyLen, const void *pVal, int valLen, TXN *pTxn); 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); 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 *), int32_t tdbTxnOpen(TXN *pTxn, int64_t txnid, void *(*xMalloc)(void *, size_t), void (*xFree)(void *, void *),
void *xArg, int flags); void *xArg, int flags);
int32_t tdbTxnCloseImpl(TXN *pTxn); int32_t tdbTxnCloseImpl(TXN *pTxn);
#define tdbTxnClose(pTxn) \ #define tdbTxnClose(pTxn) \
do { \ do { \
tdbTxnCloseImpl(pTxn); \ (void)tdbTxnCloseImpl(pTxn); \
(pTxn) = NULL; \ (pTxn) = NULL; \
} while (0) } while (0)
// other // other

View File

@ -122,7 +122,7 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPg
zArg.pBt = pBt; zArg.pBt = pBt;
ret = tdbPagerFetchPage(pPager, &pgno, &pPage, tdbBtreeInitPage, &zArg, txn); ret = tdbPagerFetchPage(pPager, &pgno, &pPage, tdbBtreeInitPage, &zArg, txn);
if (ret < 0) { if (ret < 0) {
tdbAbort(pEnv, txn); (void)tdbAbort(pEnv, txn);
tdbOsFree(pBt); tdbOsFree(pBt);
return ret; return ret;
} }
@ -130,7 +130,7 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPg
ret = tdbPagerWrite(pPager, pPage); ret = tdbPagerWrite(pPager, pPage);
if (ret < 0) { if (ret < 0) {
tdbError("failed to write page since %s", terrstr()); tdbError("failed to write page since %s", terrstr());
tdbAbort(pEnv, txn); (void)tdbAbort(pEnv, txn);
tdbOsFree(pBt); tdbOsFree(pBt);
return ret; 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); ret = tdbTbInsert(pPager->pEnv->pMainDb, tbname, strlen(tbname) + 1, &pBt->info, sizeof(pBt->info), txn);
if (ret < 0) { if (ret < 0) {
tdbAbort(pEnv, txn); (void)tdbAbort(pEnv, txn);
tdbOsFree(pBt); tdbOsFree(pBt);
return ret; return ret;
} }
@ -194,14 +194,14 @@ int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, in
int idx; int idx;
int c; int c;
tdbBtcOpen(&btc, pBt, pTxn); (void)tdbBtcOpen(&btc, pBt, pTxn);
tdbTrace("tdb insert, btc: %p, pTxn: %p", &btc, pTxn); tdbTrace("tdb insert, btc: %p, pTxn: %p", &btc, pTxn);
// move to the position to insert // move to the position to insert
ret = tdbBtcMoveTo(&btc, pKey, kLen, &c); ret = tdbBtcMoveTo(&btc, pKey, kLen, &c);
if (ret < 0) { if (ret < 0) {
tdbBtcClose(&btc); (void)tdbBtcClose(&btc);
tdbError("tdb/btree-insert: btc move to failed with ret: %d.", ret); tdbError("tdb/btree-insert: btc move to failed with ret: %d.", ret);
return ret; return ret;
} }
@ -213,7 +213,7 @@ int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, in
btc.idx++; btc.idx++;
} else if (c == 0) { } else if (c == 0) {
// dup key not allowed with insert // 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); tdbError("tdb/btree-insert: dup key. pKey: %p, kLen: %d, btc: %p, pTxn: %p", pKey, kLen, &btc, pTxn);
return TSDB_CODE_DUP_KEY; 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); ret = tdbBtcUpsert(&btc, pKey, kLen, pVal, vLen, 1);
if (ret < 0) { if (ret < 0) {
tdbBtcClose(&btc); (void)tdbBtcClose(&btc);
tdbError("tdb/btree-insert: btc upsert failed with ret: %d.", ret); tdbError("tdb/btree-insert: btc upsert failed with ret: %d.", ret);
return ret; return ret;
} }
tdbBtcClose(&btc); (void)tdbBtcClose(&btc);
return 0; return 0;
} }
@ -246,20 +246,20 @@ int tdbBtreeDelete(SBTree *pBt, const void *pKey, int kLen, TXN *pTxn) {
// move the cursor // move the cursor
ret = tdbBtcMoveTo(&btc, pKey, kLen, &c); ret = tdbBtcMoveTo(&btc, pKey, kLen, &c);
if (ret < 0) { if (ret < 0) {
tdbBtcClose(&btc); (void)tdbBtcClose(&btc);
tdbError("tdb/btree-delete: btc move to failed with ret: %d.", ret); tdbError("tdb/btree-delete: btc move to failed with ret: %d.", ret);
return ret; return ret;
} }
if (btc.idx < 0 || c != 0) { if (btc.idx < 0 || c != 0) {
tdbBtcClose(&btc); (void)tdbBtcClose(&btc);
return TSDB_CODE_NOT_FOUND; return TSDB_CODE_NOT_FOUND;
} }
// delete the key // delete the key
ret = tdbBtcDelete(&btc); ret = tdbBtcDelete(&btc);
if (ret < 0) { if (ret < 0) {
tdbBtcClose(&btc); (void)tdbBtcClose(&btc);
return ret; return ret;
} }
/* /*
@ -274,7 +274,7 @@ int tdbBtreeDelete(SBTree *pBt, const void *pKey, int kLen, TXN *pTxn) {
btc.coder.ofps = NULL; btc.coder.ofps = NULL;
} }
*/ */
tdbBtcClose(&btc); (void)tdbBtcClose(&btc);
return 0; 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); ret = tdbBtcMoveTo(&btc, pKey, kLen, &cret);
if (ret < 0) { if (ret < 0) {
tdbBtcClose(&btc); (void)tdbBtcClose(&btc);
tdbError("tdb/btree-pget: btc move to failed with ret: %d.", ret); tdbError("tdb/btree-pget: btc move to failed with ret: %d.", ret);
return ret; return ret;
} }
if (btc.idx < 0 || cret) { if (btc.idx < 0 || cret) {
tdbBtcClose(&btc); (void)tdbBtcClose(&btc);
return TSDB_CODE_NOT_FOUND; return TSDB_CODE_NOT_FOUND;
} }
pCell = tdbPageGetCell(btc.pPage, btc.idx); pCell = tdbPageGetCell(btc.pPage, btc.idx);
ret = tdbBtreeDecodeCell(btc.pPage, pCell, &cd, btc.pTxn, pBt); ret = tdbBtreeDecodeCell(btc.pPage, pCell, &cd, btc.pTxn, pBt);
if (ret < 0) { if (ret < 0) {
tdbBtcClose(&btc); (void)tdbBtcClose(&btc);
tdbError("tdb/btree-pget: decode cell failed with ret: %d.", ret); tdbError("tdb/btree-pget: decode cell failed with ret: %d.", ret);
return ret; return ret;
} }
@ -364,7 +364,7 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL
if (ppKey) { if (ppKey) {
pTKey = tdbRealloc(*ppKey, cd.kLen); pTKey = tdbRealloc(*ppKey, cd.kLen);
if (pTKey == NULL) { if (pTKey == NULL) {
tdbBtcClose(&btc); (void)tdbBtcClose(&btc);
tdbError("tdb/btree-pget: realloc pTKey failed."); tdbError("tdb/btree-pget: realloc pTKey failed.");
return terrno; return terrno;
} }
@ -376,7 +376,7 @@ int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkL
if (ppVal) { if (ppVal) {
pTVal = tdbRealloc(*ppVal, cd.vLen); pTVal = tdbRealloc(*ppVal, cd.vLen);
if (pTVal == NULL) { if (pTVal == NULL) {
tdbBtcClose(&btc); (void)tdbBtcClose(&btc);
tdbError("tdb/btree-pget: realloc pTVal failed."); tdbError("tdb/btree-pget: realloc pTVal failed.");
return terrno; 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); 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; 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 // Copy the root page content to the child page
tdbPageCopy(pRoot, pChild, 0); (void)tdbPageCopy(pRoot, pChild, 0);
// Reinitialize the root page // Reinitialize the root page
zArg.flags = TDB_BTREE_ROOT; zArg.flags = TDB_BTREE_ROOT;
@ -602,7 +602,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
if (i < nOlds - 1) { if (i < nOlds - 1) {
((SPgno *)pDivCell[i])[0] = ((SIntHdr *)pOlds[i]->pData)->pgno; ((SPgno *)pDivCell[i])[0] = ((SIntHdr *)pOlds[i]->pData)->pgno;
((SIntHdr *)pOlds[i]->pData)->pgno = 0; ((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; 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) { if (!childNotLeaf) {
SArray *ofps = pParent->pPager->ofps; SArray *ofps = pParent->pPager->ofps;
if (ofps) { if (ofps) {
for (int i = 0; i < TARRAY_SIZE(ofps); ++i) { for (int i = 0; i < TARRAY_SIZE(ofps); ++i) {
SPage *ofp = *(SPage **)taosArrayGet(ofps, i); SPage *ofp = *(SPage **)taosArrayGet(ofps, i);
tdbPagerInsertFreePage(pParent->pPager, ofp, pTxn); (void)tdbPagerInsertFreePage(pParent->pPager, ofp, pTxn);
} }
if (destroyOfps) { if (destroyOfps) {
@ -791,9 +791,9 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
iarg.pBt = pBt; iarg.pBt = pBt;
iarg.flags = TDB_BTREE_PAGE_GET_FLAGS(pOlds[0]); iarg.flags = TDB_BTREE_PAGE_GET_FLAGS(pOlds[0]);
for (int i = 0; i < nOlds; i++) { for (int i = 0; i < nOlds; i++) {
tdbPageCreate(pOlds[0]->pageSize, &pOldsCopy[i], tdbDefaultMalloc, NULL); (void)tdbPageCreate(pOlds[0]->pageSize, &pOldsCopy[i], tdbDefaultMalloc, NULL);
tdbBtreeInitPage(pOldsCopy[i], &iarg, 0); (void)tdbBtreeInitPage(pOldsCopy[i], &iarg, 0);
tdbPageCopy(pOlds[i], pOldsCopy[i], 0); (void)tdbPageCopy(pOlds[i], pOldsCopy[i], 0);
pOlds[i]->nOverflow = 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) { if (nNewCells < infoNews[iNew].cnt) {
tdbPageInsertCell(pNews[iNew], nNewCells, pCell, szCell, 0); (void)tdbPageInsertCell(pNews[iNew], nNewCells, pCell, szCell, 0);
nNewCells++; nNewCells++;
// insert parent page // insert parent page
@ -835,9 +835,9 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
int szNewCell; int szNewCell;
SPgno pgno; SPgno pgno;
pgno = TDB_PAGE_PGNO(pNews[iNew]); pgno = TDB_PAGE_PGNO(pNews[iNew]);
tdbBtreeEncodeCell(pParent, cd.pKey, cd.kLen, (void *)&pgno, sizeof(SPgno), pNewCell, &szNewCell, pTxn, (void)tdbBtreeEncodeCell(pParent, cd.pKey, cd.kLen, (void *)&pgno, sizeof(SPgno), pNewCell, &szNewCell,
pBt); pTxn, pBt);
tdbPageInsertCell(pParent, sIdx++, pNewCell, szNewCell, 0); (void)tdbPageInsertCell(pParent, sIdx++, pNewCell, szNewCell, 0);
tdbOsFree(pNewCell); tdbOsFree(pNewCell);
if (TDB_CELLDECODER_FREE_VAL(&cd)) { 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; return TSDB_CODE_FAILED;
} }
((SPgno *)pCell)[0] = TDB_PAGE_PGNO(pNews[iNew]); ((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 // move to next new page
iNew++; iNew++;
@ -892,12 +892,12 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
pIntHdr->pgno = TDB_PAGE_PGNO(pNews[nNews - 1]); pIntHdr->pgno = TDB_PAGE_PGNO(pNews[nNews - 1]);
} else { } else {
((SPgno *)pDivCell[nOlds - 1])[0] = TDB_PAGE_PGNO(pNews[nNews - 1]); ((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++) { 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]); i8 flags = TDB_BTREE_ROOT | TDB_BTREE_PAGE_IS_LEAF(pNews[0]);
// copy content to the parent page // copy content to the parent page
tdbBtreeInitPage(pParent, &(SBtreeInitPageArg){.flags = flags, .pBt = pBt}, 0); 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])) { if (!TDB_BTREE_PAGE_IS_LEAF(pNews[0])) {
((SIntHdr *)(pParent->pData))->pgno = ((SIntHdr *)(pNews[0]->pData))->pgno; ((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++) { 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) { for (pageIdx = 0; pageIdx < nOlds; ++pageIdx) {
if (pageIdx >= nNews) { if (pageIdx >= nNews) {
tdbPagerInsertFreePage(pBt->pPager, pOlds[pageIdx], pTxn); (void)tdbPagerInsertFreePage(pBt->pPager, pOlds[pageIdx], pTxn);
} }
tdbPagerReturnPage(pBt->pPager, pOlds[pageIdx], pTxn); tdbPagerReturnPage(pBt->pPager, pOlds[pageIdx], pTxn);
} }
@ -1986,7 +1986,7 @@ int tdbBtcMoveToNext(SBTC *pBtc) {
return 0; return 0;
} }
tdbBtcMoveUpward(pBtc); (void)tdbBtcMoveUpward(pBtc);
pBtc->idx++; pBtc->idx++;
if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) { if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) {
@ -2029,7 +2029,7 @@ int tdbBtcMoveToPrev(SBTC *pBtc) {
return 0; return 0;
} }
tdbBtcMoveUpward(pBtc); (void)tdbBtcMoveUpward(pBtc);
pBtc->idx--; pBtc->idx--;
if (pBtc->idx >= 0) { if (pBtc->idx >= 0) {
break; break;
@ -2040,7 +2040,7 @@ int tdbBtcMoveToPrev(SBTC *pBtc) {
for (;;) { for (;;) {
if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) break; if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) break;
tdbBtcMoveDownward(pBtc); (void)tdbBtcMoveDownward(pBtc);
if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) { if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) {
pBtc->idx = TDB_PAGE_TOTAL_CELLS(pBtc->pPage) - 1; pBtc->idx = TDB_PAGE_TOTAL_CELLS(pBtc->pPage) - 1;
} else { } else {
@ -2119,7 +2119,7 @@ int tdbBtcGet(SBTC *pBtc, const void **ppKey, int *kLen, const void **ppVal, int
} }
pCell = tdbPageGetCell(pBtc->pPage, pBtc->idx); 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) { if (ppKey) {
*ppKey = (void *)pBtc->coder.pKey; *ppKey = (void *)pBtc->coder.pKey;
@ -2165,13 +2165,13 @@ int tdbBtcDelete(SBTC *pBtc) {
destroyOfps = true; 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; SArray *ofps = pBtc->pPage->pPager->ofps;
if (ofps) { if (ofps) {
for (int i = 0; i < TARRAY_SIZE(ofps); ++i) { for (int i = 0; i < TARRAY_SIZE(ofps); ++i) {
SPage *ofp = *(SPage **)taosArrayGet(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) { if (destroyOfps) {
@ -2184,7 +2184,7 @@ int tdbBtcDelete(SBTC *pBtc) {
if (idx == nCells - 1) { if (idx == nCells - 1) {
if (idx) { if (idx) {
pBtc->idx--; pBtc->idx--;
tdbBtcGet(pBtc, &pKey, &nKey, NULL, NULL); (void)tdbBtcGet(pBtc, &pKey, &nKey, NULL, NULL);
// loop to update the interial page // loop to update the interial page
pgno = TDB_PAGE_PGNO(pBtc->pPage); pgno = TDB_PAGE_PGNO(pBtc->pPage);
@ -2202,7 +2202,7 @@ int tdbBtcDelete(SBTC *pBtc) {
// update the cell with new key // update the cell with new key
pCell = tdbOsMalloc(nKey + 9); 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); ret = tdbPageUpdateCell(pPage, idx, pCell, szCell, pBtc->pTxn, pBtc->pBt);
if (ret < 0) { if (ret < 0) {
@ -2429,7 +2429,7 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
// compare first cell // compare first cell
pBtc->idx = lidx; pBtc->idx = lidx;
tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL); (void)tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL);
c = pBt->kcmpr(pKey, kLen, pTKey, tkLen); c = pBt->kcmpr(pKey, kLen, pTKey, tkLen);
if (c <= 0) { if (c <= 0) {
ridx = lidx - 1; ridx = lidx - 1;
@ -2439,7 +2439,7 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
// compare last cell // compare last cell
if (lidx <= ridx) { if (lidx <= ridx) {
pBtc->idx = ridx; pBtc->idx = ridx;
tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL); (void)tdbBtcGet(pBtc, &pTKey, &tkLen, NULL, NULL);
c = pBt->kcmpr(pKey, kLen, pTKey, tkLen); c = pBt->kcmpr(pKey, kLen, pTKey, tkLen);
if (c >= 0) { if (c >= 0) {
lidx = ridx + 1; lidx = ridx + 1;
@ -2454,7 +2454,7 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
if (lidx > ridx) break; if (lidx > ridx) break;
pBtc->idx = (lidx + ridx) >> 1; 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); c = pBt->kcmpr(pKey, kLen, pTKey, tkLen);
if (c < 0) { if (c < 0) {
// pKey < cd.pKey // pKey < cd.pKey
@ -2476,7 +2476,7 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) {
if (c > 0) { if (c > 0) {
pBtc->idx += 1; pBtc->idx += 1;
} }
tdbBtcMoveDownward(pBtc); (void)tdbBtcMoveDownward(pBtc);
} }
} }

View File

@ -101,10 +101,10 @@ int tdbClose(TDB *pDb) {
for (pPager = pDb->pgrList; pPager; pPager = pDb->pgrList) { for (pPager = pDb->pgrList; pPager; pPager = pDb->pgrList) {
pDb->pgrList = pPager->pNext; pDb->pgrList = pPager->pNext;
tdbPagerClose(pPager); (void)tdbPagerClose(pPager);
} }
tdbPCacheClose(pDb->pCache); (void)tdbPCacheClose(pDb->pCache);
tdbOsFree(pDb->pgrHash); tdbOsFree(pDb->pgrHash);
tdbOsFree(pDb); tdbOsFree(pDb);
} }

View File

@ -44,10 +44,10 @@ static void tdbPCacheAddPageToHash(SPCache *pCache, SPage *pPage);
static void tdbPCacheUnpinPage(SPCache *pCache, SPage *pPage); static void tdbPCacheUnpinPage(SPCache *pCache, SPage *pPage);
static int tdbPCacheCloseImpl(SPCache *pCache); static int tdbPCacheCloseImpl(SPCache *pCache);
static void tdbPCacheInitLock(SPCache *pCache) { tdbMutexInit(&(pCache->mutex), NULL); } static void tdbPCacheInitLock(SPCache *pCache) { (void)tdbMutexInit(&(pCache->mutex), NULL); }
static void tdbPCacheDestroyLock(SPCache *pCache) { tdbMutexDestroy(&(pCache->mutex)); } static void tdbPCacheDestroyLock(SPCache *pCache) { (void)tdbMutexDestroy(&(pCache->mutex)); }
static void tdbPCacheLock(SPCache *pCache) { tdbMutexLock(&(pCache->mutex)); } static void tdbPCacheLock(SPCache *pCache) { (void)tdbMutexLock(&(pCache->mutex)); }
static void tdbPCacheUnlock(SPCache *pCache) { tdbMutexUnlock(&(pCache->mutex)); } static void tdbPCacheUnlock(SPCache *pCache) { (void)tdbMutexUnlock(&(pCache->mutex)); }
int tdbPCacheOpen(int pageSize, int cacheSize, SPCache **ppCache) { int tdbPCacheOpen(int pageSize, int cacheSize, SPCache **ppCache) {
int32_t code = 0; int32_t code = 0;
@ -74,7 +74,7 @@ int tdbPCacheOpen(int pageSize, int cacheSize, SPCache **ppCache) {
_exit: _exit:
if (code) { if (code) {
tdbError("%s failed at %s:%d since %s", __func__, __FILE__, __LINE__, tstrerror(code)); tdbError("%s failed at %s:%d since %s", __func__, __FILE__, __LINE__, tstrerror(code));
tdbPCacheClose(pCache); (void)tdbPCacheClose(pCache);
*ppCache = NULL; *ppCache = NULL;
} else { } else {
*ppCache = pCache; *ppCache = pCache;
@ -84,7 +84,7 @@ _exit:
int tdbPCacheClose(SPCache *pCache) { int tdbPCacheClose(SPCache *pCache) {
if (pCache) { if (pCache) {
tdbPCacheCloseImpl(pCache); (void)tdbPCacheCloseImpl(pCache);
tdbOsFree(pCache->aPage); tdbOsFree(pCache->aPage);
tdbOsFree(pCache); tdbOsFree(pCache);
} }
@ -149,7 +149,7 @@ static int tdbPCacheAlterImpl(SPCache *pCache, int32_t nPage) {
SPage *pPage = *ppPage; SPage *pPage = *ppPage;
*ppPage = pPage->pFreeNext; *ppPage = pPage->pFreeNext;
pCache->aPage[pPage->id] = NULL; pCache->aPage[pPage->id] = NULL;
tdbPageDestroy(pPage, tdbDefaultFree, NULL); (void)tdbPageDestroy(pPage, tdbDefaultFree, NULL);
pCache->nFree--; pCache->nFree--;
} else { } else {
ppPage = &(*ppPage)->pFreeNext; 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)); tdbTrace("pcache/free2 page: %p/%d, pgno:%d, ", pPage, pPage->id, TDB_PAGE_PGNO(pPage));
tdbPCacheRemovePageFromHash(pCache, 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); 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;;) { for (int nLoops = 0;;) {
if (pPageH->pPager) break; if (pPageH->pPager) break;
if (++nLoops > 1000) { if (++nLoops > 1000) {
sched_yield(); (void)sched_yield();
nLoops = 0; 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); tdbTrace("pcache destroy page: %p/%d/%d", pPage, TDB_PAGE_PGNO(pPage), pPage->id);
tdbPCacheRemovePageFromHash(pCache, pPage); tdbPCacheRemovePageFromHash(pCache, pPage);
tdbPageDestroy(pPage, tdbDefaultFree, NULL); (void)tdbPageDestroy(pPage, tdbDefaultFree, NULL);
} }
} }
@ -518,14 +518,14 @@ static int tdbPCacheCloseImpl(SPCache *pCache) {
// free free page // free free page
for (SPage *pPage = pCache->pFree; pPage;) { for (SPage *pPage = pCache->pFree; pPage;) {
SPage *pPageT = pPage->pFreeNext; SPage *pPageT = pPage->pFreeNext;
tdbPageDestroy(pPage, tdbDefaultFree, NULL); (void)tdbPageDestroy(pPage, tdbDefaultFree, NULL);
pPage = pPageT; pPage = pPageT;
} }
for (int32_t iBucket = 0; iBucket < pCache->nHash; iBucket++) { for (int32_t iBucket = 0; iBucket < pCache->nHash; iBucket++) {
for (SPage *pPage = pCache->pgHash[iBucket]; pPage;) { for (SPage *pPage = pCache->pgHash[iBucket]; pPage;) {
SPage *pPageT = pPage->pHashNext; SPage *pPageT = pPage->pHashNext;
tdbPageDestroy(pPage, tdbDefaultFree, NULL); (void)tdbPageDestroy(pPage, tdbDefaultFree, NULL);
pPage = pPageT; pPage = pPageT;
} }
} }

View File

@ -64,7 +64,7 @@ int tdbPageCreate(int pageSize, SPage **ppPage, void *(*xMalloc)(void *, size_t)
memset(ptr, 0, size); memset(ptr, 0, size);
pPage = (SPage *)(ptr + pageSize); pPage = (SPage *)(ptr + pageSize);
TDB_INIT_PAGE_LOCK(pPage); (void)TDB_INIT_PAGE_LOCK(pPage);
pPage->pageSize = pageSize; pPage->pageSize = pageSize;
pPage->pData = ptr; pPage->pData = ptr;
if (pageSize < 65536) { if (pageSize < 65536) {
@ -194,7 +194,7 @@ int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl
iOvfl++; iOvfl++;
} else { } else {
// page must has enough space to hold the cell locally // page must has enough space to hold the cell locally
tdbPageAllocate(pPage, szCell, &pNewCell); (void)tdbPageAllocate(pPage, szCell, &pNewCell);
memcpy(pNewCell, pCell, szCell); 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) { 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); return tdbPageInsertCell(pPage, idx, pCell, szCell, 0);
} }
@ -259,7 +259,7 @@ int tdbPageDropCell(SPage *pPage, int idx, TXN *pTxn, SBTree *pBt) {
lidx = idx - iOvfl; lidx = idx - iOvfl;
pCell = TDB_PAGE_CELL_AT(pPage, lidx); pCell = TDB_PAGE_CELL_AT(pPage, lidx);
szCell = (*pPage->xCellSize)(pPage, pCell, 1, pTxn, pBt); 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); TDB_PAGE_NCELLS_SET(pPage, nCells - 1);
for (; iOvfl < pPage->nOverflow; iOvfl++) { for (; iOvfl < pPage->nOverflow; iOvfl++) {

View File

@ -107,7 +107,7 @@ static int hashset_add(hashset_t set, void *item) {
set->nitems = 0; set->nitems = 0;
for (size_t i = 0; i < old_capacity; ++i) { 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); tdbOsFree(old_items);
} }
@ -223,7 +223,7 @@ int tdbPagerOpen(SPCache *pCache, const char *fileName, SPager **ppPager) {
int tdbPagerClose(SPager *pPager) { int tdbPagerClose(SPager *pPager) {
if (pPager) { if (pPager) {
tdbOsClose(pPager->fd); (void)tdbOsClose(pPager->fd);
tdbOsFree(pPager); tdbOsFree(pPager);
} }
return 0; return 0;
@ -236,14 +236,14 @@ int tdbPagerWrite(SPager *pPager, SPage *pPage) {
if (pPage->isDirty) return 0; if (pPage->isDirty) return 0;
// ref page one more time so the page will not be release // 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); tdbTrace("pager/mdirty page %p/%d/%d", pPage, TDB_PAGE_PGNO(pPage), pPage->id);
// Set page as dirty // Set page as dirty
pPage->isDirty = 1; pPage->isDirty = 1;
tdbTrace("tdb/pager-write: put page: %p %d to dirty tree: %p", pPage, TDB_PAGE_PGNO(pPage), &pPager->rbt); 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 // Write page to journal if neccessary
if (TDB_PAGE_PGNO(pPage) <= pPager->dbOrigSize && if (TDB_PAGE_PGNO(pPage) <= pPager->dbOrigSize &&
@ -256,7 +256,7 @@ int tdbPagerWrite(SPager *pPager, SPage *pPage) {
} }
if (pPager->pActiveTxn->jPageSet) { 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); tRBTreeDrop(&pPager->rbt, (SRBTreeNode *)pPage);
if (pTxn->jPageSet) { 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); 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; pPage->isDirty = 0;
tRBTreeDrop(&pPager->rbt, (SRBTreeNode *)pPage); 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); tdbPCacheMarkFree(pPager->pCache, pPage);
tdbPCacheRelease(pPager->pCache, pPage, pTxn); 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); memcpy(&pgid, pPager->fid, TDB_FILE_ID_LEN);
pgid.pgno = pgno; pgid.pgno = pgno;
while ((pPage = tdbPCacheFetch(pPager->pCache, &pgid, pTxn)) == NULL) { while ((pPage = tdbPCacheFetch(pPager->pCache, &pgid, pTxn)) == NULL) {
tdbPagerFlushPage(pPager, pTxn); (void)tdbPagerFlushPage(pPager, pTxn);
} }
tdbTrace("tdbttl fetch pager:%p", pPage->pPager); tdbTrace("tdbttl fetch pager:%p", pPage->pPager);
@ -815,7 +815,7 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) {
code = tdbTbcMoveToFirst(pCur); code = tdbTbcMoveToFirst(pCur);
if (code) { if (code) {
tdbError("tdb/remove-free-page: moveto first failed with ret: %d.", code); tdbError("tdb/remove-free-page: moveto first failed with ret: %d.", code);
tdbTbcClose(pCur); (void)tdbTbcClose(pCur);
return 0; return 0;
} }
@ -825,7 +825,7 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) {
code = tdbTbcGet(pCur, (const void **)&pKey, &nKey, NULL, NULL); code = tdbTbcGet(pCur, (const void **)&pKey, &nKey, NULL, NULL);
if (code < 0) { if (code < 0) {
// tdbError("tdb/remove-free-page: tbc get failed with ret: %d.", code); // tdbError("tdb/remove-free-page: tbc get failed with ret: %d.", code);
tdbTbcClose(pCur); (void)tdbTbcClose(pCur);
return 0; return 0;
} }
@ -836,10 +836,10 @@ static int tdbPagerRemoveFreePage(SPager *pPager, SPgno *pPgno, TXN *pTxn) {
code = tdbTbcDelete(pCur); code = tdbTbcDelete(pCur);
if (code < 0) { if (code < 0) {
tdbError("tdb/remove-free-page: tbc delete failed with ret: %d.", code); tdbError("tdb/remove-free-page: tbc delete failed with ret: %d.", code);
tdbTbcClose(pCur); (void)tdbTbcClose(pCur);
return 0; return 0;
} }
tdbTbcClose(pCur); (void)tdbTbcClose(pCur);
return 0; return 0;
} }
@ -892,7 +892,7 @@ static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage
lcode = TDB_TRY_LOCK_PAGE(pPage); lcode = TDB_TRY_LOCK_PAGE(pPage);
if (lcode == P_LOCK_SUCC) { if (lcode == P_LOCK_SUCC) {
if (TDB_PAGE_INITIALIZED(pPage)) { if (TDB_PAGE_INITIALIZED(pPage)) {
TDB_UNLOCK_PAGE(pPage); (void)TDB_UNLOCK_PAGE(pPage);
return 0; 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); tdbTrace("tdb/pager:%p, pgno:%d, nRead:%" PRId64, pPager, pgno, nRead);
if (nRead < pPage->pageSize) { if (nRead < pPage->pageSize) {
tdbError("tdb/pager:%p, pgno:%d, nRead:%" PRId64 "pgSize:%" PRId32, pPager, pgno, 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); return TAOS_SYSTEM_ERROR(errno);
} }
@ -953,7 +953,7 @@ static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage
if (ret < 0) { if (ret < 0) {
tdbError("tdb/pager:%p, pgno:%d, nRead:%" PRId64 "pgSize:%" PRId32 " init page failed.", pPager, pgno, nRead, tdbError("tdb/pager:%p, pgno:%d, nRead:%" PRId64 "pgSize:%" PRId32 " init page failed.", pPager, pgno, nRead,
pPage->pageSize); pPage->pageSize);
TDB_UNLOCK_PAGE(pPage); (void)TDB_UNLOCK_PAGE(pPage);
return ret; return ret;
} }
@ -961,7 +961,7 @@ static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage
pPage->pPager = pPager; pPage->pPager = pPager;
TDB_UNLOCK_PAGE(pPage); (void)TDB_UNLOCK_PAGE(pPage);
} else if (lcode == P_LOCK_BUSY) { } else if (lcode == P_LOCK_BUSY) {
nLoops = 0; nLoops = 0;
for (;;) { for (;;) {
@ -1162,7 +1162,7 @@ int tdbPagerRestoreJournals(SPager *pPager) {
char *name = tdbDirEntryBaseName(tdbGetDirEntryName(pDirEntry)); char *name = tdbDirEntryBaseName(tdbGetDirEntryName(pDirEntry));
if (strncmp(TDB_MAINDB_NAME "-journal", name, 16) == 0) { if (strncmp(TDB_MAINDB_NAME "-journal", name, 16) == 0) {
int64_t txnId = -1; 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) { if (taosArrayPush(pTxnList, &txnId) == NULL) {
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
@ -1179,14 +1179,14 @@ int tdbPagerRestoreJournals(SPager *pPager) {
code = tdbPagerRestore(pPager, jname); code = tdbPagerRestore(pPager, jname);
if (code) { if (code) {
taosArrayDestroy(pTxnList); taosArrayDestroy(pTxnList);
tdbCloseDir(&pDir); (void)tdbCloseDir(&pDir);
tdbError("failed to restore file due to %s. jFileName:%s", strerror(code), jname); tdbError("failed to restore file due to %s. jFileName:%s", strerror(code), jname);
return code; return code;
} }
} }
taosArrayDestroy(pTxnList); taosArrayDestroy(pTxnList);
tdbCloseDir(&pDir); (void)tdbCloseDir(&pDir);
return 0; return 0;
} }
@ -1209,7 +1209,7 @@ int tdbPagerRollback(SPager *pPager) {
jname[dirLen] = '/'; jname[dirLen] = '/';
memcpy(jname + dirLen + 1, name, strlen(name)); memcpy(jname + dirLen + 1, name, strlen(name));
if (tdbOsRemove(jname) < 0 && errno != ENOENT) { if (tdbOsRemove(jname) < 0 && errno != ENOENT) {
tdbCloseDir(&pDir); (void)tdbCloseDir(&pDir);
tdbError("failed to remove file due to %s. jFileName:%s", strerror(errno), name); tdbError("failed to remove file due to %s. jFileName:%s", strerror(errno), name);
return terrno = TAOS_SYSTEM_ERROR(errno); return terrno = TAOS_SYSTEM_ERROR(errno);
@ -1217,7 +1217,7 @@ int tdbPagerRollback(SPager *pPager) {
} }
} }
tdbCloseDir(&pDir); (void)tdbCloseDir(&pDir);
return 0; return 0;
} }

View File

@ -112,7 +112,7 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF
return ret; return ret;
} }
} else { } else {
tdbPagerRollback(pPager); (void)tdbPagerRollback(pPager);
} }
// pTb->pBt // pTb->pBt
@ -128,7 +128,7 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF
int tdbTbClose(TTB *pTb) { int tdbTbClose(TTB *pTb) {
if (pTb) { if (pTb) {
tdbBtreeClose(pTb->pBt); (void)tdbBtreeClose(pTb->pBt);
tdbOsFree(pTb); tdbOsFree(pTb);
} }
return 0; 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 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) { 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); return tdbTbInsert(pTb, pKey, kLen, pVal, vLen, pTxn);
} }
@ -224,7 +224,7 @@ int tdbTbcOpen(TTB *pTb, TBC **ppTbc, TXN *pTxn) {
return -1; return -1;
} }
tdbBtcOpen(&pTbc->btc, pTb->pBt, pTxn); (void)tdbBtcOpen(&pTbc->btc, pTb->pBt, pTxn);
*ppTbc = pTbc; *ppTbc = pTbc;
return 0; return 0;
@ -238,7 +238,7 @@ int32_t tdbTbTraversal(TTB *pTb, void *data,
return ret; return ret;
} }
tdbTbcMoveToFirst(pCur); (void)tdbTbcMoveToFirst(pCur);
void *pKey = NULL; void *pKey = NULL;
int kLen = 0; int kLen = 0;
@ -257,7 +257,7 @@ int32_t tdbTbTraversal(TTB *pTb, void *data,
} }
tdbFree(pKey); tdbFree(pKey);
tdbFree(pValue); tdbFree(pValue);
tdbTbcClose(pCur); (void)tdbTbcClose(pCur);
return 0; return 0;
} }
@ -292,7 +292,7 @@ int tdbTbcUpsert(TBC *pTbc, const void *pKey, int nKey, const void *pData, int n
int tdbTbcClose(TBC *pTbc) { int tdbTbcClose(TBC *pTbc) {
if (pTbc) { if (pTbc) {
tdbBtcClose(&pTbc->btc); (void)tdbBtcClose(&pTbc->btc);
tdbOsFree(pTbc); tdbOsFree(pTbc);
} }

View File

@ -13,6 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "tdbInt.h"
#ifndef _TDB_UTIL_H_ #ifndef _TDB_UTIL_H_
#define _TDB_UTIL_H_ #define _TDB_UTIL_H_
@ -56,8 +58,6 @@ static inline int tdbPutVarInt(u8 *p, int v) {
v >>= 7; v >>= 7;
} }
ASSERT(n < 6);
return n; return n;
} }
@ -79,8 +79,6 @@ static inline int tdbGetVarInt(const u8 *p, int *v) {
n++; n++;
} }
ASSERT(n < 6);
*v = tv; *v = tv;
return n; return n;
} }