From 3e8daeeb91a3bb8cc0f83e8bf6685146a3ca8396 Mon Sep 17 00:00:00 2001 From: wangmm0220 Date: Sun, 28 Jul 2024 01:07:07 +0800 Subject: [PATCH] fix:[TD-31017]process return value in client --- source/client/src/clientMsgHandler.c | 37 +- source/client/test/clientMonitorTests.cpp | 4 +- source/client/test/clientTests.cpp | 446 ++++++++++--------- source/dnode/mnode/impl/test/topic/topic.cpp | 15 +- 4 files changed, 270 insertions(+), 232 deletions(-) diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index 798c40dd9f..dd8cf87c74 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -245,7 +245,12 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) { if (TSDB_CODE_MND_DB_NOT_EXIST == code || TSDB_CODE_MND_DB_IN_CREATING == code || TSDB_CODE_MND_DB_IN_DROPPING == code) { SUseDbRsp usedbRsp = {0}; - (void)tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp); + code = tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp); + if(code != 0){ + tscError("0x%" PRIx64 " failed to deserialize SUseDbRsp", pRequest->requestId); + tFreeSUsedbRsp(&usedbRsp); + return TAOS_GET_TERRNO(code); + } struct SCatalog* pCatalog = NULL; if (usedbRsp.vgVersion >= 0) { // cached in local @@ -255,7 +260,13 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) { tscWarn("0x%" PRIx64 "catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pRequest->requestId, clusterId, tstrerror(code1)); } else { - (void)catalogRemoveDB(pCatalog, usedbRsp.db, usedbRsp.uid); + code = catalogRemoveDB(pCatalog, usedbRsp.db, usedbRsp.uid); + if (code != TSDB_CODE_SUCCESS) { + tscError("0x%" PRIx64 "catalogRemoveDB failed, db:%s, uid:%" PRId64 ", error:%s", pRequest->requestId, + usedbRsp.db, usedbRsp.uid, tstrerror(code)); + tFreeSUsedbRsp(&usedbRsp); + return TAOS_GET_TERRNO(code); + } } } tFreeSUsedbRsp(&usedbRsp); @@ -270,14 +281,19 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) { doRequestCallback(pRequest, pRequest->code); } else { - tsem_post(&pRequest->body.rspSem); + (void)tsem_post(&pRequest->body.rspSem); } return code; } SUseDbRsp usedbRsp = {0}; - (void)tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp); + code = tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp); + if (code != 0){ + tscError("0x%" PRIx64 " failed to deserialize SUseDbRsp", pRequest->requestId); + tFreeSUsedbRsp(&usedbRsp); + return TAOS_GET_TERRNO(code); + } if (strlen(usedbRsp.db) == 0) { if (usedbRsp.errCode != 0) { @@ -300,7 +316,9 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) { } SName name = {0}; - (void)tNameFromString(&name, usedbRsp.db, T_NAME_ACCT | T_NAME_DB); + if(tNameFromString(&name, usedbRsp.db, T_NAME_ACCT | T_NAME_DB) != TSDB_CODE_SUCCESS) { + tscError("0x%" PRIx64 " failed to parse db name:%s", pRequest->requestId, usedbRsp.db); + } SUseDbOutput output = {0}; code = queryBuildUseDbOutput(&output, &usedbRsp); @@ -317,7 +335,10 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) { tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pRequest->pTscObj->pAppInfo->clusterId, tstrerror(code1)); } else { - (void)catalogUpdateDBVgInfo(pCatalog, output.db, output.dbId, output.dbVgroup); + code = catalogUpdateDBVgInfo(pCatalog, output.db, output.dbId, output.dbVgroup); + if(code != 0){ + tscError("0x%" PRIx64 " failed to update db vgroup info since %s", pRequest->requestId, tstrerror(code)); + } output.dbVgroup = NULL; } } @@ -326,7 +347,9 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) { tFreeSUsedbRsp(&usedbRsp); char db[TSDB_DB_NAME_LEN] = {0}; - (void)tNameGetDbName(&name, db); + if(tNameGetDbName(&name, db) != TSDB_CODE_SUCCESS) { + tscError("0x%" PRIx64 " failed to get db name since %s", pRequest->requestId, tstrerror(code)); + } setConnectionDB(pRequest->pTscObj, db); diff --git a/source/client/test/clientMonitorTests.cpp b/source/client/test/clientMonitorTests.cpp index e0518a2ce2..65adb7cdae 100644 --- a/source/client/test/clientMonitorTests.cpp +++ b/source/client/test/clientMonitorTests.cpp @@ -86,7 +86,7 @@ static char* readFile(TdFilePtr pFile, int64_t *offset, int64_t size){ return NULL; } char* buf = pCont; - strcat(buf++, "["); + (void)strcat(buf++, "["); int64_t readSize = taosReadFile(pFile, buf, SLOW_LOG_SEND_SIZE_MAX); if (readSize <= 0) { if (readSize < 0){ @@ -153,7 +153,7 @@ TEST(clientMonitorTest, ReadOneFile) { const int size = 10; for(int i = 0; i < batch; i++){ char value[size] = {0}; - memset(value, '0' + i, size - 1); + (void)memset(value, '0' + i, size - 1); if (taosWriteFile(pFile, value, strlen(value) + 1) < 0){ uError("failed to write len to file:%p since %s", pFile, terrstr()); } diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 836a171ad7..e318ff1972 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -32,7 +32,7 @@ namespace { void printSubResults(void* pRes, int32_t* totalRows) { - char buf[1024]; + char buf[1024] = {0}; int32_t vgId = tmq_get_vgroup_id(pRes); int64_t offset = tmq_get_vgroup_offset(pRes); @@ -43,9 +43,10 @@ void printSubResults(void* pRes, int32_t* totalRows) { } TAOS_FIELD* fields = taos_fetch_fields(pRes); + assert(fields != NULL); int32_t numOfFields = taos_field_count(pRes); int32_t precision = taos_result_precision(pRes); - taos_print_row(buf, row, fields, numOfFields); + (void)taos_print_row(buf, row, fields, numOfFields); *totalRows += 1; std::cout << "vgId:" << vgId << ", offset:" << offset << ", precision:" << precision << ", row content:" << buf << std::endl; @@ -59,12 +60,13 @@ void showDB(TAOS* pConn) { TAOS_ROW pRow = NULL; TAOS_FIELD* pFields = taos_fetch_fields(pRes); + assert(pFields != NULL); int32_t numOfFields = taos_num_fields(pRes); char str[512] = {0}; while ((pRow = taos_fetch_row(pRes)) != NULL) { int32_t code = taos_print_row(str, pRow, pFields, numOfFields); - printf("%s\n", str); + (void)printf("%s\n", str); } } @@ -78,19 +80,19 @@ void printResult(TAOS_RES* pRes) { while ((pRow = taos_fetch_row(pRes)) != NULL) { // int32_t* length = taos_fetch_lengths(pRes); // for(int32_t i = 0; i < numOfFields; ++i) { - // printf("(%d):%d " , i, length[i]); + // (void)printf("(%d):%d " , i, length[i]); // } - // printf("\n"); + // (void)printf("\n"); // // int32_t code = taos_print_row(str, pRow, pFields, numOfFields); - // printf("%s\n", str); + // (void)printf("%s\n", str); // memset(str, 0, sizeof(str)); } } void fetchCallback(void* param, void* res, int32_t numOfRow) { #if 0 - printf("numOfRow = %d \n", numOfRow); + (void)printf("numOfRow = %d \n", numOfRow); int numFields = taos_num_fields(res); TAOS_FIELD *fields = taos_fetch_fields(res); TAOS *_taos = (TAOS *)param; @@ -100,18 +102,18 @@ void fetchCallback(void* param, void* res, int32_t numOfRow) { char temp[256] = {0}; taos_print_row(temp, row, fields, numFields); - printf("%s\n", temp); + (void)printf("%s\n", temp); } taos_fetch_rows_a(res, fetchCallback, _taos); } else { - printf("no more data, close the connection.\n"); + (void)printf("no more data, close the connection.\n"); // taos_free_result(res); // taos_close(_taos); // taos_cleanup(); } #endif if (numOfRow == 0) { - printf("completed\n"); + (void)printf("completed\n"); return; } @@ -120,26 +122,26 @@ void fetchCallback(void* param, void* res, int32_t numOfRow) { void queryCallback(void* param, void* res, int32_t code) { if (code != TSDB_CODE_SUCCESS) { - printf("failed to execute, reason:%s\n", taos_errstr(res)); + (void)printf("failed to execute, reason:%s\n", taos_errstr(res)); } - printf("start to fetch data\n"); + (void)printf("start to fetch data\n"); taos_fetch_raw_block_a(res, fetchCallback, param); } void createNewTable(TAOS* pConn, int32_t index, int32_t numOfRows, int64_t startTs, const char* pVarchar) { char str[1024] = {0}; - sprintf(str, "create table if not exists tu%d using st2 tags(%d)", index, index); + (void)sprintf(str, "create table if not exists tu%d using st2 tags(%d)", index, index); TAOS_RES* pRes = taos_query(pConn, str); if (taos_errno(pRes) != 0) { - printf("failed to create table tu, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create table tu, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); if (startTs == 0) { for (int32_t i = 0; i < numOfRows; i += 20) { char sql[1024] = {0}; - sprintf(sql, + (void)sprintf(sql, "insert into tu%d values(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)" "(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)" "(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)" @@ -149,7 +151,7 @@ void createNewTable(TAOS* pConn, int32_t index, int32_t numOfRows, int64_t start i + 14, i + 15, i + 15, i + 16, i + 16, i + 17, i + 17, i + 18, i + 18, i + 19, i + 19); TAOS_RES* p = taos_query(pConn, sql); if (taos_errno(p) != 0) { - printf("failed to insert data, reason:%s\n", taos_errstr(p)); + (void)printf("failed to insert data, reason:%s\n", taos_errstr(p)); } taos_free_result(p); @@ -157,7 +159,7 @@ void createNewTable(TAOS* pConn, int32_t index, int32_t numOfRows, int64_t start } else { for (int32_t i = 0; i < numOfRows; i += 20) { char sql[1024*50] = {0}; - sprintf(sql, + (void)sprintf(sql, "insert into tu%d values(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, " "%d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, " "'%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')(%ld, %d, '%s')", @@ -167,8 +169,9 @@ void createNewTable(TAOS* pConn, int32_t index, int32_t numOfRows, int64_t start i + 14, pVarchar, startTs + 15, i + 15, pVarchar, startTs + 16, i + 16, pVarchar, startTs + 17, i + 17, pVarchar, startTs + 18, i + 18, pVarchar, startTs + 19, i + 19, pVarchar); TAOS_RES* p = taos_query(pConn, sql); + assert(p != NULL); if (taos_errno(p) != 0) { - printf("failed to insert data, reason:%s\n", taos_errstr(p)); + (void)printf("failed to insert data, reason:%s\n", taos_errstr(p)); } // startTs += 20; @@ -180,7 +183,7 @@ void createNewTable(TAOS* pConn, int32_t index, int32_t numOfRows, int64_t start void* queryThread(void* arg) { TAOS* pConn = taos_connect("192.168.0.209", "root", "taosdata", NULL, 0); if (pConn == NULL) { - printf("failed to connect to db, reason:%s", taos_errstr(pConn)); + (void)printf("failed to connect to db, reason:%s", taos_errstr(pConn)); return NULL; } @@ -192,7 +195,7 @@ void* queryThread(void* arg) { "SELECT _wstart as ts,max(usage_user) FROM benchmarkcpu.host_49 WHERE ts >= " "1451618560000 AND ts < 1451622160000 INTERVAL(1m) ;"); if (taos_errno(pRes) != 0) { - printf("failed, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed, reason:%s\n", taos_errstr(pRes)); } else { printResult(pRes); } @@ -200,7 +203,7 @@ void* queryThread(void* arg) { taos_free_result(pRes); el += (taosGetTimestampUs() - st); if (i % 1000 == 0 && i != 0) { - printf("total:%d, avg time:%.2fms\n", i, el / (double)(i * 1000)); + (void)printf("total:%d, avg time:%.2fms\n", i, el / (double)(i * 1000)); } } @@ -211,32 +214,35 @@ void* queryThread(void* arg) { int32_t numOfThreads = 1; void tmq_commit_cb_print(tmq_t* pTmq, int32_t code, void* param) { -// printf("auto commit success, code:%d\n", code); +// (void)printf("auto commit success, code:%d\n", code); } void* doConsumeData(void* param) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); - + assert(pConn != NULL); tmq_conf_t* conf = tmq_conf_new(); - tmq_conf_set(conf, "enable.auto.commit", "true"); - tmq_conf_set(conf, "auto.commit.interval.ms", "1000"); - tmq_conf_set(conf, "group.id", "cgrpName41"); - tmq_conf_set(conf, "td.connect.user", "root"); - tmq_conf_set(conf, "td.connect.pass", "taosdata"); - tmq_conf_set(conf, "auto.offset.reset", "earliest"); - tmq_conf_set(conf, "experimental.snapshot.enable", "true"); - tmq_conf_set(conf, "msg.with.table.name", "true"); - tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); + assert(conf != NULL); + (void)tmq_conf_set(conf, "enable.auto.commit", "true"); + (void)tmq_conf_set(conf, "auto.commit.interval.ms", "1000"); + (void)tmq_conf_set(conf, "group.id", "cgrpName41"); + (void)tmq_conf_set(conf, "td.connect.user", "root"); + (void)tmq_conf_set(conf, "td.connect.pass", "taosdata"); + (void)tmq_conf_set(conf, "auto.offset.reset", "earliest"); + (void)tmq_conf_set(conf, "experimental.snapshot.enable", "true"); + (void)tmq_conf_set(conf, "msg.with.table.name", "true"); + (void)tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); + assert(tmq != NULL); tmq_conf_destroy(conf); // 创建订阅 topics 列表 tmq_list_t* topicList = tmq_list_new(); - tmq_list_append(topicList, "topic_t2"); + assert(topicList != NULL); + (void)tmq_list_append(topicList, "topic_t2"); // 启动订阅 - tmq_subscribe(tmq, topicList); + (void)tmq_subscribe(tmq, topicList); tmq_list_destroy(topicList); @@ -252,15 +258,15 @@ void* doConsumeData(void* param) { while (1) { TAOS_RES* pRes = tmq_consumer_poll(tmq, timeout); if (pRes) { - char buf[1024]; + char buf[1024] = {0}; const char* topicName = tmq_get_topic_name(pRes); const char* dbName = tmq_get_db_name(pRes); int32_t vgroupId = tmq_get_vgroup_id(pRes); - printf("topic: %s\n", topicName); - printf("db: %s\n", dbName); - printf("vgroup id: %d\n", vgroupId); + (void)printf("topic: %s\n", topicName); + (void)printf("db: %s\n", dbName); + (void)printf("vgroup id: %d\n", vgroupId); while (1) { TAOS_ROW row = taos_fetch_row(pRes); @@ -269,11 +275,12 @@ void* doConsumeData(void* param) { } fields = taos_fetch_fields(pRes); + assert(fields != NULL); numOfFields = taos_field_count(pRes); precision = taos_result_precision(pRes); - taos_print_row(buf, row, fields, numOfFields); + (void)taos_print_row(buf, row, fields, numOfFields); totalRows += 1; - // printf("precision: %d, row content: %s\n", precision, buf); + // (void)printf("precision: %d, row content: %s\n", precision, buf); } taos_free_result(pRes); @@ -282,9 +289,9 @@ void* doConsumeData(void* param) { } } - tmq_consumer_close(tmq); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); return NULL; } @@ -297,7 +304,7 @@ int main(int argc, char** argv) { } numOfThreads = TMAX(numOfThreads, 1); - printf("the runing threads is:%d", numOfThreads); + (void)printf("the runing threads is:%d", numOfThreads); return RUN_ALL_TESTS(); } @@ -311,7 +318,7 @@ TEST(clientCase, connect_Test) { taos_options(TSDB_OPTION_CONFIGDIR, "~/first/cfg"); TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); if (pConn == NULL) { - printf("failed to connect to server, reason:%s\n", taos_errstr(NULL)); + (void)printf("failed to connect to server, reason:%s\n", taos_errstr(NULL)); } taos_close(pConn); } @@ -322,7 +329,7 @@ TEST(clientCase, create_user_Test) { TAOS_RES* pRes = taos_query(pConn, "create user abc pass 'abc'"); if (taos_errno(pRes) != TSDB_CODE_SUCCESS) { - printf("failed to create user, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create user, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); @@ -335,7 +342,7 @@ TEST(clientCase, create_account_Test) { TAOS_RES* pRes = taos_query(pConn, "create account aabc pass 'abc'"); if (taos_errno(pRes) != TSDB_CODE_SUCCESS) { - printf("failed to create user, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create user, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); @@ -348,7 +355,7 @@ TEST(clientCase, drop_account_Test) { TAOS_RES* pRes = taos_query(pConn, "drop account aabc"); if (taos_errno(pRes) != TSDB_CODE_SUCCESS) { - printf("failed to create user, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create user, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); @@ -363,12 +370,13 @@ TEST(clientCase, show_user_Test) { TAOS_ROW pRow = NULL; TAOS_FIELD* pFields = taos_fetch_fields(pRes); + assert(pFields != NULL); int32_t numOfFields = taos_num_fields(pRes); char str[512] = {0}; while ((pRow = taos_fetch_row(pRes)) != NULL) { int32_t code = taos_print_row(str, pRow, pFields, numOfFields); - printf("%s\n", str); + (void)printf("%s\n", str); } taos_free_result(pRes); @@ -381,7 +389,7 @@ TEST(clientCase, drop_user_Test) { TAOS_RES* pRes = taos_query(pConn, "drop user abc"); if (taos_errno(pRes) != TSDB_CODE_SUCCESS) { - printf("failed to create user, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create user, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); @@ -396,12 +404,13 @@ TEST(clientCase, show_db_Test) { TAOS_ROW pRow = NULL; TAOS_FIELD* pFields = taos_fetch_fields(pRes); + assert(pFields != NULL); int32_t numOfFields = taos_num_fields(pRes); char str[512] = {0}; while ((pRow = taos_fetch_row(pRes)) != NULL) { int32_t code = taos_print_row(str, pRow, pFields, numOfFields); - printf("%s\n", str); + (void)printf("%s\n", str); } taos_close(pConn); @@ -413,7 +422,7 @@ TEST(clientCase, create_db_Test) { TAOS_RES* pRes = taos_query(pConn, "create database abc1 vgroups 2"); if (taos_errno(pRes) != 0) { - printf("error in create db, reason:%s\n", taos_errstr(pRes)); + (void)printf("error in create db, reason:%s\n", taos_errstr(pRes)); } TAOS_FIELD* pFields = taos_fetch_fields(pRes); @@ -426,7 +435,7 @@ TEST(clientCase, create_db_Test) { pRes = taos_query(pConn, "create database abc1 vgroups 4"); if (taos_errno(pRes) != 0) { - printf("error in create db, reason:%s\n", taos_errstr(pRes)); + (void)printf("error in create db, reason:%s\n", taos_errstr(pRes)); } taos_close(pConn); } @@ -437,13 +446,13 @@ TEST(clientCase, create_dnode_Test) { TAOS_RES* pRes = taos_query(pConn, "create dnode abc1 port 7000"); if (taos_errno(pRes) != 0) { - printf("error in create dnode, reason:%s\n", taos_errstr(pRes)); + (void)printf("error in create dnode, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); pRes = taos_query(pConn, "create dnode 1.1.1.1 port 9000"); if (taos_errno(pRes) != 0) { - printf("failed to create dnode, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create dnode, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); @@ -456,7 +465,7 @@ TEST(clientCase, drop_dnode_Test) { TAOS_RES* pRes = taos_query(pConn, "drop dnode 3"); if (taos_errno(pRes) != 0) { - printf("error in drop dnode, reason:%s\n", taos_errstr(pRes)); + (void)printf("error in drop dnode, reason:%s\n", taos_errstr(pRes)); } TAOS_FIELD* pFields = taos_fetch_fields(pRes); @@ -467,7 +476,7 @@ TEST(clientCase, drop_dnode_Test) { pRes = taos_query(pConn, "drop dnode 4"); if (taos_errno(pRes) != 0) { - printf("error in drop dnode, reason:%s\n", taos_errstr(pRes)); + (void)printf("error in drop dnode, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); @@ -480,7 +489,7 @@ TEST(clientCase, use_db_test) { TAOS_RES* pRes = taos_query(pConn, "use abc1"); if (taos_errno(pRes) != 0) { - printf("error in use db, reason:%s\n", taos_errstr(pRes)); + (void)printf("error in use db, reason:%s\n", taos_errstr(pRes)); } TAOS_FIELD* pFields = taos_fetch_fields(pRes); @@ -500,7 +509,7 @@ TEST(clientCase, use_db_test) { // // TAOS_RES* pRes = taos_query(pConn, "drop database abc1"); // if (taos_errno(pRes) != 0) { -// printf("failed to drop db, reason:%s\n", taos_errstr(pRes)); +// (void)printf("failed to drop db, reason:%s\n", taos_errstr(pRes)); // } // taos_free_result(pRes); // @@ -508,7 +517,7 @@ TEST(clientCase, use_db_test) { // // pRes = taos_query(pConn, "create database abc1"); // if (taos_errno(pRes) != 0) { -// printf("create to drop db, reason:%s\n", taos_errstr(pRes)); +// (void)printf("create to drop db, reason:%s\n", taos_errstr(pRes)); // } // taos_free_result(pRes); // taos_close(pConn); @@ -520,7 +529,7 @@ TEST(clientCase, create_stable_Test) { TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 2"); if (taos_errno(pRes) != 0) { - printf("error in create db, reason:%s\n", taos_errstr(pRes)); + (void)printf("error in create db, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); @@ -528,7 +537,7 @@ TEST(clientCase, create_stable_Test) { pRes = taos_query(pConn, "create table if not exists abc1.st1(ts timestamp, k int) tags(a int)"); if (taos_errno(pRes) != 0) { - printf("error in create stable, reason:%s\n", taos_errstr(pRes)); + (void)printf("error in create stable, reason:%s\n", taos_errstr(pRes)); } TAOS_FIELD* pFields = taos_fetch_fields(pRes); @@ -540,14 +549,14 @@ TEST(clientCase, create_stable_Test) { // pRes = taos_query(pConn, "create stable if not exists abc1.`123_$^)` (ts timestamp, `abc` int) tags(a int)"); // if (taos_errno(pRes) != 0) { - // printf("failed to create super table 123_$^), reason:%s\n", taos_errstr(pRes)); + // (void)printf("failed to create super table 123_$^), reason:%s\n", taos_errstr(pRes)); // } // // pRes = taos_query(pConn, "use abc1"); // taos_free_result(pRes); // pRes = taos_query(pConn, "drop stable `123_$^)`"); // if (taos_errno(pRes) != 0) { - // printf("failed to drop super table 123_$^), reason:%s\n", taos_errstr(pRes)); + // (void)printf("failed to drop super table 123_$^), reason:%s\n", taos_errstr(pRes)); // } taos_close(pConn); @@ -578,19 +587,19 @@ TEST(clientCase, create_ctable_Test) { TAOS_RES* pRes = taos_query(pConn, "use abc1"); if (taos_errno(pRes) != 0) { - printf("failed to use db, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to use db, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); pRes = taos_query(pConn, "create stable if not exists st1 (ts timestamp, k int ) tags(a int)"); if (taos_errno(pRes) != 0) { - printf("failed to create stable, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create stable, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); pRes = taos_query(pConn, "create table tu using st1 tags('2021-10-10 1:1:1');"); if (taos_errno(pRes) != 0) { - printf("failed to create child table tm0, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create child table tm0, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); @@ -603,7 +612,7 @@ TEST(clientCase, show_stable_Test) { TAOS_RES* pRes = taos_query(pConn, "show abc1.stables"); if (taos_errno(pRes) != 0) { - printf("failed to show stables, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to show stables, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); ASSERT_TRUE(false); } @@ -615,7 +624,7 @@ TEST(clientCase, show_stable_Test) { char str[512] = {0}; while ((pRow = taos_fetch_row(pRes)) != NULL) { int32_t code = taos_print_row(str, pRow, pFields, numOfFields); - printf("%s\n", str); + (void)printf("%s\n", str); } taos_free_result(pRes); @@ -628,13 +637,13 @@ TEST(clientCase, show_vgroup_Test) { TAOS_RES* pRes = taos_query(pConn, "use abc1"); if (taos_errno(pRes) != 0) { - printf("failed to use db, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to use db, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); pRes = taos_query(pConn, "show vgroups"); if (taos_errno(pRes) != 0) { - printf("failed to show vgroups, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to show vgroups, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); ASSERT_TRUE(false); } @@ -647,7 +656,7 @@ TEST(clientCase, show_vgroup_Test) { char str[512] = {0}; while ((pRow = taos_fetch_row(pRes)) != NULL) { int32_t code = taos_print_row(str, pRow, pFields, numOfFields); - printf("%s\n", str); + (void)printf("%s\n", str); } taos_free_result(pRes); @@ -660,7 +669,7 @@ TEST(clientCase, create_multiple_tables) { TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1"); if (taos_errno(pRes) != 0) { - printf("failed to create db, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create db, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); taos_close(pConn); return; @@ -669,7 +678,7 @@ TEST(clientCase, create_multiple_tables) { pRes = taos_query(pConn, "use abc1"); if (taos_errno(pRes) != 0) { - printf("failed to use db, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to use db, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); taos_close(pConn); return; @@ -679,14 +688,14 @@ TEST(clientCase, create_multiple_tables) { pRes = taos_query(pConn, "create stable if not exists st1 (ts timestamp, k int) tags(a int)"); if (taos_errno(pRes) != 0) { - printf("failed to create stable tables, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create stable tables, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); pRes = taos_query(pConn, "create table if not exists t_2 using st1 tags(1)"); if (taos_errno(pRes) != 0) { - printf("failed to create multiple tables, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create multiple tables, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); ASSERT_TRUE(false); } @@ -694,7 +703,7 @@ TEST(clientCase, create_multiple_tables) { taos_free_result(pRes); pRes = taos_query(pConn, "create table if not exists t_3 using st1 tags(2)"); if (taos_errno(pRes) != 0) { - printf("failed to create multiple tables, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create multiple tables, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); ASSERT_TRUE(false); } @@ -706,17 +715,17 @@ TEST(clientCase, create_multiple_tables) { char str[512] = {0}; while ((pRow = taos_fetch_row(pRes)) != NULL) { int32_t code = taos_print_row(str, pRow, pFields, numOfFields); - printf("%s\n", str); + (void)printf("%s\n", str); } taos_free_result(pRes); for (int32_t i = 0; i < 500; i += 2) { char sql[512] = {0}; - snprintf(sql, tListLen(sql), "create table t_x_%d using st1 tags(2) t_x_%d using st1 tags(5)", i, i + 1); + (void)snprintf(sql, tListLen(sql), "create table t_x_%d using st1 tags(2) t_x_%d using st1 tags(5)", i, i + 1); TAOS_RES* pres = taos_query(pConn, sql); if (taos_errno(pres) != 0) { - printf("failed to create table %d\n, reason:%s", i, taos_errstr(pres)); + (void)printf("failed to create table %d\n, reason:%s", i, taos_errstr(pres)); } taos_free_result(pres); } @@ -730,15 +739,15 @@ TEST(clientCase, show_table_Test) { TAOS_RES* pRes = taos_query(pConn, "show tables"); if (taos_errno(pRes) != 0) { - printf("failed to show tables, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to show tables, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); - taos_query(pConn, "use abc1"); + (void)taos_query(pConn, "use abc1"); pRes = taos_query(pConn, "show tables"); if (taos_errno(pRes) != 0) { - printf("failed to show tables, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to show tables, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); } @@ -751,7 +760,7 @@ TEST(clientCase, show_table_Test) { while ((pRow = taos_fetch_row(pRes)) != NULL) { int32_t code = taos_print_row(str, pRow, pFields, numOfFields); - printf("%d: %s\n", ++count, str); + (void)printf("%d: %s\n", ++count, str); } taos_free_result(pRes); @@ -764,19 +773,19 @@ TEST(clientCase, show_table_Test) { // // TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1"); // if (taos_errno(pRes) != 0) { -// printf("error in creating db, reason:%s\n", taos_errstr(pRes)); +// (void)printf("error in creating db, reason:%s\n", taos_errstr(pRes)); // } // taos_free_result(pRes); // // pRes = taos_query(pConn, "use abc1"); // if (taos_errno(pRes) != 0) { -// printf("error in using db, reason:%s\n", taos_errstr(pRes)); +// (void)printf("error in using db, reason:%s\n", taos_errstr(pRes)); // } // taos_free_result(pRes); // // pRes = taos_query(pConn, "drop stable st1"); // if (taos_errno(pRes) != 0) { -// printf("failed to drop stable, reason:%s\n", taos_errstr(pRes)); +// (void)printf("failed to drop stable, reason:%s\n", taos_errstr(pRes)); // } // // taos_free_result(pRes); @@ -790,10 +799,10 @@ TEST(clientCase, generated_request_id_test) { uint64_t v = generateRequestId(); void* result = taosHashGet(phash, &v, sizeof(v)); if (result != nullptr) { - // printf("0x%llx, index:%d\n", v, i); + // (void)printf("0x%llx, index:%d\n", v, i); } assert(result == nullptr); - taosHashPut(phash, &v, sizeof(v), NULL, 0); + (void)taosHashPut(phash, &v, sizeof(v), NULL, 0); } taosHashCleanup(phash); @@ -808,7 +817,7 @@ TEST(clientCase, insert_test) { pRes = taos_query(pConn, "insert into t_2 values(now, 1)"); if (taos_errno(pRes) != 0) { - printf("failed to create into table t_2, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create into table t_2, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); ASSERT_TRUE(false); } @@ -825,7 +834,7 @@ TEST(clientCase, projection_query_tables) { // TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1"); // if (taos_errno(pRes) != 0) { - // printf("error in create db, reason:%s\n", taos_errstr(pRes)); + // (void)printf("error in create db, reason:%s\n", taos_errstr(pRes)); // } // taos_free_result(pRes); pRes= taos_query(pConn, "use abc1"); @@ -833,7 +842,7 @@ TEST(clientCase, projection_query_tables) { pRes = taos_query(pConn, "create table tu using st2 tags(2)"); if (taos_errno(pRes) != 0) { - printf("failed to create table tu, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create table tu, reason:%s\n", taos_errstr(pRes)); } taos_free_result(pRes); @@ -848,11 +857,11 @@ TEST(clientCase, projection_query_tables) { for(int32_t i = 0; i < 1; ++i) { char str[1024] = {0}; - sprintf(str, "create table if not exists tu%d using st2 tags(%d)", i, i); + (void)sprintf(str, "create table if not exists tu%d using st2 tags(%d)", i, i); TAOS_RES* px = taos_query(pConn, str); if (taos_errno(px) != 0) { - printf("failed to create table tu, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to create table tu, reason:%s\n", taos_errstr(pRes)); } taos_free_result(px); } @@ -866,7 +875,7 @@ TEST(clientCase, projection_query_tables) { pRes = taos_query(pConn, "select * from abc1.st2"); if (taos_errno(pRes) != 0) { - printf("failed to select from table, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to select from table, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); ASSERT_TRUE(false); } @@ -878,7 +887,7 @@ TEST(clientCase, projection_query_tables) { char str[512] = {0}; while ((pRow = taos_fetch_row(pRes)) != NULL) { // int32_t code = taos_print_row(str, pRow, pFields, numOfFields); -// printf("%s\n", str); +// (void)printf("%s\n", str); } taos_free_result(pRes); @@ -889,7 +898,7 @@ TEST(clientCase, tsbs_perf_test) { TdThread qid[20] = {0}; for (int32_t i = 0; i < numOfThreads; ++i) { - taosThreadCreate(&qid[i], NULL, queryThread, NULL); + (void)taosThreadCreate(&qid[i], NULL, queryThread, NULL); } getchar(); } @@ -903,7 +912,7 @@ TEST(clientCase, projection_query_stables) { // pRes = taos_query(pConn, "select * from st2"); // if (taos_errno(pRes) != 0) { -// printf("failed to select from table, reason:%s\n", taos_errstr(pRes)); +// (void)printf("failed to select from table, reason:%s\n", taos_errstr(pRes)); // taos_free_result(pRes); // ASSERT_TRUE(false); // } @@ -925,15 +934,15 @@ TEST(clientCase, projection_query_stables) { i += numOfRows; if ( (i / 1000000) > prev) { - printf("%d\n", i); + (void)printf("%d\n", i); prev = i/1000000; } - //printf("%d\n", i); + //(void)printf("%d\n", i); } // while ((pRow = taos_fetch_row(pRes)) != NULL) { // int32_t code = taos_print_row(str, pRow, pFields, numOfFields); // if (i++ % 100000 == 0) { -// printf("%d\n", i); +// (void)printf("%d\n", i); // } // } @@ -947,7 +956,7 @@ TEST(clientCase, agg_query_tables) { TAOS_RES* pRes = taos_query(pConn, "use abc1"); if (taos_errno(pRes) != 0) { - printf("failed to use db, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed to use db, reason:%s\n", taos_errstr(pRes)); taos_free_result(pRes); ASSERT_TRUE(false); } @@ -958,7 +967,7 @@ TEST(clientCase, agg_query_tables) { char s[256] = {0}; while (1) { - sprintf(s, "insert into t1 values(%ld, %d)", st + i, i); + (void)sprintf(s, "insert into t1 values(%ld, %d)", st + i, i); pRes = taos_query(pConn, s); int32_t ret = taos_errno(pRes); @@ -982,7 +991,7 @@ TEST(clientCase, agg_query_tables) { // pRes = taos_query(pConn, "show table distributed tup"); // if (taos_errno(pRes) != 0) { -// printf("failed to select from table, reason:%s\n", taos_errstr(pRes)); +// (void)printf("failed to select from table, reason:%s\n", taos_errstr(pRes)); // taos_free_result(pRes); // ASSERT_TRUE(false); // } @@ -1008,11 +1017,11 @@ TEST(clientCase, async_api_test) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(pConn, nullptr); - taos_query(pConn, "use abc1"); + (void)taos_query(pConn, "use abc1"); TAOS_RES* pRes = taos_query(pConn, "insert into tu(ts) values('2022-02-27 12:12:61')"); if (taos_errno(pRes) != 0) { - printf("failed, reason:%s\n", taos_errstr(pRes)); + (void)printf("failed, reason:%s\n", taos_errstr(pRes)); } int32_t n = 0; @@ -1024,17 +1033,17 @@ TEST(clientCase, async_api_test) { while ((pRow = taos_fetch_row(pRes)) != NULL) { int32_t* length = taos_fetch_lengths(pRes); for (int32_t i = 0; i < numOfFields; ++i) { - printf("(%d):%d ", i, length[i]); + (void)printf("(%d):%d ", i, length[i]); } - printf("\n"); + (void)printf("\n"); int32_t code = taos_print_row(str, pRow, pFields, numOfFields); - printf("%s\n", str); - memset(str, 0, sizeof(str)); + (void)printf("%s\n", str); + (void)memset(str, 0, sizeof(str)); } taos_query_a(pConn, "select count(*) from tu", queryCallback, pConn); - getchar(); + (void)getchar(); taos_close(pConn); } @@ -1044,7 +1053,7 @@ TEST(clientCase, update_test) { TAOS_RES* pRes = taos_query(pConn, "select cast(0 as timestamp)-1y"); if (taos_errno(pRes) != TSDB_CODE_SUCCESS) { - printf("failed to create database, code:%s", taos_errstr(pRes)); + (void)printf("failed to create database, code:%s", taos_errstr(pRes)); taos_free_result(pRes); return; } @@ -1053,7 +1062,7 @@ TEST(clientCase, update_test) { pRes = taos_query(pConn, "use abc1"); if (taos_errno(pRes) != TSDB_CODE_SUCCESS) { - printf("failed to use db, code:%s", taos_errstr(pRes)); + (void)printf("failed to use db, code:%s", taos_errstr(pRes)); taos_free_result(pRes); return; } @@ -1061,14 +1070,14 @@ TEST(clientCase, update_test) { pRes = taos_query(pConn, "create table tup (ts timestamp, k int);"); if (taos_errno(pRes) != 0) { - printf("failed to create table, reason:%s", taos_errstr(pRes)); + (void)printf("failed to create table, reason:%s", taos_errstr(pRes)); } taos_free_result(pRes); char s[256] = {0}; for (int32_t i = 0; i < 17000; ++i) { - sprintf(s, "insert into tup values(now+%da, %d)", i, i); + (void)sprintf(s, "insert into tup values(now+%da, %d)", i, i); pRes = taos_query(pConn, s); taos_free_result(pRes); } @@ -1080,32 +1089,32 @@ TEST(clientCase, sub_db_test) { // TAOS_RES* pRes = taos_query(pConn, "create topic topic_t1 as select * from t1"); // if (taos_errno(pRes) != TSDB_CODE_SUCCESS) { - // printf("failed to create topic, code:%s", taos_errstr(pRes)); + // (void)printf("failed to create topic, code:%s", taos_errstr(pRes)); // taos_free_result(pRes); // return; // } tmq_conf_t* conf = tmq_conf_new(); - tmq_conf_set(conf, "enable.auto.commit", "true"); - tmq_conf_set(conf, "auto.commit.interval.ms", "1000"); - tmq_conf_set(conf, "group.id", "cgrpNamedb"); - tmq_conf_set(conf, "td.connect.user", "root"); - tmq_conf_set(conf, "td.connect.pass", "taosdata"); - tmq_conf_set(conf, "auto.offset.reset", "earliest"); - tmq_conf_set(conf, "experimental.snapshot.enable", "false"); - tmq_conf_set(conf, "msg.with.table.name", "true"); - tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); + (void)tmq_conf_set(conf, "enable.auto.commit", "true"); + (void)tmq_conf_set(conf, "auto.commit.interval.ms", "1000"); + (void)tmq_conf_set(conf, "group.id", "cgrpNamedb"); + (void)tmq_conf_set(conf, "td.connect.user", "root"); + (void)tmq_conf_set(conf, "td.connect.pass", "taosdata"); + (void)tmq_conf_set(conf, "auto.offset.reset", "earliest"); + (void)tmq_conf_set(conf, "experimental.snapshot.enable", "false"); + (void)tmq_conf_set(conf, "msg.with.table.name", "true"); + (void)tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); tmq_conf_destroy(conf); // 创建订阅 topics 列表 tmq_list_t* topicList = tmq_list_new(); - tmq_list_append(topicList, "topic_t1"); + (void)tmq_list_append(topicList, "topic_t1"); // tmq_list_append(topicList, "topic_s2"); // 启动订阅 - tmq_subscribe(tmq, topicList); + (void)tmq_subscribe(tmq, topicList); tmq_list_destroy(topicList); TAOS_FIELD* fields = NULL; @@ -1127,12 +1136,12 @@ TEST(clientCase, sub_db_test) { const char* dbName = tmq_get_db_name(pRes); int32_t vgroupId = tmq_get_vgroup_id(pRes); - printf("topic: %s\n", topicName); - printf("db: %s\n", dbName); - printf("vgroup id: %d\n", vgroupId); + (void)printf("topic: %s\n", topicName); + (void)printf("db: %s\n", dbName); + (void)printf("vgroup id: %d\n", vgroupId); if (count++ > 200) { - tmq_unsubscribe(tmq); + (void)tmq_unsubscribe(tmq); break; } @@ -1141,17 +1150,18 @@ TEST(clientCase, sub_db_test) { if (row == NULL) break; fields = taos_fetch_fields(pRes); + assert(fields != NULL); numOfFields = taos_field_count(pRes); precision = taos_result_precision(pRes); rows++; - taos_print_row(buf, row, fields, numOfFields); - printf("precision: %d, row content: %s\n", precision, buf); + (void)taos_print_row(buf, row, fields, numOfFields); + (void)printf("precision: %d, row content: %s\n", precision, buf); } taos_free_result(pRes); } } - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); } TEST(clientCase, tmq_commit) { @@ -1162,13 +1172,13 @@ TEST(clientCase, tmq_commit) { tmq_conf_t* conf = tmq_conf_new(); - tmq_conf_set(conf, "enable.auto.commit", "false"); - tmq_conf_set(conf, "auto.commit.interval.ms", "2000"); - tmq_conf_set(conf, "group.id", "group_id_2"); - tmq_conf_set(conf, "td.connect.user", "root"); - tmq_conf_set(conf, "td.connect.pass", "taosdata"); - tmq_conf_set(conf, "auto.offset.reset", "earliest"); - tmq_conf_set(conf, "msg.with.table.name", "true"); + (void)tmq_conf_set(conf, "enable.auto.commit", "false"); + (void)tmq_conf_set(conf, "auto.commit.interval.ms", "2000"); + (void)tmq_conf_set(conf, "group.id", "group_id_2"); + (void)tmq_conf_set(conf, "td.connect.user", "root"); + (void)tmq_conf_set(conf, "td.connect.pass", "taosdata"); + (void)tmq_conf_set(conf, "auto.offset.reset", "earliest"); + (void)tmq_conf_set(conf, "msg.with.table.name", "true"); tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); tmq_conf_destroy(conf); @@ -1176,10 +1186,10 @@ TEST(clientCase, tmq_commit) { char topicName[128] = "tp"; // 创建订阅 topics 列表 tmq_list_t* topicList = tmq_list_new(); - tmq_list_append(topicList, topicName); + (void)tmq_list_append(topicList, topicName); // 启动订阅 - tmq_subscribe(tmq, topicList); + (void)tmq_subscribe(tmq, topicList); tmq_list_destroy(topicList); int32_t totalRows = 0; @@ -1191,11 +1201,11 @@ TEST(clientCase, tmq_commit) { int32_t code = tmq_get_topic_assignment(tmq, topicName, &pAssign, &numOfAssign); if (code != 0) { - printf("error occurs:%s\n", tmq_err2str(code)); + (void)printf("error occurs:%s\n", tmq_err2str(code)); tmq_free_assignment(pAssign); - tmq_consumer_close(tmq); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); return; } @@ -1210,13 +1220,13 @@ TEST(clientCase, tmq_commit) { int64_t position = tmq_position(tmq, topicName, pa->vgId); std::cout << "position vgId:" << pa->vgId << ", position:" << position << std::endl; - tmq_offset_seek(tmq, topicName, pa->vgId, 1); + (void)tmq_offset_seek(tmq, topicName, pa->vgId, 1); position = tmq_position(tmq, topicName, pa->vgId); std::cout << "after seek 1, position vgId:" << pa->vgId << " position:" << position << std::endl; } while (1) { - printf("start to poll\n"); + (void)printf("start to poll\n"); TAOS_RES* pRes = tmq_consumer_poll(tmq, timeout); if (pRes) { printSubResults(pRes, &totalRows); @@ -1224,13 +1234,13 @@ TEST(clientCase, tmq_commit) { break; } - tmq_commit_sync(tmq, pRes); + (void)tmq_commit_sync(tmq, pRes); for(int i = 0; i < numOfAssign; i++) { int64_t committed = tmq_committed(tmq, topicName, pAssign[i].vgId); std::cout << "committed vgId:" << pAssign[i].vgId << " , committed:" << committed << std::endl; if(committed > 0){ int32_t code = tmq_commit_offset_sync(tmq, topicName, pAssign[i].vgId, 4); - printf("tmq_commit_offset_sync vgId:%d, offset:4, code:%d\n", pAssign[i].vgId, code); + (void)printf("tmq_commit_offset_sync vgId:%d, offset:4, code:%d\n", pAssign[i].vgId, code); int64_t committed = tmq_committed(tmq, topicName, pAssign[i].vgId); std::cout << "after tmq_commit_offset_sync, committed vgId:" << pAssign[i].vgId << ", committed:" << committed @@ -1246,9 +1256,9 @@ TEST(clientCase, tmq_commit) { tmq_free_assignment(pAssign); - tmq_consumer_close(tmq); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); } namespace { void doPrintInfo(tmq_topic_assignment* pa, int32_t index) { @@ -1264,24 +1274,25 @@ TEST(clientCase, td_25129) { tmq_conf_t* conf = tmq_conf_new(); - tmq_conf_set(conf, "enable.auto.commit", "false"); - tmq_conf_set(conf, "auto.commit.interval.ms", "2000"); - tmq_conf_set(conf, "group.id", "group_id_2"); - tmq_conf_set(conf, "td.connect.user", "root"); - tmq_conf_set(conf, "td.connect.pass", "taosdata"); - tmq_conf_set(conf, "auto.offset.reset", "earliest"); - tmq_conf_set(conf, "msg.with.table.name", "true"); + (void)tmq_conf_set(conf, "enable.auto.commit", "false"); + (void)tmq_conf_set(conf, "auto.commit.interval.ms", "2000"); + (void)tmq_conf_set(conf, "group.id", "group_id_2"); + (void)tmq_conf_set(conf, "td.connect.user", "root"); + (void)tmq_conf_set(conf, "td.connect.pass", "taosdata"); + (void)tmq_conf_set(conf, "auto.offset.reset", "earliest"); + (void)tmq_conf_set(conf, "msg.with.table.name", "true"); tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); + assert(tmq != NULL); tmq_conf_destroy(conf); char topicName[128] = "tp"; // 创建订阅 topics 列表 tmq_list_t* topicList = tmq_list_new(); - tmq_list_append(topicList, topicName); + (void)tmq_list_append(topicList, topicName); // 启动订阅 - tmq_subscribe(tmq, topicList); + (void)tmq_subscribe(tmq, topicList); tmq_list_destroy(topicList); TAOS_FIELD* fields = NULL; @@ -1298,11 +1309,11 @@ TEST(clientCase, td_25129) { int32_t code = tmq_get_topic_assignment(tmq, topicName, &pAssign, &numOfAssign); if (code != 0) { - printf("error occurs:%s\n", tmq_err2str(code)); + (void)printf("error occurs:%s\n", tmq_err2str(code)); tmq_free_assignment(pAssign); - tmq_consumer_close(tmq); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); return; } @@ -1315,11 +1326,11 @@ TEST(clientCase, td_25129) { code = tmq_get_topic_assignment(tmq, topicName, &pAssign, &numOfAssign); if (code != 0) { - printf("error occurs:%s\n", tmq_err2str(code)); + (void)printf("error occurs:%s\n", tmq_err2str(code)); tmq_free_assignment(pAssign); - tmq_consumer_close(tmq); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); return; } @@ -1331,11 +1342,11 @@ TEST(clientCase, td_25129) { code = tmq_get_topic_assignment(tmq, topicName, &pAssign, &numOfAssign); if (code != 0) { - printf("error occurs:%s\n", tmq_err2str(code)); + (void)printf("error occurs:%s\n", tmq_err2str(code)); tmq_free_assignment(pAssign); - tmq_consumer_close(tmq); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); return; } @@ -1345,7 +1356,7 @@ TEST(clientCase, td_25129) { } while (1) { - printf("start to poll\n"); + (void)printf("start to poll\n"); TAOS_RES* pRes = tmq_consumer_poll(tmq, timeout); if (pRes) { char buf[128]; @@ -1354,19 +1365,19 @@ TEST(clientCase, td_25129) { // const char* dbName = tmq_get_db_name(pRes); // int32_t vgroupId = tmq_get_vgroup_id(pRes); // -// printf("topic: %s\n", topicName); -// printf("db: %s\n", dbName); -// printf("vgroup id: %d\n", vgroupId); +// (void)printf("topic: %s\n", topicName); +// (void)printf("db: %s\n", dbName); +// (void)printf("vgroup id: %d\n", vgroupId); printSubResults(pRes, &totalRows); code = tmq_get_topic_assignment(tmq, topicName, &pAssign, &numOfAssign); if (code != 0) { - printf("error occurs:%s\n", tmq_err2str(code)); + (void)printf("error occurs:%s\n", tmq_err2str(code)); tmq_free_assignment(pAssign); - tmq_consumer_close(tmq); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); return; } @@ -1375,9 +1386,9 @@ TEST(clientCase, td_25129) { } } else { for(int i = 0; i < numOfAssign; i++) { - tmq_offset_seek(tmq, topicName, pAssign[i].vgId, pAssign[i].currentOffset); + (void)tmq_offset_seek(tmq, topicName, pAssign[i].vgId, pAssign[i].currentOffset); } - tmq_commit_sync(tmq, pRes); + (void)tmq_commit_sync(tmq, pRes); break; } @@ -1398,11 +1409,11 @@ TEST(clientCase, td_25129) { code = tmq_get_topic_assignment(tmq, "tp", &pAssign, &numOfAssign); if (code != 0) { - printf("error occurs:%s\n", tmq_err2str(code)); + (void)printf("error occurs:%s\n", tmq_err2str(code)); tmq_free_assignment(pAssign); - tmq_consumer_close(tmq); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); return; } @@ -1411,13 +1422,13 @@ TEST(clientCase, td_25129) { } tmq_free_assignment(pAssign); - tmq_consumer_close(tmq); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); } TEST(clientCase, sub_tb_test) { - taos_options(TSDB_OPTION_CONFIGDIR, "~/first/cfg"); + (void)taos_options(TSDB_OPTION_CONFIGDIR, "~/first/cfg"); TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(pConn, nullptr); @@ -1426,27 +1437,28 @@ TEST(clientCase, sub_tb_test) { int32_t ts = taosGetTimestampMs()%INT32_MAX; char consumerGroupid[128] = {0}; - sprintf(consumerGroupid, "group_id_%d", ts); + (void)sprintf(consumerGroupid, "group_id_%d", ts); - tmq_conf_set(conf, "enable.auto.commit", "true"); - tmq_conf_set(conf, "auto.commit.interval.ms", "2000"); - tmq_conf_set(conf, "group.id", consumerGroupid); - tmq_conf_set(conf, "td.connect.user", "root"); - tmq_conf_set(conf, "td.connect.pass", "taosdata"); - tmq_conf_set(conf, "auto.offset.reset", "earliest"); - tmq_conf_set(conf, "experimental.snapshot.enable", "false"); - tmq_conf_set(conf, "msg.with.table.name", "true"); - tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); + (void)tmq_conf_set(conf, "enable.auto.commit", "true"); + (void)tmq_conf_set(conf, "auto.commit.interval.ms", "2000"); + (void)tmq_conf_set(conf, "group.id", consumerGroupid); + (void)tmq_conf_set(conf, "td.connect.user", "root"); + (void)tmq_conf_set(conf, "td.connect.pass", "taosdata"); + (void)tmq_conf_set(conf, "auto.offset.reset", "earliest"); + (void)tmq_conf_set(conf, "experimental.snapshot.enable", "false"); + (void)tmq_conf_set(conf, "msg.with.table.name", "true"); + (void)tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); + assert(tmq != NULL); tmq_conf_destroy(conf); // 创建订阅 topics 列表 tmq_list_t* topicList = tmq_list_new(); - tmq_list_append(topicList, "t1"); + (void)tmq_list_append(topicList, "t1"); // 启动订阅 - tmq_subscribe(tmq, topicList); + (void)tmq_subscribe(tmq, topicList); tmq_list_destroy(topicList); TAOS_FIELD* fields = NULL; @@ -1463,36 +1475,36 @@ TEST(clientCase, sub_tb_test) { int32_t code = tmq_get_topic_assignment(tmq, "t1", &pAssign, &numOfAssign); if (code != 0) { - printf("error occurs:%s\n", tmq_err2str(code)); - tmq_consumer_close(tmq); + (void)printf("error occurs:%s\n", tmq_err2str(code)); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); return; } - tmq_offset_seek(tmq, "t1", pAssign[0].vgId, 4); + (void)tmq_offset_seek(tmq, "t1", pAssign[0].vgId, 4); code = tmq_get_topic_assignment(tmq, "t1", &pAssign, &numOfAssign); if (code != 0) { - printf("error occurs:%s\n", tmq_err2str(code)); - tmq_consumer_close(tmq); + (void)printf("error occurs:%s\n", tmq_err2str(code)); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); return; } while (1) { TAOS_RES* pRes = tmq_consumer_poll(tmq, timeout); if (pRes) { - char buf[128]; + char buf[128] = {0}; const char* topicName = tmq_get_topic_name(pRes); // const char* dbName = tmq_get_db_name(pRes); // int32_t vgroupId = tmq_get_vgroup_id(pRes); // -// printf("topic: %s\n", topicName); -// printf("db: %s\n", dbName); -// printf("vgroup id: %d\n", vgroupId); +// (void)printf("topic: %s\n", topicName); +// (void)printf("db: %s\n", dbName); +// (void)printf("vgroup id: %d\n", vgroupId); printSubResults(pRes, &totalRows); } else { @@ -1500,7 +1512,7 @@ TEST(clientCase, sub_tb_test) { // break; } - tmq_commit_sync(tmq, pRes); + (void)tmq_commit_sync(tmq, pRes); if (pRes != NULL) { taos_free_result(pRes); // if ((++count) > 1) { @@ -1510,12 +1522,12 @@ TEST(clientCase, sub_tb_test) { break; } - tmq_offset_seek(tmq, "topic_t1", pAssign[0].vgId, pAssign[0].begin); + (void)tmq_offset_seek(tmq, "topic_t1", pAssign[0].vgId, pAssign[0].begin); } - tmq_consumer_close(tmq); + (void)tmq_consumer_close(tmq); taos_close(pConn); - fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + (void)fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); } TEST(clientCase, sub_tb_mt_test) { @@ -1524,17 +1536,17 @@ TEST(clientCase, sub_tb_mt_test) { char *ip = NULL; int port = 0; char key[512] = {0}; - snprintf(key, sizeof(key), "%s:%s:%s:%d", user, auth, ip, port); + (void)snprintf(key, sizeof(key), "%s:%s:%s:%d", user, auth, ip, port); - taos_options(TSDB_OPTION_CONFIGDIR, "~/first/cfg"); + (void)taos_options(TSDB_OPTION_CONFIGDIR, "~/first/cfg"); TdThread qid[20] = {0}; for (int32_t i = 0; i < 1; ++i) { - taosThreadCreate(&qid[i], NULL, doConsumeData, NULL); + (void)taosThreadCreate(&qid[i], NULL, doConsumeData, NULL); } for (int32_t i = 0; i < 4; ++i) { - taosThreadJoin(qid[i], NULL); + (void)taosThreadJoin(qid[i], NULL); } } @@ -1552,12 +1564,12 @@ TEST(clientCase, sub_tb_mt_test) { // } // int ret = snprintf(buf + len, size - len, "%s", db); // if (ret < 0) { -// printf("snprintf failed, buf:%s, ret:%d", buf, ret); +// (void)printf("snprintf failed, buf:%s, ret:%d", buf, ret); // break; // } // len += ret; // if (len >= size){ -// printf("dbList is truncated, buf:%s, len:%d", buf, len); +// (void)printf("dbList is truncated, buf:%s, len:%d", buf, len); // break; // } // } diff --git a/source/dnode/mnode/impl/test/topic/topic.cpp b/source/dnode/mnode/impl/test/topic/topic.cpp index 84b3a21a8f..4c2213b700 100644 --- a/source/dnode/mnode/impl/test/topic/topic.cpp +++ b/source/dnode/mnode/impl/test/topic/topic.cpp @@ -31,7 +31,7 @@ Testbase MndTestTopic::test; void* MndTestTopic::BuildCreateDbReq(const char* dbname, int32_t* pContLen) { SCreateDbReq createReq = {0}; - strcpy(createReq.db, dbname); + (void)strcpy(createReq.db, dbname); createReq.numOfVgroups = 2; createReq.buffer = -1; createReq.pageSize = -1; @@ -53,7 +53,8 @@ void* MndTestTopic::BuildCreateDbReq(const char* dbname, int32_t* pContLen) { int32_t contLen = tSerializeSCreateDbReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); - tSerializeSCreateDbReq(pReq, contLen, &createReq); + assert(pReq != NULL); + (void)tSerializeSCreateDbReq(pReq, contLen, &createReq); *pContLen = contLen; return pReq; @@ -61,14 +62,15 @@ void* MndTestTopic::BuildCreateDbReq(const char* dbname, int32_t* pContLen) { void* MndTestTopic::BuildCreateTopicReq(const char* topicName, const char* sql, int32_t* pContLen) { SCMCreateTopicReq createReq = {0}; - strcpy(createReq.name, topicName); + (void)strcpy(createReq.name, topicName); createReq.igExists = 0; createReq.sql = (char*)sql; createReq.ast = NULL; int32_t contLen = tSerializeSCMCreateTopicReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); - tSerializeSCMCreateTopicReq(pReq, contLen, &createReq); + assert(pReq != NULL); + (void)tSerializeSCMCreateTopicReq(pReq, contLen, &createReq); *pContLen = contLen; return pReq; @@ -76,11 +78,12 @@ void* MndTestTopic::BuildCreateTopicReq(const char* topicName, const char* sql, void* MndTestTopic::BuildDropTopicReq(const char* topicName, int32_t* pContLen) { SMDropTopicReq dropReq = {0}; - strcpy(dropReq.name, topicName); + (void)strcpy(dropReq.name, topicName); int32_t contLen = tSerializeSMDropTopicReq(NULL, 0, &dropReq); void* pReq = rpcMallocCont(contLen); - tSerializeSMDropTopicReq(pReq, contLen, &dropReq); + assert(pReq != NULL); + (void)tSerializeSMDropTopicReq(pReq, contLen, &dropReq); *pContLen = contLen; return pReq;