Skip to content

Commit

Permalink
Merge pull request #22810 from taosdata/fix/m/TD-26136
Browse files Browse the repository at this point in the history
fix: coverity issues
  • Loading branch information
dapan1121 committed Sep 11, 2023
2 parents 70fc33a + 952d6e1 commit f831bf7
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 23 deletions.
3 changes: 2 additions & 1 deletion source/common/src/ttime.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,8 @@ int32_t taosTimeCountIntervalForFill(int64_t skey, int64_t ekey, int64_t interva
}

int64_t taosTimeTruncate(int64_t ts, const SInterval* pInterval) {
if (pInterval->sliding == 0 && pInterval->interval == 0) {
if (pInterval->sliding == 0) {
ASSERT(pInterval->interval == 0);
return ts;
}

Expand Down
42 changes: 25 additions & 17 deletions source/libs/planner/src/planOptimizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -3221,8 +3221,11 @@ int32_t stbJoinOptAddFuncToScanNode(char* funcName, SScanLogicNode* pScan) {
SFunctionNode* pUidFunc = createFunction(funcName, NULL);
snprintf(pUidFunc->node.aliasName, sizeof(pUidFunc->node.aliasName), "%s.%p",
pUidFunc->functionName, pUidFunc);
nodesListStrictAppend(pScan->pScanPseudoCols, (SNode *)pUidFunc);
return createColumnByRewriteExpr((SNode*)pUidFunc, &pScan->node.pTargets);
int32_t code = nodesListStrictAppend(pScan->pScanPseudoCols, (SNode *)pUidFunc);
if (TSDB_CODE_SUCCESS == code) {
code = createColumnByRewriteExpr((SNode*)pUidFunc, &pScan->node.pTargets);
}
return code;
}


Expand Down Expand Up @@ -3369,12 +3372,7 @@ static int32_t stbJoinOptCreateTableScanNodes(SLogicNode* pJoin, SNodeList** ppL
pScan->scanType = SCAN_TYPE_TABLE;
}

if (TSDB_CODE_SUCCESS == code) {
*ppList = pList;
} else {
nodesDestroyList(pList);
*ppList = NULL;
}
*ppList = pList;

return code;
}
Expand Down Expand Up @@ -3478,12 +3476,15 @@ static int32_t stbJoinOptCreateMergeJoinNode(SLogicNode* pOrig, SLogicNode* pChi
FOREACH(pNode, pJoin->node.pChildren) {
ERASE_NODE(pJoin->node.pChildren);
}
nodesListStrictAppend(pJoin->node.pChildren, (SNode *)pChild);
pChild->pParent = (SLogicNode*)pJoin;

*ppLogic = (SLogicNode*)pJoin;
int32_t code = nodesListStrictAppend(pJoin->node.pChildren, (SNode *)pChild);
if (TSDB_CODE_SUCCESS == code) {
pChild->pParent = (SLogicNode*)pJoin;
*ppLogic = (SLogicNode*)pJoin;
} else {
nodesDestroyNode((SNode*)pJoin);
}

return TSDB_CODE_SUCCESS;
return code;
}

static int32_t stbJoinOptCreateDynQueryCtrlNode(SLogicNode* pRoot, SLogicNode* pPrev, SLogicNode* pPost, bool* srcScan, SLogicNode** ppDynNode) {
Expand Down Expand Up @@ -3523,11 +3524,18 @@ static int32_t stbJoinOptCreateDynQueryCtrlNode(SLogicNode* pRoot, SLogicNode* p
nodesListStrictAppend(pDynCtrl->stbJoin.pUidList, nodesListGetNode(pHJoin->node.pTargets, 2));
nodesListStrictAppend(pDynCtrl->stbJoin.pVgList, nodesListGetNode(pHJoin->node.pTargets, 1));
nodesListStrictAppend(pDynCtrl->stbJoin.pVgList, nodesListGetNode(pHJoin->node.pTargets, 3));

if (TSDB_CODE_SUCCESS == code) {
nodesListStrictAppend(pDynCtrl->node.pChildren, (SNode*)pPrev);
nodesListStrictAppend(pDynCtrl->node.pChildren, (SNode*)pPost);
pDynCtrl->node.pTargets = nodesCloneList(pPost->pTargets);
code = nodesListStrictAppend(pDynCtrl->node.pChildren, (SNode*)pPrev);
if (TSDB_CODE_SUCCESS == code) {
code = nodesListStrictAppend(pDynCtrl->node.pChildren, (SNode*)pPost);
}
if (TSDB_CODE_SUCCESS == code) {
pDynCtrl->node.pTargets = nodesCloneList(pPost->pTargets);
if (!pDynCtrl->node.pTargets) {
code = TSDB_CODE_OUT_OF_MEMORY;
}
}
}

if (TSDB_CODE_SUCCESS == code) {
Expand Down
8 changes: 3 additions & 5 deletions source/libs/planner/src/planPhysiCreater.c
Original file line number Diff line number Diff line change
Expand Up @@ -1025,11 +1025,7 @@ static int32_t createGroupCachePhysiNode(SPhysiPlanContext* pCxt, SNodeList* pCh
}
*/

if (TSDB_CODE_SUCCESS == code) {
*pPhyNode = (SPhysiNode*)pGrpCache;
} else {
nodesDestroyNode((SNode*)pGrpCache);
}
*pPhyNode = (SPhysiNode*)pGrpCache;

return code;
}
Expand Down Expand Up @@ -1059,6 +1055,8 @@ static int32_t updateDynQueryCtrlStbJoinInfo(SPhysiPlanContext* pCxt, SNodeList*
}
pDynCtrl->stbJoin.batchFetch = pLogicNode->stbJoin.batchFetch;
}
nodesDestroyList(pVgList);
nodesDestroyList(pUidList);

return code;
}
Expand Down
3 changes: 3 additions & 0 deletions source/libs/scalar/src/scalar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1671,6 +1671,9 @@ static int32_t sclGetJsonOperatorResType(SOperatorNode *pOp) {
}

static int32_t sclGetBitwiseOperatorResType(SOperatorNode *pOp) {
if (!pOp->pLeft || !pOp->pRight) {
return TSDB_CODE_TSC_INVALID_OPERATION;
}
SDataType ldt = ((SExprNode *)(pOp->pLeft))->resType;
SDataType rdt = ((SExprNode *)(pOp->pRight))->resType;
if(TSDB_DATA_TYPE_VARBINARY == ldt.type || TSDB_DATA_TYPE_VARBINARY == rdt.type){
Expand Down
1 change: 1 addition & 0 deletions source/libs/scalar/src/sclvector.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ static FORCE_INLINE void varToVarbinary(char *buf, SScalarParam *pOut, int32_t r
if (t == NULL) {
sclError("Out of memory");
terrno = TSDB_CODE_OUT_OF_MEMORY;
taosMemoryFree(data);
return;
}
varDataSetLen(t, size);
Expand Down

0 comments on commit f831bf7

Please sign in to comment.