other: fix coverity issue.

This commit is contained in:
Haojun Liao 2024-07-04 19:20:07 +08:00
parent 9d015722c3
commit 799f61c2db
3 changed files with 17 additions and 12 deletions

View File

@ -3459,11 +3459,15 @@ static int32_t tagScanFilterByTagCond(SArray* aUidTags, SNode* pTagCond, SArray*
SScalarParam output = {0};
code = tagScanCreateResultData(&type, numOfTables, &output);
if (TSDB_CODE_SUCCESS != code) {
blockDataDestroy(pResBlock);
taosArrayDestroy(pBlockList);
return code;
}
code = scalarCalculate(pTagCond, pBlockList, &output);
if (TSDB_CODE_SUCCESS != code) {
blockDataDestroy(pResBlock);
taosArrayDestroy(pBlockList);
return code;
}

View File

@ -238,6 +238,9 @@ int32_t remoteChkp_readMetaData(char* path, SArray* list) {
sprintf(metaPath, "%s%s%s", path, TD_DIRSEP, "META");
TdFilePtr pFile = taosOpenFile(path, TD_FILE_READ);
if (pFile == NULL) {
return -1;
}
char buf[128] = {0};
if (taosReadFile(pFile, buf, sizeof(buf)) <= 0) {
@ -245,7 +248,8 @@ int32_t remoteChkp_readMetaData(char* path, SArray* list) {
taosCloseFile(&pFile);
return -1;
}
int32_t len = strlen(buf);
int32_t len = strnlen(buf, tListLen(buf));
for (int i = 0; i < len; i++) {
if (buf[i] == '\n') {
char* item = taosMemoryCalloc(1, i + 1);
@ -2117,9 +2121,7 @@ void taskDbDestroy(void* pDb, bool flush) {
stDebug("succ to destroy stream backend:%p", wrapper);
int8_t nCf = sizeof(ginitDict) / sizeof(ginitDict[0]);
if (wrapper == NULL) return;
int8_t nCf = tListLen(ginitDict);
if (flush) {
if (wrapper->db && wrapper->pCf) {
@ -4223,7 +4225,8 @@ int32_t dbChkpDumpTo(SDbChkp* p, char* dname, SArray* list) {
static char* chkpMeta = "META";
memset(dstBuf, 0, len);
sprintf(dstDir, "%s%s%s", dstDir, TD_DIRSEP, chkpMeta);
sprintf(dstBuf, "%s%s%s", dstDir, TD_DIRSEP, chkpMeta);
tstrncpy(dstDir, dstBuf, strlen(dstBuf) + 1);
TdFilePtr pFile = taosOpenFile(dstDir, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC);
if (pFile == NULL) {

View File

@ -312,17 +312,12 @@ int32_t streamSnapHandleInit(SStreamSnapHandle* pHandle, char* path, void* pMeta
ASSERT(code == 0);
taosArrayPush(pDbSnapSet, &snapFile);
}
pHandle->pDbSnapSet = pDbSnapSet;
pHandle->pSnapInfoSet = pSnapInfoSet;
pHandle->currIdx = 0;
pHandle->pMeta = pMeta;
return 0;
_err:
streamSnapHandleDestroy(pHandle);
code = -1;
return code;
}
void streamSnapHandleDestroy(SStreamSnapHandle* handle) {
@ -444,6 +439,7 @@ _NEXT:
pSnapFile = taosArrayGet(pHandle->pDbSnapSet, pHandle->currIdx);
goto _NEXT;
} else {
taosMemoryFree(buf);
*ppData = NULL;
*size = 0;
return 0;
@ -465,7 +461,9 @@ _NEXT:
pHdr->totalSize = item->size;
pHdr->snapInfo = pSnapFile->snapInfo;
memcpy(pHdr->name, item->name, strlen(item->name));
int32_t len = TMIN(strlen(item->name), tListLen(pHdr->name));
memcpy(pHdr->name, item->name, len);
pSnapFile->seraial += nread;
*ppData = buf;