Merge pull request #26818 from taosdata/enh/TD-30996-fix

enh:[TD-30996] Handling return value
This commit is contained in:
dapan1121 2024-07-29 08:51:01 +08:00 committed by GitHub
commit 59c3d3c5e5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 101 additions and 78 deletions

View File

@ -917,17 +917,17 @@ void taos_init_imp(void) {
if (tscDbg.memEnable) {
int32_t code = taosMemoryDbgInit();
if (code) {
printf("failed to init memory dbg, error:%s\n", tstrerror(code));
(void)printf("failed to init memory dbg, error:%s\n", tstrerror(code));
} else {
tsAsyncLog = false;
printf("memory dbg enabled\n");
(void)printf("memory dbg enabled\n");
}
}
#endif
// In the APIs of other program language, taos_cleanup is not available yet.
// So, to make sure taos_cleanup will be invoked to clean up the allocated resource to suppress the valgrind warning.
atexit(taos_cleanup);
(void)atexit(taos_cleanup);
errno = TSDB_CODE_SUCCESS;
taosSeedRand(taosGetTimestampSec());
@ -950,7 +950,7 @@ void taos_init_imp(void) {
(void)snprintf(logDirName, 64, "taoslog");
#endif
if (taosCreateLog(logDirName, 10, configDir, NULL, NULL, NULL, NULL, 1) != 0) {
printf(" WARING: Create %s failed:%s. configDir=%s\n", logDirName, strerror(errno), configDir);
(void)printf(" WARING: Create %s failed:%s. configDir=%s\n", logDirName, strerror(errno), configDir);
tscInitRes = -1;
return;
}
@ -994,7 +994,7 @@ void taos_init_imp(void) {
}
int taos_init() {
taosThreadOnce(&tscinit, taos_init_imp);
(void)taosThreadOnce(&tscinit, taos_init_imp);
return tscInitRes;
}

View File

@ -1330,6 +1330,10 @@ static void *hbThreadFunc(void *param) {
continue;
}
int tlen = tSerializeSClientHbBatchReq(NULL, 0, pReq);
if (tlen == -1) {
tFreeClientHbBatchReq(pReq);
break;
}
void *buf = taosMemoryMalloc(tlen);
if (buf == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
@ -1338,7 +1342,11 @@ static void *hbThreadFunc(void *param) {
break;
}
tSerializeSClientHbBatchReq(buf, tlen, pReq);
if (tSerializeSClientHbBatchReq(buf, tlen, pReq) == -1) {
tFreeClientHbBatchReq(pReq);
taosMemoryFree(buf);
break;
}
SMsgSendInfo *pInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
if (pInfo == NULL) {
@ -1361,10 +1369,12 @@ static void *hbThreadFunc(void *param) {
SAppInstInfo *pAppInstInfo = pAppHbMgr->pAppInstInfo;
int64_t transporterId = 0;
SEpSet epSet = getEpSet_s(&pAppInstInfo->mgmtEp);
asyncSendMsgToServer(pAppInstInfo->pTransporter, &epSet, &transporterId, pInfo);
if (TSDB_CODE_SUCCESS != asyncSendMsgToServer(pAppInstInfo->pTransporter, &epSet, &transporterId, pInfo)) {
tscWarn("failed to async send msg to server");
}
tFreeClientHbBatchReq(pReq);
// hbClearReqInfo(pAppHbMgr);
atomic_add_fetch_32(&pAppHbMgr->reportCnt, 1);
(void)atomic_add_fetch_32(&pAppHbMgr->reportCnt, 1);
}
if (TSDB_CODE_SUCCESS != taosThreadMutexUnlock(&clientHbMgr.lock)) {
@ -1629,7 +1639,7 @@ void hbDeregisterConn(STscObj *pTscObj, SClientHbKey connKey) {
SClientHbReq *pReq = taosHashAcquire(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey));
if (pReq) {
tFreeClientHbReq(pReq);
taosHashRemove(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey));
(void)taosHashRemove(pAppHbMgr->activeInfo, &connKey, sizeof(SClientHbKey));
taosHashRelease(pAppHbMgr->activeInfo, pReq);
(void)atomic_sub_fetch_32(&pAppHbMgr->connKeyCnt, 1);
}

View File

@ -1083,7 +1083,7 @@ void postSubQueryFetchCb(void* param, TAOS_RES* res, int32_t rowNum) {
SRequestObj* pNextReq = acquireRequest(pRequest->relation.nextRefId);
if (pNextReq) {
continuePostSubQuery(pNextReq, pBlock);
releaseRequest(pRequest->relation.nextRefId);
(void)releaseRequest(pRequest->relation.nextRefId);
} else {
tscError("0x%" PRIx64 ", next req ref 0x%" PRIx64 " is not there, reqId:0x%" PRIx64, pRequest->self,
pRequest->relation.nextRefId, pRequest->requestId);
@ -2545,7 +2545,7 @@ int32_t appendTbToReq(SHashObj* pHash, int32_t pos1, int32_t len1, int32_t pos2,
}
char dbFName[TSDB_DB_FNAME_LEN];
sprintf(dbFName, "%d.%.*s", acctId, dbLen, dbName);
(void)sprintf(dbFName, "%d.%.*s", acctId, dbLen, dbName);
STablesReq* pDb = taosHashGet(pHash, dbFName, strlen(dbFName));
if (pDb) {

View File

@ -484,7 +484,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getSchemaMetaData
(*env)->SetIntField(env, metadataObj, g_metadataColindexField, i);
jstring metadataObjColname = (*env)->NewStringUTF(env, fields[i].name);
(*env)->SetObjectField(env, metadataObj, g_metadataColnameField, metadataObjColname);
(*env)->CallBooleanMethod(env, arrayListObj, g_arrayListAddFp, metadataObj);
(void)(*env)->CallBooleanMethod(env, arrayListObj, g_arrayListAddFp, metadataObj);
}
}

View File

@ -42,7 +42,7 @@ int taos_options(TSDB_OPTION option, const void *arg, ...) {
for (int i = 1; atomic_val_compare_exchange_32(&lock, 0, 1) != 0; ++i) {
if (i % 1000 == 0) {
tscInfo("haven't acquire lock after spin %d times.", i);
sched_yield();
(void)sched_yield();
}
}
@ -754,7 +754,7 @@ bool taos_is_update_query(TAOS_RES *res) { return taos_num_fields(res) == 0; }
int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) {
int32_t numOfRows = 0;
/*int32_t code = */ taos_fetch_block_s(res, &numOfRows, rows);
/*int32_t code = */ terrno = taos_fetch_block_s(res, &numOfRows, rows);
return numOfRows;
}

View File

@ -709,11 +709,12 @@ const int tkLogStbNum = ARRAY_SIZE(tkLogStb);
const int tkAuditStbNum = ARRAY_SIZE(tkAuditStb);
// exclude stbs of taoskeeper log
static int32_t vnodeGetTimeSeriesBlackList(SVnode *pVnode) {
int32_t tbSize = 0;
static int32_t vnodeGetTimeSeriesBlackList(SVnode *pVnode, int32_t *tbSize) {
int32_t code = TSDB_CODE_SUCCESS;
int32_t tbNum = 0;
const char **pTbArr = NULL;
const char *dbName = NULL;
*tbSize = 0;
if (!(dbName = strchr(pVnode->config.dbname, '.'))) return 0;
if (0 == strncmp(++dbName, "log", TSDB_DB_NAME_LEN)) {
@ -724,19 +725,22 @@ static int32_t vnodeGetTimeSeriesBlackList(SVnode *pVnode) {
pTbArr = (const char **)&tkAuditStb;
}
if (tbNum && pTbArr) {
tbSize = metaSizeOfTbFilterCache(pVnode->pMeta, 0);
if (tbSize < tbNum) {
*tbSize = metaSizeOfTbFilterCache(pVnode->pMeta, 0);
if (*tbSize < tbNum) {
for (int32_t i = 0; i < tbNum; ++i) {
tb_uid_t suid = metaGetTableEntryUidByName(pVnode->pMeta, pTbArr[i]);
if (suid != 0) {
metaPutTbToFilterCache(pVnode->pMeta, &suid, 0);
code = metaPutTbToFilterCache(pVnode->pMeta, &suid, 0);
if (TSDB_CODE_SUCCESS != code) {
return code;
}
}
}
tbSize = metaSizeOfTbFilterCache(pVnode->pMeta, 0);
*tbSize = metaSizeOfTbFilterCache(pVnode->pMeta, 0);
}
}
return tbSize;
return code;
}
#endif
@ -758,8 +762,12 @@ int32_t vnodeGetTimeSeriesNum(SVnode *pVnode, int64_t *num) {
}
int32_t tbFilterSize = 0;
int32_t code = TSDB_CODE_SUCCESS;
#ifdef TD_ENTERPRISE
tbFilterSize = vnodeGetTimeSeriesBlackList(pVnode);
code = vnodeGetTimeSeriesBlackList(pVnode, &tbFilterSize);
if (TSDB_CODE_SUCCESS != code) {
goto _exit;
}
#endif
if ((!tbFilterSize && vnodeGetStbIdList(pVnode, 0, suidList) < 0) ||
@ -771,7 +779,6 @@ int32_t vnodeGetTimeSeriesNum(SVnode *pVnode, int64_t *num) {
*num = 0;
int64_t arrSize = taosArrayGetSize(suidList);
int32_t code = TSDB_CODE_SUCCESS;
for (int64_t i = 0; i < arrSize; ++i) {
tb_uid_t suid = *(tb_uid_t *)taosArrayGet(suidList, i);

View File

@ -2229,7 +2229,10 @@ int32_t apercentileFunction(SqlFunctionCtx* pCtx) {
double v = 0; // value
int64_t w = 1; // weigth
GET_TYPED_DATA(v, double, type, data);
tdigestAdd(pInfo->pTDigest, v, w);
int32_t code = tdigestAdd(pInfo->pTDigest, v, w);
if (code != TSDB_CODE_SUCCESS) {
return code;
}
}
} else {
// might be a race condition here that pHisto can be overwritten or setup function
@ -2285,7 +2288,10 @@ static int32_t apercentileTransferInfo(SAPercentileInfo* pInput, SAPercentileInf
(void)memcpy(pTDigest, pInput->pTDigest, (size_t)TDIGEST_SIZE(COMPRESSION));
tdigestAutoFill(pTDigest, COMPRESSION);
} else {
tdigestMerge(pTDigest, pInput->pTDigest);
int32_t code = tdigestMerge(pTDigest, pInput->pTDigest);
if (TSDB_CODE_SUCCESS != code) {
return code;
}
}
} else {
buildHistogramInfo(pInput);

View File

@ -1840,8 +1840,8 @@ int32_t filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t optio
if (unit->compare.optr2) {
(void)strcat(str, " && ");
if (unit->compare.optr2 <= OP_TYPE_JSON_CONTAINS) {
sprintf(str + strlen(str), "[%d][%d] %s [", refNode->dataBlockId, refNode->slotId,
operatorTypeStr(unit->compare.optr2));
(void)sprintf(str + strlen(str), "[%d][%d] %s [", refNode->dataBlockId, refNode->slotId,
operatorTypeStr(unit->compare.optr2));
}
if (unit->right2.type == FLD_TYPE_VALUE && FILTER_UNIT_OPTR(unit) != OP_TYPE_IN) {

View File

@ -329,10 +329,10 @@ static void tltrim(char *input, char *output, int32_t type, int32_t charLen) {
int32_t resLen;
if (type == TSDB_DATA_TYPE_VARCHAR) {
resLen = charLen - numOfSpaces;
memcpy(varDataVal(output), varDataVal(input) + numOfSpaces, resLen);
(void)memcpy(varDataVal(output), varDataVal(input) + numOfSpaces, resLen);
} else {
resLen = (charLen - numOfSpaces) * TSDB_NCHAR_SIZE;
memcpy(varDataVal(output), varDataVal(input) + numOfSpaces * TSDB_NCHAR_SIZE, resLen);
(void)memcpy(varDataVal(output), varDataVal(input) + numOfSpaces * TSDB_NCHAR_SIZE, resLen);
}
varDataSetLen(output, resLen);
@ -362,7 +362,7 @@ static void trtrim(char *input, char *output, int32_t type, int32_t charLen) {
} else {
resLen = (charLen - numOfSpaces) * TSDB_NCHAR_SIZE;
}
memcpy(varDataVal(output), varDataVal(input), resLen);
(void)memcpy(varDataVal(output), varDataVal(input), resLen);
varDataSetLen(output, resLen);
}
@ -401,11 +401,11 @@ static int32_t concatCopyHelper(const char *input, char *output, bool hasNchar,
taosMemoryFree(newBuf);
return TSDB_CODE_SCALAR_CONVERT_ERROR;
}
memcpy(varDataVal(output) + *dataLen, newBuf, varDataLen(input) * TSDB_NCHAR_SIZE);
(void)memcpy(varDataVal(output) + *dataLen, newBuf, varDataLen(input) * TSDB_NCHAR_SIZE);
*dataLen += varDataLen(input) * TSDB_NCHAR_SIZE;
taosMemoryFree(newBuf);
} else {
memcpy(varDataVal(output) + *dataLen, varDataVal(input), varDataLen(input));
(void)memcpy(varDataVal(output) + *dataLen, varDataVal(input), varDataLen(input));
*dataLen += varDataLen(input);
}
return TSDB_CODE_SUCCESS;
@ -581,7 +581,7 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
if (hasNull) {
colDataSetNULL(pOutputData, k);
memset(output, 0, dataLen);
(void)memset(output, 0, dataLen);
} else {
varDataSetLen(output, dataLen);
SCL_ERR_JRET(colDataSetVal(pOutputData, k, output, false));
@ -725,7 +725,7 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
char *output = outputBuf;
int32_t resLen = TMIN(subLen, len - startPosBytes);
if (resLen > 0) {
memcpy(varDataVal(output), varDataVal(input) + startPosBytes, resLen);
(void)memcpy(varDataVal(output), varDataVal(input) + startPosBytes, resLen);
varDataSetLen(output, resLen);
} else {
varDataSetLen(output, 0);
@ -768,7 +768,7 @@ int32_t md5Function(SScalarParam* pInput, int32_t inputNum, SScalarParam* pOutpu
}
}
char *output = pOutputBuf;
memcpy(varDataVal(output), varDataVal(input), varDataLen(input));
(void)memcpy(varDataVal(output), varDataVal(input), varDataLen(input));
int32_t len = taosCreateMD5Hash(varDataVal(output), varDataLen(input));
varDataSetLen(output, len);
int32_t code = colDataSetVal(pOutputData, i, output, false);
@ -812,7 +812,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
switch (outputType) {
case TSDB_DATA_TYPE_TINYINT: {
if (inputType == TSDB_DATA_TYPE_BINARY) {
memcpy(buf, varDataVal(input), varDataLen(input));
(void)memcpy(buf, varDataVal(input), varDataLen(input));
buf[varDataLen(input)] = 0;
*(int8_t *)output = taosStr2Int8(buf, NULL, 10);
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
@ -831,7 +831,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
}
case TSDB_DATA_TYPE_SMALLINT: {
if (inputType == TSDB_DATA_TYPE_BINARY) {
memcpy(buf, varDataVal(input), varDataLen(input));
(void)memcpy(buf, varDataVal(input), varDataLen(input));
buf[varDataLen(input)] = 0;
*(int16_t *)output = taosStr2Int16(buf, NULL, 10);
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
@ -849,7 +849,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
}
case TSDB_DATA_TYPE_INT: {
if (inputType == TSDB_DATA_TYPE_BINARY) {
memcpy(buf, varDataVal(input), varDataLen(input));
(void)memcpy(buf, varDataVal(input), varDataLen(input));
buf[varDataLen(input)] = 0;
*(int32_t *)output = taosStr2Int32(buf, NULL, 10);
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
@ -868,7 +868,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
}
case TSDB_DATA_TYPE_BIGINT: {
if (inputType == TSDB_DATA_TYPE_BINARY) {
memcpy(buf, varDataVal(input), varDataLen(input));
(void)memcpy(buf, varDataVal(input), varDataLen(input));
buf[varDataLen(input)] = 0;
*(int64_t *)output = taosStr2Int64(buf, NULL, 10);
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
@ -886,7 +886,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
}
case TSDB_DATA_TYPE_UTINYINT: {
if (inputType == TSDB_DATA_TYPE_BINARY) {
memcpy(buf, varDataVal(input), varDataLen(input));
(void)memcpy(buf, varDataVal(input), varDataLen(input));
buf[varDataLen(input)] = 0;
*(uint8_t *)output = taosStr2UInt8(buf, NULL, 10);
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
@ -904,7 +904,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
}
case TSDB_DATA_TYPE_USMALLINT: {
if (inputType == TSDB_DATA_TYPE_BINARY) {
memcpy(buf, varDataVal(input), varDataLen(input));
(void)memcpy(buf, varDataVal(input), varDataLen(input));
buf[varDataLen(input)] = 0;
*(uint16_t *)output = taosStr2UInt16(buf, NULL, 10);
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
@ -922,7 +922,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
}
case TSDB_DATA_TYPE_UINT: {
if (inputType == TSDB_DATA_TYPE_BINARY) {
memcpy(buf, varDataVal(input), varDataLen(input));
(void)memcpy(buf, varDataVal(input), varDataLen(input));
buf[varDataLen(input)] = 0;
*(uint32_t *)output = taosStr2UInt32(buf, NULL, 10);
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
@ -940,7 +940,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
}
case TSDB_DATA_TYPE_UBIGINT: {
if (inputType == TSDB_DATA_TYPE_BINARY) {
memcpy(buf, varDataVal(input), varDataLen(input));
(void)memcpy(buf, varDataVal(input), varDataLen(input));
buf[varDataLen(input)] = 0;
*(uint64_t *)output = taosStr2UInt64(buf, NULL, 10);
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
@ -959,7 +959,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
}
case TSDB_DATA_TYPE_FLOAT: {
if (inputType == TSDB_DATA_TYPE_BINARY) {
memcpy(buf, varDataVal(input), varDataLen(input));
(void)memcpy(buf, varDataVal(input), varDataLen(input));
buf[varDataLen(input)] = 0;
*(float *)output = taosStr2Float(buf, NULL);
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
@ -977,7 +977,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
}
case TSDB_DATA_TYPE_DOUBLE: {
if (inputType == TSDB_DATA_TYPE_BINARY) {
memcpy(buf, varDataVal(input), varDataLen(input));
(void)memcpy(buf, varDataVal(input), varDataLen(input));
buf[varDataLen(input)] = 0;
*(double *)output = taosStr2Double(buf, NULL);
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
@ -995,7 +995,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
}
case TSDB_DATA_TYPE_BOOL: {
if (inputType == TSDB_DATA_TYPE_BINARY) {
memcpy(buf, varDataVal(input), varDataLen(input));
(void)memcpy(buf, varDataVal(input), varDataLen(input));
buf[varDataLen(input)] = 0;
*(bool *)output = taosStr2Int8(buf, NULL, 10);
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
@ -1036,7 +1036,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
varDataSetLen(output, len);
} else if (inputType == TSDB_DATA_TYPE_BINARY) {
int32_t len = TMIN(varDataLen(input), outputLen - VARSTR_HEADER_SIZE);
memcpy(varDataVal(output), varDataVal(input), len);
(void)memcpy(varDataVal(output), varDataVal(input), len);
varDataSetLen(output, len);
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf);
@ -1045,13 +1045,13 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
goto _end;
}
len = TMIN(len, outputLen - VARSTR_HEADER_SIZE);
memcpy(varDataVal(output), convBuf, len);
(void)memcpy(varDataVal(output), convBuf, len);
varDataSetLen(output, len);
} else {
NUM_TO_STRING(inputType, input, bufSize, buf);
int32_t len = (int32_t)strlen(buf);
len = (outputLen - VARSTR_HEADER_SIZE) > len ? len : (outputLen - VARSTR_HEADER_SIZE);
memcpy(varDataVal(output), buf, len);
(void)memcpy(varDataVal(output), buf, len);
varDataSetLen(output, len);
}
break;
@ -1059,7 +1059,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
case TSDB_DATA_TYPE_VARBINARY:{
if (inputType == TSDB_DATA_TYPE_BINARY) {
int32_t len = TMIN(varDataLen(input), outputLen - VARSTR_HEADER_SIZE);
memcpy(varDataVal(output), varDataVal(input), len);
(void)memcpy(varDataVal(output), varDataVal(input), len);
varDataSetLen(output, len);
}else{
code = TSDB_CODE_FUNC_FUNTION_PARA_TYPE;
@ -1091,7 +1091,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp
varDataSetLen(output, len);
} else if (inputType == TSDB_DATA_TYPE_NCHAR) {
len = TMIN(outputLen - VARSTR_HEADER_SIZE, varDataLen(input));
memcpy(output, input, len + VARSTR_HEADER_SIZE);
(void)memcpy(output, input, len + VARSTR_HEADER_SIZE);
varDataSetLen(output, len);
} else {
NUM_TO_STRING(inputType, input, bufSize, buf);
@ -1141,7 +1141,7 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *
int32_t tzLen = 0;
if (tzPresent) {
tzLen = varDataLen(pInput[1].columnData->pData);
memcpy(tz, varDataVal(pInput[1].columnData->pData), tzLen);
(void)memcpy(tz, varDataVal(pInput[1].columnData->pData), tzLen);
}
for (int32_t i = 0; i < pInput[0].numOfRows; ++i) {
@ -1218,7 +1218,7 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *
// add timezone string
if (tzLen > 0) {
snprintf(buf + len, tzLen + 1, "%s", tz);
(void)snprintf(buf + len, tzLen + 1, "%s", tz);
len += tzLen;
}
@ -1286,7 +1286,7 @@ int32_t toJsonFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
taosArrayDestroy(pTagVals);
return TSDB_CODE_FAILED;
}
memcpy(tmp, varDataVal(input), varDataLen(input));
(void)memcpy(tmp, varDataVal(input), varDataLen(input));
tmp[varDataLen(input)] = 0;
if (parseJsontoTagData(tmp, pTagVals, &pTag, NULL)) {
code = tTagNew(pTagVals, 1, true, &pTag);
@ -1402,7 +1402,7 @@ _return:
int64_t offsetFromTz(char *timezone, int64_t factor) {
char *minStr = &timezone[3];
int64_t minutes = taosStr2Int64(minStr, NULL, 10);
memset(minStr, 0, strlen(minStr));
(void)memset(minStr, 0, strlen(minStr));
int64_t hours = taosStr2Int64(timezone, NULL, 10);
int64_t seconds = hours * 3600 + minutes * 60;

View File

@ -49,7 +49,7 @@
#define _DEBUG_PRINT_ 0
#if _DEBUG_PRINT_
#define PRINTF(...) printf(__VA_ARGS__)
#define PRINTF(...) (void)printf(__VA_ARGS__)
#else
#define PRINTF(...)
#endif
@ -84,7 +84,7 @@ void scltInitLogFile() {
(void)strcpy(tsLogDir, TD_LOG_DIR_PATH);
if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
printf("failed to open log file in directory:%s\n", tsLogDir);
(void)printf("failed to open log file in directory:%s\n", tsLogDir);
}
}
@ -1450,7 +1450,7 @@ TEST(columnTest, json_column_arith_op) {
OP_TYPE_REM, OP_TYPE_MINUS, OP_TYPE_BIT_AND, OP_TYPE_BIT_OR};
int32_t input[len] = {1, 8, 2, 2, 3, 0, -4, 9};
printf("--------------------json int-4 op {1, 8, 2, 2, 3, 0, -4, 9}--------------------\n");
(void)printf("--------------------json int-4 op {1, 8, 2, 2, 3, 0, -4, 9}--------------------\n");
char *key = "k1";
double eRes00[len] = {5.0, -4, 8.0, 2.0, 1.0, -4, 4 & -4, 4 | 9};
double eRes01[len] = {5.0, 4, 8.0, 0.5, 3, 0, 4 & -4, 4 | 9};
@ -1463,7 +1463,7 @@ TEST(columnTest, json_column_arith_op) {
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
}
printf("--------------------json string- 0 op {1, 8, 2, 2, 3, 0, -4, 9}--------------------\n");
(void)printf("--------------------json string- 0 op {1, 8, 2, 2, 3, 0, -4, 9}--------------------\n");
key = "k2";
double eRes10[len] = {1.0, -8, 0, 0, 0, 0, 0, 9};
@ -1477,7 +1477,7 @@ TEST(columnTest, json_column_arith_op) {
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
}
printf("---------------------json null- null op {1, 8, 2, 2, 3, 0, -4, 9}-------------------\n");
(void)printf("---------------------json null- null op {1, 8, 2, 2, 3, 0, -4, 9}-------------------\n");
key = "k3";
double eRes20[len] = {DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX};
@ -1491,7 +1491,7 @@ TEST(columnTest, json_column_arith_op) {
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
}
printf("---------------------json bool- true op {1, 8, 2, 2, 3, 0, -4, 9}-------------------\n");
(void)printf("---------------------json bool- true op {1, 8, 2, 2, 3, 0, -4, 9}-------------------\n");
key = "k4";
double eRes30[len] = {2.0, -7, 2, 0.5, 1, -1, 1 & -4, 1 | 9};
@ -1505,7 +1505,7 @@ TEST(columnTest, json_column_arith_op) {
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
}
printf("----------------------json double-- 5.44 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n");
(void)printf("----------------------json double-- 5.44 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n");
key = "k5";
double eRes40[len] = {6.44, -2.56, 10.88, 2.72, 2.44, -5.44, 5 & -4, 5 | 9};
@ -1519,7 +1519,7 @@ TEST(columnTest, json_column_arith_op) {
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
}
printf("----------------------json int-- -10 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n");
(void)printf("----------------------json int-- -10 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n");
key = "k6";
double eRes50[len] = {-9, -18, -20, -5, -10 % 3, 10, -10 & -4, -10 | 9};
@ -1533,7 +1533,7 @@ TEST(columnTest, json_column_arith_op) {
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
}
printf("----------------------json double-- -9.8 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n");
(void)printf("----------------------json double-- -9.8 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n");
key = "k7";
double eRes60[len] = {-8.8, -17.8, -19.6, -4.9, -0.8, 9.8, -9 & -4, -9 | 9};
@ -1547,7 +1547,7 @@ TEST(columnTest, json_column_arith_op) {
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
}
printf("----------------------json bool-- 0 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n");
(void)printf("----------------------json bool-- 0 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n");
key = "k8";
double eRes70[len] = {1.0, -8, 0, 0, 0, 0, 0, 9};
@ -1561,7 +1561,7 @@ TEST(columnTest, json_column_arith_op) {
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
}
printf("----------------------json string-- 8 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n");
(void)printf("----------------------json string-- 8 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n");
key = "k9";
double eRes80[len] = {9, 0, 16, 4, 8 % 3, -8, 8 & -4, 8 | 9};
@ -1575,7 +1575,7 @@ TEST(columnTest, json_column_arith_op) {
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
}
printf("---------------------json not exist-- NULL op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n");
(void)printf("---------------------json not exist-- NULL op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n");
key = "k10";
double eRes90[len] = {DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX};
@ -1628,7 +1628,7 @@ TEST(columnTest, json_column_logic_op) {
int32_t input[len] = {1, 8, 2, 2, 3, 0, 0, 0, 0};
char *inputNchar[len1] = {"hell_", "hel%", "hell", "llll"};
printf("--------------------json int---4 {1, 8, 2, 2, 3, 0, 0, 0, 0}------------------\n");
(void)printf("--------------------json int---4 {1, 8, 2, 2, 3, 0, 0, 0, 0}------------------\n");
char *key = "k1";
bool eRes[len + len1] = {true, false, false, false, false, true, false, true, true, false, false, false, false};
for (int i = 0; i < len; i++) {
@ -1647,7 +1647,7 @@ TEST(columnTest, json_column_logic_op) {
taosMemoryFree(rightData);
}
printf("--------------------json string--0 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
(void)printf("--------------------json string--0 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
key = "k2";
bool eRes1[len + len1] = {false, false, false, false, false, false, false, true, false, true, false, true, true};
@ -1668,7 +1668,7 @@ TEST(columnTest, json_column_logic_op) {
taosMemoryFree(rightData);
}
printf("--------------------json null---null {1, 8, 2, 2, 3, 0, 0, 0, 0}------------------\n");
(void)printf("--------------------json null---null {1, 8, 2, 2, 3, 0, 0, 0, 0}------------------\n");
key = "k3"; // (null is true) return NULL, so use DBL_MAX represent NULL
bool eRes2[len + len1] = {false, false, false, false, false, false, true, false, false, false, false, false, false};
@ -1689,7 +1689,7 @@ TEST(columnTest, json_column_logic_op) {
taosMemoryFree(rightData);
}
printf("--------------------json bool--1 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
(void)printf("--------------------json bool--1 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
key = "k4";
bool eRes3[len + len1] = {false, false, false, false, false, false, false, true, true, false, false, false, false};
@ -1710,7 +1710,7 @@ TEST(columnTest, json_column_logic_op) {
taosMemoryFree(rightData);
}
printf("--------------------json double--5.44 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
(void)printf("--------------------json double--5.44 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
key = "k5";
bool eRes4[len + len1] = {true, false, false, false, false, true, false, true, true, false, false, false, false};
@ -1731,7 +1731,7 @@ TEST(columnTest, json_column_logic_op) {
taosMemoryFree(rightData);
}
printf("--------------------json int-- -10 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
(void)printf("--------------------json int-- -10 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
key = "k6";
bool eRes5[len + len1] = {false, false, true, true, false, true, false, true, true, false, false, false, false};
@ -1752,7 +1752,7 @@ TEST(columnTest, json_column_logic_op) {
taosMemoryFree(rightData);
}
printf("--------------------json double-- -9.8 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
(void)printf("--------------------json double-- -9.8 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
key = "k7";
bool eRes6[len + len1] = {false, false, true, true, false, true, false, true, true, false, false, false, false};
@ -1773,7 +1773,7 @@ TEST(columnTest, json_column_logic_op) {
taosMemoryFree(rightData);
}
printf("--------------------json bool-- 0 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
(void)printf("--------------------json bool-- 0 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
key = "k8";
bool eRes7[len + len1] = {false, false, false, false, false, false, false, true, false, false, false, false, false};
@ -1794,7 +1794,7 @@ TEST(columnTest, json_column_logic_op) {
taosMemoryFree(rightData);
}
printf("--------------------json string-- 6.6hello {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
(void)printf("--------------------json string-- 6.6hello {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n");
key = "k9";
bool eRes8[len + len1] = {false, false, false, false, false, false, false, true, true, false, true, true, true};
@ -1811,14 +1811,14 @@ TEST(columnTest, json_column_logic_op) {
for (int i = len; i < len + len1; i++) {
void *rightData = prepareNchar(inputNchar[i - len]);
if (i == 11) {
printf("abc\n");
(void)printf("abc\n");
}
code = makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes8[i], op[i], false);
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
taosMemoryFree(rightData);
}
printf("---------------------json not exist-- NULL {1, 8, 2, 2, 3, 0, 0, 0, 0}------------------\n");
(void)printf("---------------------json not exist-- NULL {1, 8, 2, 2, 3, 0, 0, 0, 0}------------------\n");
key = "k10"; // (NULL is true) return NULL, so use DBL_MAX represent NULL
bool eRes9[len + len1] = {false, false, false, false, false, false, true, false, false, false, false, false, false};