From fa2da69e7cecfe2ae1d31de25b0a933c6450d951 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Fri, 9 Aug 2024 17:36:20 +0800 Subject: [PATCH] refactor errno code --- source/libs/index/src/indexFilter.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/source/libs/index/src/indexFilter.c b/source/libs/index/src/indexFilter.c index 0d20fc6741..c362932da3 100644 --- a/source/libs/index/src/indexFilter.c +++ b/source/libs/index/src/indexFilter.c @@ -882,11 +882,10 @@ static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *ou if (ctx->noExec == false) { for (int32_t m = 0; m < node->pParameterList->length; m++) { if (node->condType == LOGIC_COND_TYPE_AND) { - (void)taosArrayAddAll(output->result, params[m].result); + if (taosArrayAddAll(output->result, params[m].result) == NULL) return terrno; } else if (node->condType == LOGIC_COND_TYPE_OR) { - (void)taosArrayAddAll(output->result, params[m].result); + if (taosArrayAddAll(output->result, params[m].result) == NULL) return terrno; } else if (node->condType == LOGIC_COND_TYPE_NOT) { - // taosArrayAddAll(output->result, params[m].result); } taosArraySort(output->result, uidCompare); taosArrayRemoveDuplicate(output->result, uidCompare, NULL); @@ -894,8 +893,6 @@ static int32_t sifExecLogic(SLogicConditionNode *node, SIFCtx *ctx, SIFParam *ou } else { for (int32_t m = 0; m < node->pParameterList->length; m++) { output->status = sifMergeCond(node->condType, output->status, params[m].status); - // taosArrayDestroy(params[m].result); - // params[m].result = NULL; } } _return: @@ -904,7 +901,7 @@ _return: } static EDealRes sifWalkFunction(SNode *pNode, void *context) { - SIFCtx *ctx = context; + SIFCtx *ctx = context; SFunctionNode *node = (SFunctionNode *)pNode; SIFParam output = {.result = taosArrayInit(8, sizeof(uint64_t)), .status = SFLT_COARSE_INDEX}; if (output.result == NULL) { @@ -924,7 +921,7 @@ static EDealRes sifWalkFunction(SNode *pNode, void *context) { return DEAL_RES_CONTINUE; } static EDealRes sifWalkLogic(SNode *pNode, void *context) { - SIFCtx *ctx = context; + SIFCtx *ctx = context; SLogicConditionNode *node = (SLogicConditionNode *)pNode; SIFParam output = {.result = taosArrayInit(8, sizeof(uint64_t)), .status = SFLT_COARSE_INDEX}; @@ -946,7 +943,7 @@ static EDealRes sifWalkLogic(SNode *pNode, void *context) { return DEAL_RES_CONTINUE; } static EDealRes sifWalkOper(SNode *pNode, void *context) { - SIFCtx *ctx = context; + SIFCtx *ctx = context; SOperatorNode *node = (SOperatorNode *)pNode; SIFParam output = {.result = taosArrayInit(8, sizeof(uint64_t)), .status = SFLT_COARSE_INDEX}; if (output.result == NULL) { @@ -1029,9 +1026,9 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) { SIF_ERR_RET(TSDB_CODE_APP_ERROR); } if (res->result != NULL) { - if (taosArrayAddAll(pDst->result, res->result) == NULL) { + if (taosArrayAddAll(pDst->result, res->result) == NULL) { SIF_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); - } + } } pDst->status = res->status; @@ -1090,7 +1087,7 @@ int32_t doFilterTag(SNode *pFilterNode, SIndexMetaArg *metaArg, SArray *result, SFilterInfo *filter = NULL; - SArray *output = taosArrayInit(8, sizeof(uint64_t)); + SArray *output = taosArrayInit(8, sizeof(uint64_t)); if (output == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -1107,11 +1104,13 @@ int32_t doFilterTag(SNode *pFilterNode, SIndexMetaArg *metaArg, SArray *result, *status = st; } - sifFreeParam(¶m); - if(taosArrayAddAll(result, param.result) == NULL) { + if (taosArrayAddAll(result, param.result) == NULL) { + sifFreeParam(¶m); return TSDB_CODE_OUT_OF_MEMORY; } + + sifFreeParam(¶m); return TSDB_CODE_SUCCESS; }