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: Shuduo Sang <sdsang@taosdata.com>
This commit is contained in:
parent
3b4a2ecce9
commit
de97080d85
|
@ -4212,7 +4212,7 @@ static void getTableName(char *pTblName, threadInfo* pThreadInfo, int tableSeq)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
snprintf(pTblName, TSDB_TABLE_NAME_LEN, "%s%d",
|
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);
|
tableName);
|
||||||
} else {
|
} else {
|
||||||
len = snprintf(buffer,
|
len = snprintf(buffer,
|
||||||
(superTblInfo?superTblInfo->maxSqlLen:g_args.max_sql_len),
|
superTblInfo->maxSqlLen,
|
||||||
"insert into %s.%s values",
|
"insert into %s.%s values",
|
||||||
pThreadInfo->db_name,
|
pThreadInfo->db_name,
|
||||||
tableName);
|
tableName);
|
||||||
|
@ -5471,11 +5471,15 @@ static int queryTestProcess() {
|
||||||
&& g_queryInfo.superQueryInfo.concurrent > 0) {
|
&& g_queryInfo.superQueryInfo.concurrent > 0) {
|
||||||
|
|
||||||
pids = malloc(g_queryInfo.superQueryInfo.concurrent * sizeof(pthread_t));
|
pids = malloc(g_queryInfo.superQueryInfo.concurrent * sizeof(pthread_t));
|
||||||
infos = malloc(g_queryInfo.superQueryInfo.concurrent * sizeof(threadInfo));
|
if (NULL == pids) {
|
||||||
if ((NULL == pids) || (NULL == infos)) {
|
|
||||||
printf("malloc failed for create threads\n");
|
|
||||||
taos_close(taos);
|
taos_close(taos);
|
||||||
exit(-1);
|
ERROR_EXIT("memory allocation failed\n");
|
||||||
|
}
|
||||||
|
infos = malloc(g_queryInfo.superQueryInfo.concurrent * sizeof(threadInfo));
|
||||||
|
if (NULL == infos) {
|
||||||
|
taos_close(taos);
|
||||||
|
free(pids);
|
||||||
|
ERROR_EXIT("memory allocation failed for create threads\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < g_queryInfo.superQueryInfo.concurrent; i++) {
|
for (int i = 0; i < g_queryInfo.superQueryInfo.concurrent; i++) {
|
||||||
|
@ -5489,6 +5493,8 @@ static int queryTestProcess() {
|
||||||
sprintf(sqlStr, "use %s", g_queryInfo.dbName);
|
sprintf(sqlStr, "use %s", g_queryInfo.dbName);
|
||||||
verbosePrint("%s() %d sqlStr: %s\n", __func__, __LINE__, sqlStr);
|
verbosePrint("%s() %d sqlStr: %s\n", __func__, __LINE__, sqlStr);
|
||||||
if (0 != queryDbExec(t_info->taos, sqlStr, NO_INSERT_TYPE)) {
|
if (0 != queryDbExec(t_info->taos, sqlStr, NO_INSERT_TYPE)) {
|
||||||
|
free(infos);
|
||||||
|
free(pids);
|
||||||
errorPrint( "use database %s failed!\n\n",
|
errorPrint( "use database %s failed!\n\n",
|
||||||
g_queryInfo.dbName);
|
g_queryInfo.dbName);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -5509,11 +5515,21 @@ static int queryTestProcess() {
|
||||||
if ((g_queryInfo.subQueryInfo.sqlCount > 0)
|
if ((g_queryInfo.subQueryInfo.sqlCount > 0)
|
||||||
&& (g_queryInfo.subQueryInfo.threadCnt > 0)) {
|
&& (g_queryInfo.subQueryInfo.threadCnt > 0)) {
|
||||||
pidsOfSub = malloc(g_queryInfo.subQueryInfo.threadCnt * sizeof(pthread_t));
|
pidsOfSub = malloc(g_queryInfo.subQueryInfo.threadCnt * sizeof(pthread_t));
|
||||||
infosOfSub = malloc(g_queryInfo.subQueryInfo.threadCnt * sizeof(threadInfo));
|
if (NULL == pidsOfSub) {
|
||||||
if ((NULL == pidsOfSub) || (NULL == infosOfSub)) {
|
|
||||||
printf("malloc failed for create threads\n");
|
|
||||||
taos_close(taos);
|
taos_close(taos);
|
||||||
exit(-1);
|
free(infos);
|
||||||
|
free(pids);
|
||||||
|
|
||||||
|
ERROR_EXIT("memory allocation failed for create threads\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
infosOfSub = malloc(g_queryInfo.subQueryInfo.threadCnt * sizeof(threadInfo));
|
||||||
|
if (NULL == infosOfSub) {
|
||||||
|
taos_close(taos);
|
||||||
|
free(pidsOfSub);
|
||||||
|
free(infos);
|
||||||
|
free(pids);
|
||||||
|
ERROR_EXIT("memory allocation failed for create threads\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int ntables = g_queryInfo.subQueryInfo.childTblCount;
|
int ntables = g_queryInfo.subQueryInfo.childTblCount;
|
||||||
|
@ -5568,7 +5584,8 @@ static int queryTestProcess() {
|
||||||
|
|
||||||
static void subscribe_callback(TAOS_SUB* tsub, TAOS_RES *res, void* param, int code) {
|
static void subscribe_callback(TAOS_SUB* tsub, TAOS_RES *res, void* param, int code) {
|
||||||
if (res == NULL || taos_errno(res) != 0) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue