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

Hotfix/sangshuduo/td 3197 taosdemo coverity scan for master (#8004)

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

* exit if read sample file failed.

* fix converity scan issue.

* fix coverity scan issue.

* fix coverity scan memory leak.

* fix resource leak reported by coverity scan.

* fix taosdemo coverity scan issue.

* fix tcsetattr and getchar return value determination bug.

* fix coverity scan issue.

* fix two more coverity scan issues.

* fix stmt batch coverity scan issue.

* change to portable format.
Co-authored-by: NShuduo Sang <sdsang@taosdata.com>
上级 e1b3c5cb
...@@ -7668,7 +7668,7 @@ UNUSED_FUNC static int32_t prepareStbStmtRand( ...@@ -7668,7 +7668,7 @@ UNUSED_FUNC static int32_t prepareStbStmtRand(
} }
#if STMT_BIND_PARAM_BATCH == 1 #if STMT_BIND_PARAM_BATCH == 1
static int execBindParamBatch( static int execStbBindParamBatch(
threadInfo *pThreadInfo, threadInfo *pThreadInfo,
char *tableName, char *tableName,
int64_t tableSeq, int64_t tableSeq,
...@@ -7682,7 +7682,9 @@ static int execBindParamBatch( ...@@ -7682,7 +7682,9 @@ static int execBindParamBatch(
TAOS_STMT *stmt = pThreadInfo->stmt; TAOS_STMT *stmt = pThreadInfo->stmt;
SSuperTable *stbInfo = pThreadInfo->stbInfo; SSuperTable *stbInfo = pThreadInfo->stbInfo;
uint32_t columnCount = (stbInfo)?pThreadInfo->stbInfo->columnCount:g_args.columnCount; assert(stbInfo);
uint32_t columnCount = pThreadInfo->stbInfo->columnCount;
uint32_t thisBatch = MAX_SAMPLES - (*pSamplePos); uint32_t thisBatch = MAX_SAMPLES - (*pSamplePos);
...@@ -7707,29 +7709,39 @@ static int execBindParamBatch( ...@@ -7707,29 +7709,39 @@ static int execBindParamBatch(
param->buffer = pThreadInfo->bind_ts_array; param->buffer = pThreadInfo->bind_ts_array;
} else { } else {
data_type = (stbInfo)?stbInfo->columns[c-1].data_type:g_args.data_type[c-1]; data_type = stbInfo->columns[c-1].data_type;
char *tmpP; char *tmpP;
switch(data_type) { switch(data_type) {
case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_BINARY:
param->buffer_length =
stbInfo->columns[c-1].dataLen;
tmpP =
(char *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray
+sizeof(char*)*(c-1)));
verbosePrint("%s() LN%d, tmpP=%p pos=%"PRId64" width=%"PRIxPTR" position=%"PRId64"\n",
__func__, __LINE__, tmpP, *pSamplePos, param->buffer_length,
(*pSamplePos) * param->buffer_length);
param->buffer = (void *)(tmpP + *pSamplePos * param->buffer_length);
break;
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
param->buffer_length = param->buffer_length =
((stbInfo)?stbInfo->columns[c-1].dataLen:g_args.binwidth); stbInfo->columns[c-1].dataLen;
tmpP = tmpP =
(char *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray (char *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray
+sizeof(char*)*(c-1))); +sizeof(char*)*(c-1)));
verbosePrint("%s() LN%d, tmpP=%p pos=%"PRId64" width=%d position=%"PRId64"\n", verbosePrint("%s() LN%d, tmpP=%p pos=%"PRId64" width=%"PRIxPTR" position=%"PRId64"\n",
__func__, __LINE__, tmpP, *pSamplePos, __func__, __LINE__, tmpP, *pSamplePos, param->buffer_length,
(((stbInfo)?stbInfo->columns[c-1].dataLen:g_args.binwidth)), (*pSamplePos) * param->buffer_length);
(*pSamplePos) *
(((stbInfo)?stbInfo->columns[c-1].dataLen:g_args.binwidth)));
param->buffer = (void *)(tmpP + *pSamplePos * param->buffer = (void *)(tmpP + *pSamplePos * param->buffer_length);
(((stbInfo)?stbInfo->columns[c-1].dataLen:g_args.binwidth))
);
break; break;
case TSDB_DATA_TYPE_INT: case TSDB_DATA_TYPE_INT:
...@@ -8372,7 +8384,7 @@ static int32_t prepareStbStmt( ...@@ -8372,7 +8384,7 @@ static int32_t prepareStbStmt(
} }
#if STMT_BIND_PARAM_BATCH == 1 #if STMT_BIND_PARAM_BATCH == 1
return execBindParamBatch( return execStbBindParamBatch(
pThreadInfo, pThreadInfo,
tableName, tableName,
tableSeq, tableSeq,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册