Merge pull request #17474 from taosdata/fix/TD-19250-4
fix: coverity issues
This commit is contained in:
commit
09a77b3b97
|
@ -343,6 +343,8 @@ typedef struct {
|
||||||
} SSchemaWrapper;
|
} SSchemaWrapper;
|
||||||
|
|
||||||
static FORCE_INLINE SSchemaWrapper* tCloneSSchemaWrapper(const SSchemaWrapper* pSchemaWrapper) {
|
static FORCE_INLINE SSchemaWrapper* tCloneSSchemaWrapper(const SSchemaWrapper* pSchemaWrapper) {
|
||||||
|
if (pSchemaWrapper->pSchema == NULL) return NULL;
|
||||||
|
|
||||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosMemoryMalloc(sizeof(SSchemaWrapper));
|
SSchemaWrapper* pSW = (SSchemaWrapper*)taosMemoryMalloc(sizeof(SSchemaWrapper));
|
||||||
if (pSW == NULL) return pSW;
|
if (pSW == NULL) return pSW;
|
||||||
pSW->nCols = pSchemaWrapper->nCols;
|
pSW->nCols = pSchemaWrapper->nCols;
|
||||||
|
@ -352,6 +354,7 @@ static FORCE_INLINE SSchemaWrapper* tCloneSSchemaWrapper(const SSchemaWrapper* p
|
||||||
taosMemoryFree(pSW);
|
taosMemoryFree(pSW);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(pSW->pSchema, pSchemaWrapper->pSchema, pSW->nCols * sizeof(SSchema));
|
memcpy(pSW->pSchema, pSchemaWrapper->pSchema, pSW->nCols * sizeof(SSchema));
|
||||||
return pSW;
|
return pSW;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) {
|
||||||
if (tEncodeI64(pCoder, pME->version) < 0) return -1;
|
if (tEncodeI64(pCoder, pME->version) < 0) return -1;
|
||||||
if (tEncodeI8(pCoder, pME->type) < 0) return -1;
|
if (tEncodeI8(pCoder, pME->type) < 0) return -1;
|
||||||
if (tEncodeI64(pCoder, pME->uid) < 0) return -1;
|
if (tEncodeI64(pCoder, pME->uid) < 0) return -1;
|
||||||
if (tEncodeCStr(pCoder, pME->name) < 0) return -1;
|
if (pME->name == NULL || tEncodeCStr(pCoder, pME->name) < 0) return -1;
|
||||||
|
|
||||||
if (pME->type == TSDB_SUPER_TABLE) {
|
if (pME->type == TSDB_SUPER_TABLE) {
|
||||||
if (tEncodeI8(pCoder, pME->flags) < 0) return -1; // TODO: need refactor?
|
if (tEncodeI8(pCoder, pME->flags) < 0) return -1; // TODO: need refactor?
|
||||||
|
|
|
@ -1094,6 +1094,7 @@ static int tdbBtreeEncodePayload(SPage *pPage, SCell *pCell, int nHeader, const
|
||||||
// fetch next ofp, a new ofp and make it dirty
|
// fetch next ofp, a new ofp and make it dirty
|
||||||
ret = tdbFetchOvflPage(&pgno, &nextOfp, pTxn, pBt);
|
ret = tdbFetchOvflPage(&pgno, &nextOfp, pTxn, pBt);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
tdbFree(pBuf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1135,6 +1136,11 @@ static int tdbBtreeEncodePayload(SPage *pPage, SCell *pCell, int nHeader, const
|
||||||
memcpy(pBuf, ((SCell *)pVal) + vLen - nLeft, bytes);
|
memcpy(pBuf, ((SCell *)pVal) + vLen - nLeft, bytes);
|
||||||
memcpy(pBuf + bytes, &pgno, sizeof(pgno));
|
memcpy(pBuf + bytes, &pgno, sizeof(pgno));
|
||||||
|
|
||||||
|
if (ofp == NULL) {
|
||||||
|
tdbFree(pBuf);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ret = tdbPageInsertCell(ofp, 0, pBuf, bytes + sizeof(pgno), 0);
|
ret = tdbPageInsertCell(ofp, 0, pBuf, bytes + sizeof(pgno), 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
tdbFree(pBuf);
|
tdbFree(pBuf);
|
||||||
|
|
|
@ -106,7 +106,8 @@ int32_t tdbBegin(TDB *pDb, TXN *pTxn) {
|
||||||
for (pPager = pDb->pgrList; pPager; pPager = pPager->pNext) {
|
for (pPager = pDb->pgrList; pPager; pPager = pPager->pNext) {
|
||||||
ret = tdbPagerBegin(pPager, pTxn);
|
ret = tdbPagerBegin(pPager, pTxn);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
tdbError("failed to begin pager since %s. dbName:%s, txnId:%ld", tstrerror(terrno), pDb->dbName, pTxn->txnId);
|
tdbError("failed to begin pager since %s. dbName:%s, txnId:%" PRId64, tstrerror(terrno), pDb->dbName,
|
||||||
|
pTxn->txnId);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,7 +122,8 @@ int32_t tdbCommit(TDB *pDb, TXN *pTxn) {
|
||||||
for (pPager = pDb->pgrList; pPager; pPager = pPager->pNext) {
|
for (pPager = pDb->pgrList; pPager; pPager = pPager->pNext) {
|
||||||
ret = tdbPagerCommit(pPager, pTxn);
|
ret = tdbPagerCommit(pPager, pTxn);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
tdbError("failed to commit pager since %s. dbName:%s, txnId:%ld", tstrerror(terrno), pDb->dbName, pTxn->txnId);
|
tdbError("failed to commit pager since %s. dbName:%s, txnId:%" PRId64, tstrerror(terrno), pDb->dbName,
|
||||||
|
pTxn->txnId);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,7 +153,8 @@ int32_t tdbAbort(TDB *pDb, TXN *pTxn) {
|
||||||
for (pPager = pDb->pgrList; pPager; pPager = pPager->pNext) {
|
for (pPager = pDb->pgrList; pPager; pPager = pPager->pNext) {
|
||||||
ret = tdbPagerAbort(pPager, pTxn);
|
ret = tdbPagerAbort(pPager, pTxn);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
tdbError("failed to abort pager since %s. dbName:%s, txnId:%ld", tstrerror(terrno), pDb->dbName, pTxn->txnId);
|
tdbError("failed to abort pager since %s. dbName:%s, txnId:%" PRId64, tstrerror(terrno), pDb->dbName,
|
||||||
|
pTxn->txnId);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ static int tdbPCacheAlterImpl(SPCache *pCache, int32_t nPage) {
|
||||||
for (int32_t iPage = pCache->nPages; iPage < nPage; iPage++) {
|
for (int32_t iPage = pCache->nPages; iPage < nPage; iPage++) {
|
||||||
if (tdbPageCreate(pCache->szPage, &aPage[iPage], tdbDefaultMalloc, NULL) < 0) {
|
if (tdbPageCreate(pCache->szPage, &aPage[iPage], tdbDefaultMalloc, NULL) < 0) {
|
||||||
// TODO: handle error
|
// TODO: handle error
|
||||||
tdbOsFree(pCache->aPage);
|
tdbOsFree(aPage);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -575,7 +575,7 @@ static int tdbPagerWritePageToDB(SPager *pPager, SPage *pPage) {
|
||||||
|
|
||||||
offset = (i64)pPage->pageSize * (TDB_PAGE_PGNO(pPage) - 1);
|
offset = (i64)pPage->pageSize * (TDB_PAGE_PGNO(pPage) - 1);
|
||||||
if (tdbOsLSeek(pPager->fd, offset, SEEK_SET) < 0) {
|
if (tdbOsLSeek(pPager->fd, offset, SEEK_SET) < 0) {
|
||||||
tdbError("failed to lseek due to %s. file:%s, offset:%ld", strerror(errno), pPager->dbFileName, offset);
|
tdbError("failed to lseek due to %s. file:%s, offset:%" PRId64, strerror(errno), pPager->dbFileName, offset);
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -630,7 +630,7 @@ int tdbPagerRestore(SPager *pPager, SBTree *pBt) {
|
||||||
|
|
||||||
i64 offset = pPager->pageSize * (pgno - 1);
|
i64 offset = pPager->pageSize * (pgno - 1);
|
||||||
if (tdbOsLSeek(pPager->fd, offset, SEEK_SET) < 0) {
|
if (tdbOsLSeek(pPager->fd, offset, SEEK_SET) < 0) {
|
||||||
tdbError("failed to lseek fd due to %s. file:%s, offset:%ld", strerror(errno), pPager->dbFileName, offset);
|
tdbError("failed to lseek fd due to %s. file:%s, offset:%" PRId64, strerror(errno), pPager->dbFileName, offset);
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
tdbOsFree(pageBuf);
|
tdbOsFree(pageBuf);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in New Issue