fix coverity scan problem
This commit is contained in:
parent
4d33387e80
commit
8fc33dd74d
|
@ -5644,6 +5644,7 @@ int32_t tDeserializeSOperatorParam(SDecoder *pDecoder, SOperatorParam* pOpParam)
|
|||
if (uidNum > 0) {
|
||||
pScan->pUidList = taosArrayInit(uidNum, sizeof(int64_t));
|
||||
if (NULL == pScan->pUidList) return -1;
|
||||
|
||||
for (int32_t m = 0; m < uidNum; ++m) {
|
||||
if (tDecodeI64(pDecoder, &uid) < 0) return -1;
|
||||
taosArrayPush(pScan->pUidList, &uid);
|
||||
|
@ -5660,6 +5661,7 @@ int32_t tDeserializeSOperatorParam(SDecoder *pDecoder, SOperatorParam* pOpParam)
|
|||
|
||||
int32_t childrenNum = 0;
|
||||
if (tDecodeI32(pDecoder, &childrenNum) < 0) return -1;
|
||||
|
||||
if (childrenNum > 0) {
|
||||
pOpParam->pChildren = taosArrayInit(childrenNum, POINTER_BYTES);
|
||||
if (NULL == pOpParam->pChildren) return -1;
|
||||
|
@ -5676,7 +5678,6 @@ int32_t tDeserializeSOperatorParam(SDecoder *pDecoder, SOperatorParam* pOpParam)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t tSerializeSResFetchReq(void *buf, int32_t bufLen, SResFetchReq *pReq) {
|
||||
int32_t headLen = sizeof(SMsgHead);
|
||||
if (buf != NULL) {
|
||||
|
@ -5933,7 +5934,6 @@ int32_t tDeserializeSTaskNotifyReq(void *buf, int32_t bufLen, STaskNotifyReq *pR
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t tSerializeSQueryTableRsp(void *buf, int32_t bufLen, SQueryTableRsp *pRsp) {
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, buf, bufLen);
|
||||
|
|
|
@ -91,7 +91,7 @@ int32_t streamStateSnapRead(SStreamStateReader* pReader, uint8_t** ppData) {
|
|||
uint8_t* rowData = NULL;
|
||||
int64_t len;
|
||||
code = streamSnapRead(pReader->pReaderImpl, &rowData, &len);
|
||||
if (rowData == NULL || len == 0) {
|
||||
if (code != 0 || rowData == NULL || len == 0) {
|
||||
return code;
|
||||
}
|
||||
*ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + len);
|
||||
|
|
|
@ -178,6 +178,10 @@ void bkdMgtDestroy(SBackendManager* bm) {
|
|||
|
||||
taosHashCleanup(bm->pSstTbl[0]);
|
||||
taosHashCleanup(bm->pSstTbl[1]);
|
||||
|
||||
taosMemoryFree(bm->pCurrent);
|
||||
taosMemoryFree(bm->pManifest);
|
||||
|
||||
taosMemoryFree(bm);
|
||||
}
|
||||
|
||||
|
@ -239,7 +243,7 @@ int32_t bkdMgtGetDelta(SBackendManager* bm, int64_t chkpId, SArray* list) {
|
|||
continue;
|
||||
}
|
||||
if (strlen(name) >= sstLen && strncmp(name + strlen(name) - 4, pSST, sstLen) == 0) {
|
||||
char* p = taosStrdup(name);
|
||||
// char* p = taosStrdup(name);
|
||||
taosHashPut(bm->pSstTbl[1 - bm->idx], name, strlen(name), &dummy, sizeof(dummy));
|
||||
continue;
|
||||
}
|
||||
|
@ -267,7 +271,7 @@ int32_t bkdMgtGetDelta(SBackendManager* bm, int64_t chkpId, SArray* list) {
|
|||
taosArrayClearP(bm->pDel, taosMemoryFree);
|
||||
taosHashClear(bm->pSstTbl[1 - bm->idx]);
|
||||
bm->update = 0;
|
||||
|
||||
taosCloseDir(&pDir);
|
||||
return code;
|
||||
}
|
||||
|
||||
|
@ -280,6 +284,8 @@ int32_t bkdMgtGetDelta(SBackendManager* bm, int64_t chkpId, SArray* list) {
|
|||
taosHashClear(bm->pSstTbl[bm->idx]);
|
||||
bm->idx = 1 - bm->idx;
|
||||
|
||||
taosCloseDir(&pDir);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -287,8 +293,8 @@ int32_t bkdMgtDumpTo(SBackendManager* bm, char* dname) {
|
|||
int32_t code = 0;
|
||||
int32_t len = bm->len + 128;
|
||||
|
||||
char* dstBuf = taosMemoryCalloc(1, len);
|
||||
char* srcBuf = taosMemoryCalloc(1, len);
|
||||
char* dstBuf = taosMemoryCalloc(1, len);
|
||||
|
||||
char* srcDir = taosMemoryCalloc(1, len);
|
||||
char* dstDir = taosMemoryCalloc(1, len);
|
||||
|
@ -297,12 +303,16 @@ int32_t bkdMgtDumpTo(SBackendManager* bm, char* dname) {
|
|||
sprintf(dstDir, "%s%s%s", bm->path, TD_DIRSEP, dname);
|
||||
|
||||
if (!taosDirExist(srcDir)) {
|
||||
return 0;
|
||||
qError("failed to dump srcDir %s, reason: not exist such dir", srcDir);
|
||||
code = -1;
|
||||
goto _ERROR;
|
||||
}
|
||||
|
||||
code = taosMkDir(dstDir);
|
||||
if (code != 0) {
|
||||
return code;
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
qError("failed to mkdir srcDir %s, reason: %s", dstDir, terrstr());
|
||||
goto _ERROR;
|
||||
}
|
||||
|
||||
// clear current file
|
||||
|
@ -353,6 +363,7 @@ int32_t bkdMgtDumpTo(SBackendManager* bm, char* dname) {
|
|||
taosArrayClearP(bm->pAdd, taosMemoryFree);
|
||||
taosArrayClearP(bm->pDel, taosMemoryFree);
|
||||
|
||||
_ERROR:
|
||||
taosMemoryFree(srcBuf);
|
||||
taosMemoryFree(dstBuf);
|
||||
taosMemoryFree(srcDir);
|
||||
|
@ -388,7 +399,11 @@ int32_t copyFiles(const char* src, const char* dst) {
|
|||
char* dstName = taosMemoryCalloc(1, dLen + 64);
|
||||
|
||||
TdDirPtr pDir = taosOpenDir(src);
|
||||
if (pDir == NULL) return 0;
|
||||
if (pDir == NULL) {
|
||||
taosMemoryFree(srcName);
|
||||
taosMemoryFree(dstName);
|
||||
return -1;
|
||||
}
|
||||
|
||||
TdDirEntryPtr de = NULL;
|
||||
while ((de = taosReadDir(pDir)) != NULL) {
|
||||
|
@ -1484,6 +1499,10 @@ int32_t streamStateOpenBackendCf(void* backend, char* name, char** cfs, int32_t
|
|||
params[i].tableOpt = tableOpt;
|
||||
|
||||
int idx = streamStateGetCfIdx(NULL, funcname);
|
||||
if (idx < 0 || idx >= sizeof(ginitDict) / sizeof(ginitDict[0])) {
|
||||
qError("failed to open cf");
|
||||
return -1;
|
||||
}
|
||||
SCfInit* cfPara = &ginitDict[idx];
|
||||
|
||||
rocksdb_comparator_t* compare =
|
||||
|
@ -2315,6 +2334,7 @@ int32_t streamStateSessionGetKVByCur_rocksdb(SStreamStateCur* pCur, SSessionKey*
|
|||
char* val = NULL;
|
||||
int32_t len = decodeValueFunc((void*)vval, vLen, NULL, &val);
|
||||
if (len < 0) {
|
||||
taosMemoryFree(val);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -2798,6 +2818,7 @@ char* streamDefaultIterVal_rocksdb(void* iter, int32_t* len) {
|
|||
const char* val = rocksdb_iter_value(pCur->iter, (size_t*)&vlen);
|
||||
*len = decodeValueFunc((void*)val, vlen, NULL, &ret);
|
||||
if (*len < 0) {
|
||||
taosMemoryFree(ret);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -343,6 +343,7 @@ int32_t streamSnapRead(SStreamSnapReader* pReader, uint8_t** ppData, int64_t* si
|
|||
uint8_t* buf = taosMemoryCalloc(1, sizeof(SStreamSnapBlockHdr) + kBlockSize);
|
||||
int64_t nread = taosPReadFile(pHandle->fd, buf + sizeof(SStreamSnapBlockHdr), kBlockSize, pHandle->offset);
|
||||
if (nread == -1) {
|
||||
taosMemoryFree(buf);
|
||||
code = TAOS_SYSTEM_ERROR(terrno);
|
||||
qError("%s snap failed to read snap, file name:%s, type:%d,reason:%s", STREAM_STATE_TRANSFER, item->name,
|
||||
item->type, tstrerror(code));
|
||||
|
|
Loading…
Reference in New Issue