Skip to content

Commit

Permalink
Merge pull request taosdata#14270 from fansehep/fan_3
Browse files Browse the repository at this point in the history
fix: some warnings by Coverity Scan in qAggMain.c
  • Loading branch information
guanshengliang authored Oct 24, 2022
2 parents 3425b8e + 30b1627 commit 77ca715
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/query/src/qAggMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -2406,15 +2406,15 @@ static void do_top_function_add(STopBotInfo *pInfo, int32_t maxLen, void *pData,
if (pInfo->num < maxLen) {
valuePairAssign(pList[pInfo->num], type, (const char *)&val.i64, ts, pTags, pTagInfo, stage);

taosheapsort((void *) pList, sizeof(tValuePair **), pInfo->num + 1, (const void *) &type, topBotComparFn, (const void *) &pTagInfo->tagsLen, topBotSwapFn, 0);
taosheapsort((void *) pList, sizeof(tValuePair *), pInfo->num + 1, (const void *) &type, topBotComparFn, (const void *) &pTagInfo->tagsLen, topBotSwapFn, 0);

pInfo->num++;
} else {
if ((IS_SIGNED_NUMERIC_TYPE(type) && val.i64 > pList[0]->v.i64) ||
(IS_UNSIGNED_NUMERIC_TYPE(type) && val.u64 > pList[0]->v.u64) ||
(IS_FLOAT_TYPE(type) && val.dKey > pList[0]->v.dKey)) {
valuePairAssign(pList[0], type, (const char *)&val.i64, ts, pTags, pTagInfo, stage);
taosheapadjust((void *) pList, sizeof(tValuePair **), 0, maxLen - 1, (const void *) &type, topBotComparFn, (const void *) &pTagInfo->tagsLen, topBotSwapFn, 0);
taosheapadjust((void *) pList, sizeof(tValuePair *), 0, maxLen - 1, (const void *) &type, topBotComparFn, (const void *) &pTagInfo->tagsLen, topBotSwapFn, 0);
}
}
}
Expand All @@ -2430,15 +2430,15 @@ static void do_bottom_function_add(STopBotInfo *pInfo, int32_t maxLen, void *pDa
if (pInfo->num < maxLen) {
valuePairAssign(pList[pInfo->num], type, (const char *)&val.i64, ts, pTags, pTagInfo, stage);

taosheapsort((void *) pList, sizeof(tValuePair **), pInfo->num + 1, (const void *) &type, topBotComparFn, (const void *) &pTagInfo->tagsLen, topBotSwapFn, 1);
taosheapsort((void *) pList, sizeof(tValuePair *), pInfo->num + 1, (const void *) &type, topBotComparFn, (const void *) &pTagInfo->tagsLen, topBotSwapFn, 1);

pInfo->num++;
} else {
if ((IS_SIGNED_NUMERIC_TYPE(type) && val.i64 < pList[0]->v.i64) ||
(IS_UNSIGNED_NUMERIC_TYPE(type) && val.u64 < pList[0]->v.u64) ||
(IS_FLOAT_TYPE(type) && val.dKey < pList[0]->v.dKey)) {
valuePairAssign(pList[0], type, (const char *)&val.i64, ts, pTags, pTagInfo, stage);
taosheapadjust((void *) pList, sizeof(tValuePair **), 0, maxLen - 1, (const void *) &type, topBotComparFn, (const void *) &pTagInfo->tagsLen, topBotSwapFn, 1);
taosheapadjust((void *) pList, sizeof(tValuePair *), 0, maxLen - 1, (const void *) &type, topBotComparFn, (const void *) &pTagInfo->tagsLen, topBotSwapFn, 1);
}
}
}
Expand Down Expand Up @@ -5049,7 +5049,7 @@ static void do_reservoir_sample(SQLFunctionCtx *pCtx, SSampleFuncInfo *pInfo, in
assignResultSample(pCtx, pInfo, pInfo->numSampled, ts, pData, type, bytes, NULL);
pInfo->numSampled++;
} else {
int32_t j = rand() % (pInfo->totalPoints);
int32_t j = random() % (pInfo->totalPoints);
if (j < samplesK) {
assignResultSample(pCtx, pInfo, j, ts, pData, type, bytes, NULL);
}
Expand Down Expand Up @@ -5749,12 +5749,12 @@ static void do_tail_function_add(STailInfo *pInfo, int32_t maxLen, void *pData,
if (pInfo->num < maxLen) {
valueTailAssign(pList[pInfo->num], bytes, pData, ts, pTagInfo, pTags, stage);

taosheapsort((void *) pList, sizeof(TailUnit **), pInfo->num + 1, NULL, tailComparFn, NULL, tailSwapFn, 0);
taosheapsort((void *) pList, sizeof(TailUnit *), pInfo->num + 1, NULL, tailComparFn, NULL, tailSwapFn, 0);

pInfo->num++;
} else if(pList[0]->timestamp < ts) {
valueTailAssign(pList[0], bytes, pData, ts, pTagInfo, pTags, stage);
taosheapadjust((void *) pList, sizeof(TailUnit **), 0, maxLen - 1, NULL, tailComparFn, NULL, tailSwapFn, 0);
taosheapadjust((void *) pList, sizeof(TailUnit *), 0, maxLen - 1, NULL, tailComparFn, NULL, tailSwapFn, 0);
}
}

Expand Down Expand Up @@ -6674,4 +6674,4 @@ SAggFunctionInfo aAggs[TSDB_FUNC_MAX_NUM] = {{
hll_func_merge,
dataBlockRequired,
}
};
};

0 comments on commit 77ca715

Please sign in to comment.