未验证 提交 5a8172d6 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #17298 from taosdata/fix/glzhao_coverity

fix: fix coverity issues
......@@ -184,22 +184,54 @@ void tmq_commit_cb_print(tmq_t* tmq, int32_t code, void* param) {
tmq_t* build_consumer() {
tmq_conf_res_t code;
tmq_conf_t* conf = tmq_conf_new();
code = tmq_conf_set(conf, "enable.auto.commit", "true");
if (TMQ_CONF_OK != code) return NULL;
if (TMQ_CONF_OK != code) {
tmq_conf_destroy(conf);
return NULL;
}
code = tmq_conf_set(conf, "auto.commit.interval.ms", "1000");
if (TMQ_CONF_OK != code) return NULL;
if (TMQ_CONF_OK != code) {
tmq_conf_destroy(conf);
return NULL;
}
code = tmq_conf_set(conf, "group.id", "cgrpName");
if (TMQ_CONF_OK != code) return NULL;
if (TMQ_CONF_OK != code) {
tmq_conf_destroy(conf);
return NULL;
}
code = tmq_conf_set(conf, "client.id", "user defined name");
if (TMQ_CONF_OK != code) return NULL;
if (TMQ_CONF_OK != code) {
tmq_conf_destroy(conf);
return NULL;
}
code = tmq_conf_set(conf, "td.connect.user", "root");
if (TMQ_CONF_OK != code) return NULL;
if (TMQ_CONF_OK != code) {
tmq_conf_destroy(conf);
return NULL;
}
code = tmq_conf_set(conf, "td.connect.pass", "taosdata");
if (TMQ_CONF_OK != code) return NULL;
if (TMQ_CONF_OK != code) {
tmq_conf_destroy(conf);
return NULL;
}
code = tmq_conf_set(conf, "auto.offset.reset", "earliest");
if (TMQ_CONF_OK != code) return NULL;
if (TMQ_CONF_OK != code) {
tmq_conf_destroy(conf);
return NULL;
}
code = tmq_conf_set(conf, "experimental.snapshot.enable", "false");
if (TMQ_CONF_OK != code) return NULL;
if (TMQ_CONF_OK != code) {
tmq_conf_destroy(conf);
return NULL;
}
tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL);
......
......@@ -411,7 +411,7 @@ _exit:
int32_t tTSRowClone(const STSRow2 *pRow, STSRow2 **ppRow) {
int32_t code = 0;
int32_t rLen;
int32_t rLen = 0;
TSROW_LEN(pRow, rLen);
(*ppRow) = (STSRow2 *)taosMemoryMalloc(rLen);
......@@ -1678,8 +1678,8 @@ int32_t tColDataCopy(SColData *pColDataSrc, SColData *pColDataDest) {
int32_t size;
ASSERT(pColDataSrc->nVal > 0);
ASSERT(pColDataDest->cid = pColDataSrc->cid);
ASSERT(pColDataDest->type = pColDataSrc->type);
ASSERT(pColDataDest->cid == pColDataSrc->cid);
ASSERT(pColDataDest->type == pColDataSrc->type);
pColDataDest->smaOn = pColDataSrc->smaOn;
pColDataDest->nVal = pColDataSrc->nVal;
......@@ -1711,4 +1711,4 @@ int32_t tColDataCopy(SColData *pColDataSrc, SColData *pColDataDest) {
_exit:
return code;
}
\ No newline at end of file
}
......@@ -35,7 +35,7 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
// tscError("tmp file created failed since %s", terrstr());
return NULL;
}
STSBuf* pTSBuf = taosMemoryCalloc(1, sizeof(STSBuf));
if (pTSBuf == NULL) {
return NULL;
......@@ -52,10 +52,13 @@ STSBuf* tsBufCreate(bool autoDelete, int32_t order) {
}
if (!autoDelete) {
taosRemoveFile(pTSBuf->path);
if (taosRemoveFile(pTSBuf->path) != 0) {
taosMemoryFree(pTSBuf);
return NULL;
}
}
if (NULL == allocResForTSBuf(pTSBuf)) {
if (allocResForTSBuf(pTSBuf) == NULL) {
return NULL;
}
......
......@@ -1939,7 +1939,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) {
bytes = (len + 1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE;
fi->data = taosMemoryCalloc(1, bytes);
} else{
} else {
if (dType->type == TSDB_DATA_TYPE_VALUE_ARRAY) { //TIME RANGE
/*
fi->data = taosMemoryCalloc(dType->bytes, tDataTypes[type].bytes);
......
......@@ -363,7 +363,11 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
}
SSDataBlock *block = *(SSDataBlock **)taosArrayGet(ctx->pBlockList, index);
if (NULL == block || ref->slotId >= taosArrayGetSize(block->pDataBlock)) {
if (NULL == block) {
SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
}
if (ref->slotId >= taosArrayGetSize(block->pDataBlock)) {
sclError("column slotId is too big, slodId:%d, dataBlockSize:%d", ref->slotId, (int32_t)taosArrayGetSize(block->pDataBlock));
SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
}
......
......@@ -2002,7 +2002,7 @@ int32_t avgScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *
}
}
if (hasNull) {
if (hasNull || (count == 0)) {
colDataAppendNULL(pOutputData, 0);
} else {
if (IS_SIGNED_NUMERIC_TYPE(type)) {
......
......@@ -281,7 +281,7 @@ static FORCE_INLINE void varToTimestamp(char *buf, SScalarParam* pOut, int32_t r
if (taosParseTime(buf, &value, strlen(buf), pOut->columnData->info.precision, tsDaylight) != TSDB_CODE_SUCCESS) {
value = 0;
}
colDataAppendInt64(pOut->columnData, rowIndex, &value);
}
......@@ -300,29 +300,29 @@ static FORCE_INLINE void varToSigned(char *buf, SScalarParam* pOut, int32_t rowI
*overflow = 0;
}
}
switch (pOut->columnData->info.type) {
case TSDB_DATA_TYPE_TINYINT: {
int8_t value = (int8_t)taosStr2Int8(buf, NULL, 10);
colDataAppendInt8(pOut->columnData, rowIndex, (int8_t*)&value);
break;
}
}
case TSDB_DATA_TYPE_SMALLINT: {
int16_t value = (int16_t)taosStr2Int16(buf, NULL, 10);
colDataAppendInt16(pOut->columnData, rowIndex, (int16_t*)&value);
break;
}
}
case TSDB_DATA_TYPE_INT: {
int32_t value = (int32_t)taosStr2Int32(buf, NULL, 10);
colDataAppendInt32(pOut->columnData, rowIndex, (int32_t*)&value);
break;
}
}
case TSDB_DATA_TYPE_BIGINT: {
int64_t value = (int64_t)taosStr2Int64(buf, NULL, 10);
colDataAppendInt64(pOut->columnData, rowIndex, (int64_t*)&value);
break;
}
}
}
}
......@@ -347,22 +347,22 @@ static FORCE_INLINE void varToUnsigned(char *buf, SScalarParam* pOut, int32_t ro
uint8_t value = (uint8_t)taosStr2UInt8(buf, NULL, 10);
colDataAppendInt8(pOut->columnData, rowIndex, (int8_t*)&value);
break;
}
}
case TSDB_DATA_TYPE_USMALLINT: {
uint16_t value = (uint16_t)taosStr2UInt16(buf, NULL, 10);
colDataAppendInt16(pOut->columnData, rowIndex, (int16_t*)&value);
break;
}
}
case TSDB_DATA_TYPE_UINT: {
uint32_t value = (uint32_t)taosStr2UInt32(buf, NULL, 10);
colDataAppendInt32(pOut->columnData, rowIndex, (int32_t*)&value);
break;
}
}
case TSDB_DATA_TYPE_UBIGINT: {
uint64_t value = (uint64_t)taosStr2UInt64(buf, NULL, 10);
colDataAppendInt64(pOut->columnData, rowIndex, (int64_t*)&value);
break;
}
}
}
}
......@@ -372,7 +372,7 @@ static FORCE_INLINE void varToFloat(char *buf, SScalarParam* pOut, int32_t rowIn
colDataAppendFloat(pOut->columnData, rowIndex, &value);
return;
}
double value = taosStr2Double(buf, NULL);
colDataAppendDouble(pOut->columnData, rowIndex, &value);
}
......@@ -488,11 +488,11 @@ int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, in
tmp[len] = 0;
}
}
(*func)(tmp, pOut, i, overflow);
taosMemoryFreeClear(tmp);
}
return TSDB_CODE_SUCCESS;
}
......@@ -529,24 +529,24 @@ void* ncharTobinary(void *buf){ // todo need to remove , if tobinary
bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t typeRight, char **pLeftData, char **pRightData,
void *pLeftOut, void *pRightOut, bool *isNull, bool *freeLeft, bool *freeRight){
if(optr == OP_TYPE_JSON_CONTAINS) {
if (optr == OP_TYPE_JSON_CONTAINS) {
return true;
}
if(typeLeft != TSDB_DATA_TYPE_JSON && typeRight != TSDB_DATA_TYPE_JSON){
if (typeLeft != TSDB_DATA_TYPE_JSON && typeRight != TSDB_DATA_TYPE_JSON) {
return true;
}
if(typeLeft == TSDB_DATA_TYPE_JSON){
if(tTagIsJson(*pLeftData)){
if (typeLeft == TSDB_DATA_TYPE_JSON) {
if (tTagIsJson(*pLeftData)) {
terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR;
return false;
}
typeLeft = **pLeftData;
(*pLeftData) ++;
}
if(typeRight == TSDB_DATA_TYPE_JSON){
if(tTagIsJson(*pLeftData)){
if (typeRight == TSDB_DATA_TYPE_JSON) {
if (tTagIsJson(*pLeftData)) {
terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR;
return false;
}
......@@ -554,71 +554,71 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t
(*pRightData) ++;
}
if(optr == OP_TYPE_LIKE || optr == OP_TYPE_NOT_LIKE || optr == OP_TYPE_MATCH || optr == OP_TYPE_NMATCH){
if(typeLeft != TSDB_DATA_TYPE_NCHAR && typeLeft != TSDB_DATA_TYPE_BINARY){
if (optr == OP_TYPE_LIKE || optr == OP_TYPE_NOT_LIKE || optr == OP_TYPE_MATCH || optr == OP_TYPE_NMATCH) {
if (typeLeft != TSDB_DATA_TYPE_NCHAR && typeLeft != TSDB_DATA_TYPE_BINARY) {
return false;
}
}
// if types can not comparable
if((IS_NUMERIC_TYPE(typeLeft) && !IS_NUMERIC_TYPE(typeRight)) ||
(IS_NUMERIC_TYPE(typeRight) && !IS_NUMERIC_TYPE(typeLeft)) ||
(IS_VAR_DATA_TYPE(typeLeft) && !IS_VAR_DATA_TYPE(typeRight)) ||
(IS_VAR_DATA_TYPE(typeRight) && !IS_VAR_DATA_TYPE(typeLeft)) ||
((typeLeft == TSDB_DATA_TYPE_BOOL) && (typeRight != TSDB_DATA_TYPE_BOOL)) ||
((typeRight == TSDB_DATA_TYPE_BOOL) && (typeLeft != TSDB_DATA_TYPE_BOOL)))
if ((IS_NUMERIC_TYPE(typeLeft) && !IS_NUMERIC_TYPE(typeRight)) ||
(IS_NUMERIC_TYPE(typeRight) && !IS_NUMERIC_TYPE(typeLeft)) ||
(IS_VAR_DATA_TYPE(typeLeft) && !IS_VAR_DATA_TYPE(typeRight)) ||
(IS_VAR_DATA_TYPE(typeRight) && !IS_VAR_DATA_TYPE(typeLeft)) ||
((typeLeft == TSDB_DATA_TYPE_BOOL) && (typeRight != TSDB_DATA_TYPE_BOOL)) ||
((typeRight == TSDB_DATA_TYPE_BOOL) && (typeLeft != TSDB_DATA_TYPE_BOOL)))
return false;
if(typeLeft == TSDB_DATA_TYPE_NULL || typeRight == TSDB_DATA_TYPE_NULL){
if (typeLeft == TSDB_DATA_TYPE_NULL || typeRight == TSDB_DATA_TYPE_NULL) {
*isNull = true;
return true;
}
int8_t type = vectorGetConvertType(typeLeft, typeRight);
if(type == 0) {
if (type == 0) {
*fp = filterGetCompFunc(typeLeft, optr);
return true;
}
*fp = filterGetCompFunc(type, optr);
if(IS_NUMERIC_TYPE(type)){
if(typeLeft == TSDB_DATA_TYPE_NCHAR) {
if (IS_NUMERIC_TYPE(type)) {
if (typeLeft == TSDB_DATA_TYPE_NCHAR) {
ASSERT(0);
// convertNcharToDouble(*pLeftData, pLeftOut);
// *pLeftData = pLeftOut;
} else if(typeLeft == TSDB_DATA_TYPE_BINARY) {
} else if (typeLeft == TSDB_DATA_TYPE_BINARY) {
ASSERT(0);
// convertBinaryToDouble(*pLeftData, pLeftOut);
// *pLeftData = pLeftOut;
} else if(typeLeft != type) {
} else if (typeLeft != type) {
convertNumberToNumber(*pLeftData, pLeftOut, typeLeft, type);
*pLeftData = pLeftOut;
}
if(typeRight == TSDB_DATA_TYPE_NCHAR) {
if (typeRight == TSDB_DATA_TYPE_NCHAR) {
ASSERT(0);
// convertNcharToDouble(*pRightData, pRightOut);
// *pRightData = pRightOut;
} else if(typeRight == TSDB_DATA_TYPE_BINARY) {
} else if (typeRight == TSDB_DATA_TYPE_BINARY) {
ASSERT(0);
// convertBinaryToDouble(*pRightData, pRightOut);
// *pRightData = pRightOut;
} else if(typeRight != type) {
} else if (typeRight != type) {
convertNumberToNumber(*pRightData, pRightOut, typeRight, type);
*pRightData = pRightOut;
}
}else if(type == TSDB_DATA_TYPE_BINARY){
if(typeLeft == TSDB_DATA_TYPE_NCHAR){
} else if (type == TSDB_DATA_TYPE_BINARY) {
if (typeLeft == TSDB_DATA_TYPE_NCHAR) {
*pLeftData = ncharTobinary(*pLeftData);
*freeLeft = true;
}
if(typeRight == TSDB_DATA_TYPE_NCHAR){
if (typeRight == TSDB_DATA_TYPE_NCHAR) {
*pRightData = ncharTobinary(*pRightData);
*freeRight = true;
}
}else{
} else {
ASSERT(0);
}
......@@ -636,7 +636,7 @@ int32_t vectorConvertToVarData(const SScalarParam* pIn, SScalarParam* pOut, int1
colDataAppendNULL(pOutputCol, i);
continue;
}
int64_t value = 0;
GET_TYPED_DATA(value, int64_t, inType, colDataGetData(pInputCol, i));
int32_t len = sprintf(varDataVal(tmp), "%" PRId64, value);
......@@ -653,7 +653,7 @@ int32_t vectorConvertToVarData(const SScalarParam* pIn, SScalarParam* pOut, int1
colDataAppendNULL(pOutputCol, i);
continue;
}
uint64_t value = 0;
GET_TYPED_DATA(value, uint64_t, inType, colDataGetData(pInputCol, i));
int32_t len = sprintf(varDataVal(tmp), "%" PRIu64, value);
......@@ -670,7 +670,7 @@ int32_t vectorConvertToVarData(const SScalarParam* pIn, SScalarParam* pOut, int1
colDataAppendNULL(pOutputCol, i);
continue;
}
double value = 0;
GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, i));
int32_t len = sprintf(varDataVal(tmp), "%lf", value);
......@@ -698,7 +698,7 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t*
sclError("input column is NULL, hashFilter %p", pIn->pHashFilter);
return TSDB_CODE_APP_ERROR;
}
int16_t inType = pInputCol->info.type;
int16_t outType = pOutputCol->info.type;
......@@ -710,14 +710,14 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t*
ASSERT(1 == pIn->numOfRows);
pOut->numOfRows = 0;
if (IS_SIGNED_NUMERIC_TYPE(outType)) {
int64_t minValue = tDataTypes[outType].minValue;
int64_t maxValue = tDataTypes[outType].maxValue;
double value = 0;
GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, 0));
if (value > maxValue) {
*overflow = 1;
return TSDB_CODE_SUCCESS;
......@@ -730,10 +730,10 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t*
} else if (IS_UNSIGNED_NUMERIC_TYPE(outType)) {
uint64_t minValue = (uint64_t)tDataTypes[outType].minValue;
uint64_t maxValue = (uint64_t)tDataTypes[outType].maxValue;
double value = 0;
GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, 0));
if (value > maxValue) {
*overflow = 1;
return TSDB_CODE_SUCCESS;
......@@ -820,7 +820,7 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t*
colDataAppendNULL(pOutputCol, i);
continue;
}
uint8_t value = 0;
GET_TYPED_DATA(value, uint8_t, inType, colDataGetData(pInputCol, i));
colDataAppendInt8(pOutputCol, i, (int8_t *)&value);
......@@ -833,7 +833,7 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t*
colDataAppendNULL(pOutputCol, i);
continue;
}
uint16_t value = 0;
GET_TYPED_DATA(value, uint16_t, inType, colDataGetData(pInputCol, i));
colDataAppendInt16(pOutputCol, i, (int16_t *)&value);
......@@ -846,7 +846,7 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t*
colDataAppendNULL(pOutputCol, i);
continue;
}
uint32_t value = 0;
GET_TYPED_DATA(value, uint32_t, inType, colDataGetData(pInputCol, i));
colDataAppendInt32(pOutputCol, i, (int32_t *)&value);
......@@ -859,7 +859,7 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t*
colDataAppendNULL(pOutputCol, i);
continue;
}
uint64_t value = 0;
GET_TYPED_DATA(value, uint64_t, inType, colDataGetData(pInputCol, i));
colDataAppendInt64(pOutputCol, i, (int64_t*)&value);
......@@ -872,12 +872,12 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t*
colDataAppendNULL(pOutputCol, i);
continue;
}
float value = 0;
GET_TYPED_DATA(value, float, inType, colDataGetData(pInputCol, i));
colDataAppendFloat(pOutputCol, i, (float*)&value);
}
break;
break;
}
case TSDB_DATA_TYPE_DOUBLE: {
for (int32_t i = 0; i < pIn->numOfRows; ++i) {
......@@ -885,14 +885,14 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t*
colDataAppendNULL(pOutputCol, i);
continue;
}
double value = 0;
GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, i));
colDataAppendDouble(pOutputCol, i, (double*)&value);
}
break;
break;
}
case TSDB_DATA_TYPE_BINARY:
case TSDB_DATA_TYPE_BINARY:
case TSDB_DATA_TYPE_NCHAR: {
return vectorConvertToVarData(pIn, pOut, inType, outType);
}
......@@ -966,10 +966,10 @@ int32_t vectorConvert(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam* p
return TSDB_CODE_SUCCESS;
}
SScalarParam *param1 = NULL, *paramOut1 = NULL;
SScalarParam *param1 = NULL, *paramOut1 = NULL;
SScalarParam *param2 = NULL, *paramOut2 = NULL;
int32_t code = 0;
if (leftType < rightType) {
param1 = pLeft;
param2 = pRight;
......@@ -993,7 +993,7 @@ int32_t vectorConvert(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam* p
return code;
}
}
if (type != GET_PARAM_TYPE(param2)) {
code = vectorConvertScalarParam(param2, paramOut2, type);
if (code) {
......@@ -1136,7 +1136,7 @@ void vectorMathAdd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
}
*output = getVectorBigintValueFnLeft(pLeftCol->pData, i) + getVectorBigintValueFnRight(pRightCol->pData, i);
}
}
}
} else {
double *output = (double *)pOutputCol->pData;
_getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type);
......@@ -1198,7 +1198,7 @@ static void vectorMathTsSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pR
}
*output = taosTimeAdd(getVectorBigintValueFnLeft(pLeftCol->pData, i), -getVectorBigintValueFnRight(pRightCol->pData, 0),
pRightCol->info.scale, pRightCol->info.precision);
}
}
}
......@@ -1706,7 +1706,7 @@ void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *
int32_t lType = GET_PARAM_TYPE(pLeft);
int32_t rType = GET_PARAM_TYPE(pRight);
__compar_fn_t fp = NULL;
if (lType == rType) {
fp = filterGetCompFunc(lType, optr);
} else {
......@@ -1736,9 +1736,9 @@ void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *
}
void vectorCompare(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord, int32_t optr) {
SScalarParam pLeftOut = {0};
SScalarParam pLeftOut = {0};
SScalarParam pRightOut = {0};
SScalarParam *param1 = NULL;
SScalarParam *param1 = NULL;
SScalarParam *param2 = NULL;
if (SCL_NO_NEED_CONVERT_COMPARISION(GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), optr)) {
......@@ -1762,7 +1762,7 @@ void vectorCompare(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
vectorCompareImpl(param1, param2, pOut, _ord, optr);
sclFreeParam(&pLeftOut);
sclFreeParam(&pRightOut);
sclFreeParam(&pRightOut);
}
void vectorGreater(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册