Merge pull request #17298 from taosdata/fix/glzhao_coverity
fix: fix coverity issues
This commit is contained in:
commit
5a8172d6c2
|
@ -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;
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue