未验证 提交 de97080d 编写于 作者: sangshuduo's avatar sangshuduo 提交者: GitHub

Hotfix/sangshuduo/td 3197 fix taosdemo coverity scan (#5521)

* [TD-3197] <fix>: fix taosdemo coverity scan issues.

* [TD-3197] <fix>: fix taosdemo coverity scan issue.

fix subscribeTest pids uninitialized.

* [TD-3197] <fix>: fix taosdemo coverity scan issues.
Co-authored-by: NShuduo Sang <sdsang@taosdata.com>
上级 3b4a2ecc
......@@ -4212,7 +4212,7 @@ static void getTableName(char *pTblName, threadInfo* pThreadInfo, int tableSeq)
}
} else {
snprintf(pTblName, TSDB_TABLE_NAME_LEN, "%s%d",
superTblInfo?superTblInfo->childTblPrefix:g_args.tb_prefix, tableSeq);
g_args.tb_prefix, tableSeq);
}
}
......@@ -4355,7 +4355,7 @@ static int generateSQLHead(char *tableName, int32_t tableSeq,
tableName);
} else {
len = snprintf(buffer,
(superTblInfo?superTblInfo->maxSqlLen:g_args.max_sql_len),
superTblInfo->maxSqlLen,
"insert into %s.%s values",
pThreadInfo->db_name,
tableName);
......@@ -5471,11 +5471,15 @@ static int queryTestProcess() {
&& g_queryInfo.superQueryInfo.concurrent > 0) {
pids = malloc(g_queryInfo.superQueryInfo.concurrent * sizeof(pthread_t));
if (NULL == pids) {
taos_close(taos);
ERROR_EXIT("memory allocation failed\n");
}
infos = malloc(g_queryInfo.superQueryInfo.concurrent * sizeof(threadInfo));
if ((NULL == pids) || (NULL == infos)) {
printf("malloc failed for create threads\n");
if (NULL == infos) {
taos_close(taos);
exit(-1);
free(pids);
ERROR_EXIT("memory allocation failed for create threads\n");
}
for (int i = 0; i < g_queryInfo.superQueryInfo.concurrent; i++) {
......@@ -5489,6 +5493,8 @@ static int queryTestProcess() {
sprintf(sqlStr, "use %s", g_queryInfo.dbName);
verbosePrint("%s() %d sqlStr: %s\n", __func__, __LINE__, sqlStr);
if (0 != queryDbExec(t_info->taos, sqlStr, NO_INSERT_TYPE)) {
free(infos);
free(pids);
errorPrint( "use database %s failed!\n\n",
g_queryInfo.dbName);
return -1;
......@@ -5509,11 +5515,21 @@ static int queryTestProcess() {
if ((g_queryInfo.subQueryInfo.sqlCount > 0)
&& (g_queryInfo.subQueryInfo.threadCnt > 0)) {
pidsOfSub = malloc(g_queryInfo.subQueryInfo.threadCnt * sizeof(pthread_t));
if (NULL == pidsOfSub) {
taos_close(taos);
free(infos);
free(pids);
ERROR_EXIT("memory allocation failed for create threads\n");
}
infosOfSub = malloc(g_queryInfo.subQueryInfo.threadCnt * sizeof(threadInfo));
if ((NULL == pidsOfSub) || (NULL == infosOfSub)) {
printf("malloc failed for create threads\n");
if (NULL == infosOfSub) {
taos_close(taos);
exit(-1);
free(pidsOfSub);
free(infos);
free(pids);
ERROR_EXIT("memory allocation failed for create threads\n");
}
int ntables = g_queryInfo.subQueryInfo.childTblCount;
......@@ -5544,7 +5560,7 @@ static int queryTestProcess() {
}
g_queryInfo.subQueryInfo.threadCnt = threads;
}else {
} else {
g_queryInfo.subQueryInfo.threadCnt = 0;
}
......@@ -5568,7 +5584,8 @@ static int queryTestProcess() {
static void subscribe_callback(TAOS_SUB* tsub, TAOS_RES *res, void* param, int code) {
if (res == NULL || taos_errno(res) != 0) {
printf("failed to subscribe result, code:%d, reason:%s\n", code, taos_errstr(res));
errorPrint("%s() LN%d, failed to subscribe result, code:%d, reason:%s\n",
__func__, __LINE__, code, taos_errstr(res));
return;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册