提交 4e1f5b29 编写于 作者: M Minglei Jin

fix(meta): cleanup coverity scan issues

上级 1a75fa71
...@@ -55,8 +55,8 @@ struct SMetaCache { ...@@ -55,8 +55,8 @@ struct SMetaCache {
// query cache // query cache
struct STagFilterResCache { struct STagFilterResCache {
TdThreadMutex lock; TdThreadMutex lock;
SHashObj* pTableEntry; SHashObj* pTableEntry;
SLRUCache* pUidResCache; SLRUCache* pUidResCache;
} sTagFilterResCache; } sTagFilterResCache;
}; };
...@@ -563,13 +563,13 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int ...@@ -563,13 +563,13 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int
} }
// add to cache. // add to cache.
taosLRUCacheInsert(pCache, buf, sizeof(uint64_t) + keyLen, pPayload, payloadLen, freePayload, NULL, int32_t ret = taosLRUCacheInsert(pCache, buf, sizeof(uint64_t) + keyLen, pPayload, payloadLen, freePayload, NULL,
TAOS_LRU_PRIORITY_LOW); TAOS_LRU_PRIORITY_LOW);
taosThreadMutexUnlock(pLock); taosThreadMutexUnlock(pLock);
metaDebug("vgId:%d, suid:%" PRIu64 " list cache added into cache, total:%d, tables:%d", TD_VID(pMeta->pVnode), suid, metaDebug("vgId:%d, suid:%" PRIu64 " list cache added into cache, total:%d, tables:%d, ret:%d", TD_VID(pMeta->pVnode),
(int32_t)taosLRUCacheGetUsage(pCache), taosHashGetSize(pTableEntry)); suid, (int32_t)taosLRUCacheGetUsage(pCache), taosHashGetSize(pTableEntry), ret);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
......
...@@ -653,8 +653,10 @@ int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sv ...@@ -653,8 +653,10 @@ int32_t metaGetTbTSchemaEx(SMeta *pMeta, tb_uid_t suid, tb_uid_t uid, int32_t sv
} }
if (c == 0) { if (c == 0) {
metaError("meta/query: incorrect c: %" PRId32 ".", c); metaULock(pMeta);
tdbTbcClose(pSkmDbC);
code = TSDB_CODE_FAILED; code = TSDB_CODE_FAILED;
metaError("meta/query: incorrect c: %" PRId32 ".", c);
goto _exit; goto _exit;
} }
......
...@@ -343,6 +343,10 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { ...@@ -343,6 +343,10 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) {
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL); tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
ret = tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = pReq->suid, .version = oversion}), sizeof(STbDbKey), &c); ret = tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = pReq->suid, .version = oversion}), sizeof(STbDbKey), &c);
if (!(ret == 0 && c == 0)) { if (!(ret == 0 && c == 0)) {
tdbTbcClose(pUidIdxc);
tdbTbcClose(pTbDbc);
terrno = TSDB_CODE_TDB_STB_NOT_EXIST;
metaError("meta/table: invalide ret: %" PRId32 " or c: %" PRId32 "alter stb failed.", ret, c); metaError("meta/table: invalide ret: %" PRId32 " or c: %" PRId32 "alter stb failed.", ret, c);
return -1; return -1;
} }
...@@ -783,6 +787,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl ...@@ -783,6 +787,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL); tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c); tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
if (c != 0) { if (c != 0) {
tdbTbcClose(pUidIdxc);
metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c); metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c);
return -1; return -1;
} }
...@@ -796,6 +801,8 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl ...@@ -796,6 +801,8 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL); tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c); tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
if (c != 0) { if (c != 0) {
tdbTbcClose(pUidIdxc);
tdbTbcClose(pTbDbc);
metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c); metaError("meta/table: invalide c: %" PRId32 " alt tb column failed.", c);
return -1; return -1;
} }
...@@ -809,6 +816,8 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl ...@@ -809,6 +816,8 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl
tDecoderInit(&dc, entry.pBuf, nData); tDecoderInit(&dc, entry.pBuf, nData);
ret = metaDecodeEntry(&dc, &entry); ret = metaDecodeEntry(&dc, &entry);
if (ret != 0) { if (ret != 0) {
tdbTbcClose(pUidIdxc);
tdbTbcClose(pTbDbc);
tDecoderClear(&dc); tDecoderClear(&dc);
metaError("meta/table: invalide ret: %" PRId32 " alt tb column failed.", ret); metaError("meta/table: invalide ret: %" PRId32 " alt tb column failed.", ret);
return -1; return -1;
...@@ -989,6 +998,8 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA ...@@ -989,6 +998,8 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL); tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c); tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
if (c != 0) { if (c != 0) {
tdbTbcClose(pUidIdxc);
terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST;
metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c); metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c);
return -1; return -1;
} }
...@@ -1005,6 +1016,9 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA ...@@ -1005,6 +1016,9 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL); tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c); tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
if (c != 0) { if (c != 0) {
tdbTbcClose(pUidIdxc);
tdbTbcClose(pTbDbc);
terrno = TSDB_CODE_TDB_TABLE_NOT_EXIST;
metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c); metaError("meta/table: invalide c: %" PRId32 " update tb tag val failed.", c);
return -1; return -1;
} }
...@@ -1166,6 +1180,7 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p ...@@ -1166,6 +1180,7 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL); tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL);
tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c); tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c);
if (c != 0) { if (c != 0) {
tdbTbcClose(pUidIdxc);
metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c); metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c);
return -1; return -1;
} }
...@@ -1179,6 +1194,8 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p ...@@ -1179,6 +1194,8 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p
tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL); tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL);
tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c); tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c);
if (c != 0) { if (c != 0) {
tdbTbcClose(pUidIdxc);
tdbTbcClose(pTbDbc);
metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c); metaError("meta/table: invalide c: %" PRId32 " update tb options failed.", c);
return -1; return -1;
} }
......
...@@ -262,9 +262,10 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) { ...@@ -262,9 +262,10 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
tjsonGetNumberValue(info, "nodePort", pNode->nodePort, code); tjsonGetNumberValue(info, "nodePort", pNode->nodePort, code);
if (code < 0) return -1; if (code < 0) return -1;
tjsonGetStringValue(info, "nodeFqdn", pNode->nodeFqdn); tjsonGetStringValue(info, "nodeFqdn", pNode->nodeFqdn);
if (code < 0) return -1;
tjsonGetNumberValue(info, "nodeId", pNode->nodeId, code); tjsonGetNumberValue(info, "nodeId", pNode->nodeId, code);
if (code < 0) return -1;
tjsonGetNumberValue(info, "clusterId", pNode->clusterId, code); tjsonGetNumberValue(info, "clusterId", pNode->clusterId, code);
if (code < 0) return -1;
vDebug("vgId:%d, decode config, replica:%d ep:%s:%u dnode:%d", pCfg->vgId, i, pNode->nodeFqdn, pNode->nodePort, vDebug("vgId:%d, decode config, replica:%d ep:%s:%u dnode:%d", pCfg->vgId, i, pNode->nodeFqdn, pNode->nodePort,
pNode->nodeId); pNode->nodeId);
} }
......
...@@ -731,8 +731,8 @@ static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage ...@@ -731,8 +731,8 @@ static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage
int ret; int ret;
int lcode; int lcode;
int nLoops; int nLoops;
i64 nRead; i64 nRead = 0;
SPgno pgno; SPgno pgno = 0;
int init = 0; int init = 0;
lcode = TDB_TRY_LOCK_PAGE(pPage); lcode = TDB_TRY_LOCK_PAGE(pPage);
......
...@@ -191,7 +191,7 @@ int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime) { ...@@ -191,7 +191,7 @@ int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime) {
int32_t code = _stati64(path, &fileStat); int32_t code = _stati64(path, &fileStat);
#else #else
struct stat fileStat; struct stat fileStat;
int32_t code = stat(path, &fileStat); int32_t code = stat(path, &fileStat);
#endif #endif
if (code < 0) { if (code < 0) {
return code; return code;
...@@ -232,7 +232,7 @@ int32_t taosDevInoFile(TdFilePtr pFile, int64_t *stDev, int64_t *stIno) { ...@@ -232,7 +232,7 @@ int32_t taosDevInoFile(TdFilePtr pFile, int64_t *stDev, int64_t *stIno) {
#else #else
struct stat fileStat; struct stat fileStat;
int32_t code = fstat(pFile->fd, &fileStat); int32_t code = fstat(pFile->fd, &fileStat);
if (code < 0) { if (code < 0) {
printf("taosFStatFile run fstat fail."); printf("taosFStatFile run fstat fail.");
return code; return code;
...@@ -439,6 +439,9 @@ int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count) { ...@@ -439,6 +439,9 @@ int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count) {
taosThreadRwlockWrlock(&(pFile->rwlock)); taosThreadRwlockWrlock(&(pFile->rwlock));
#endif #endif
if (pFile->fd < 0) { if (pFile->fd < 0) {
#if FILE_WITH_LOCK
taosThreadRwlockUnlock(&(pFile->rwlock));
#endif
return 0; return 0;
} }
...@@ -543,7 +546,7 @@ int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime) { ...@@ -543,7 +546,7 @@ int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int32_t *mtime) {
int32_t taosLockFile(TdFilePtr pFile) { int32_t taosLockFile(TdFilePtr pFile) {
ASSERT(pFile->fd >= 0); // Please check if you have closed the file. ASSERT(pFile->fd >= 0); // Please check if you have closed the file.
if(pFile->fd < 0) { if (pFile->fd < 0) {
return -1; return -1;
} }
#ifdef WINDOWS #ifdef WINDOWS
...@@ -570,13 +573,13 @@ int32_t taosLockFile(TdFilePtr pFile) { ...@@ -570,13 +573,13 @@ int32_t taosLockFile(TdFilePtr pFile) {
int32_t taosUnLockFile(TdFilePtr pFile) { int32_t taosUnLockFile(TdFilePtr pFile) {
ASSERT(pFile->fd >= 0); ASSERT(pFile->fd >= 0);
if(pFile->fd < 0) { if (pFile->fd < 0) {
return 0; return 0;
} }
#ifdef WINDOWS #ifdef WINDOWS
BOOL fSuccess = FALSE; BOOL fSuccess = FALSE;
OVERLAPPED overlapped = {0}; OVERLAPPED overlapped = {0};
HANDLE hFile = (HANDLE)_get_osfhandle(pFile->fd); HANDLE hFile = (HANDLE)_get_osfhandle(pFile->fd);
fSuccess = UnlockFileEx(hFile, 0, ~0, ~0, &overlapped); fSuccess = UnlockFileEx(hFile, 0, ~0, ~0, &overlapped);
if (!fSuccess) { if (!fSuccess) {
...@@ -592,7 +595,7 @@ int32_t taosFtruncateFile(TdFilePtr pFile, int64_t l_size) { ...@@ -592,7 +595,7 @@ int32_t taosFtruncateFile(TdFilePtr pFile, int64_t l_size) {
if (pFile == NULL) { if (pFile == NULL) {
return 0; return 0;
} }
if(pFile->fd < 0) { if (pFile->fd < 0) {
printf("Ftruncate file error, fd arg was negative\n"); printf("Ftruncate file error, fd arg was negative\n");
return -1; return -1;
} }
...@@ -669,7 +672,7 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in ...@@ -669,7 +672,7 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in
return 0; return 0;
} }
ASSERT(pFileIn->fd >= 0 && pFileOut->fd >= 0); ASSERT(pFileIn->fd >= 0 && pFileOut->fd >= 0);
if(pFileIn->fd < 0 || pFileOut->fd < 0) { if (pFileIn->fd < 0 || pFileOut->fd < 0) {
return 0; return 0;
} }
...@@ -829,7 +832,7 @@ int32_t taosEOFFile(TdFilePtr pFile) { ...@@ -829,7 +832,7 @@ int32_t taosEOFFile(TdFilePtr pFile) {
return -1; return -1;
} }
ASSERT(pFile->fp != NULL); ASSERT(pFile->fp != NULL);
if(pFile->fp == NULL) { if (pFile->fp == NULL) {
return -1; return -1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册