Merge pull request #2409 from taosdata/hotfix/test
[modify for covrity scan]
This commit is contained in:
commit
99cb63d175
|
@ -168,7 +168,7 @@ void shellReadCommand(TAOS *con, char *command) {
|
||||||
int count = countPrefixOnes(c);
|
int count = countPrefixOnes(c);
|
||||||
utf8_array[0] = c;
|
utf8_array[0] = c;
|
||||||
for (int k = 1; k < count; k++) {
|
for (int k = 1; k < count; k++) {
|
||||||
c = getchar();
|
c = (char)getchar();
|
||||||
utf8_array[k] = c;
|
utf8_array[k] = c;
|
||||||
}
|
}
|
||||||
insertChar(&cmd, utf8_array, count);
|
insertChar(&cmd, utf8_array, count);
|
||||||
|
@ -214,10 +214,10 @@ void shellReadCommand(TAOS *con, char *command) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (c == '\033') {
|
} else if (c == '\033') {
|
||||||
c = getchar();
|
c = (char)getchar();
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '[':
|
case '[':
|
||||||
c = getchar();
|
c = (char)getchar();
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'A': // Up arrow
|
case 'A': // Up arrow
|
||||||
if (hist_counter != history.hstart) {
|
if (hist_counter != history.hstart) {
|
||||||
|
@ -244,35 +244,35 @@ void shellReadCommand(TAOS *con, char *command) {
|
||||||
moveCursorLeft(&cmd);
|
moveCursorLeft(&cmd);
|
||||||
break;
|
break;
|
||||||
case '1':
|
case '1':
|
||||||
if ((c = getchar()) == '~') {
|
if ((c = (char)getchar()) == '~') {
|
||||||
// Home key
|
// Home key
|
||||||
positionCursorHome(&cmd);
|
positionCursorHome(&cmd);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
if ((c = getchar()) == '~') {
|
if ((c = (char)getchar()) == '~') {
|
||||||
// Insert key
|
// Insert key
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '3':
|
case '3':
|
||||||
if ((c = getchar()) == '~') {
|
if ((c = (char)getchar()) == '~') {
|
||||||
// Delete key
|
// Delete key
|
||||||
deleteChar(&cmd);
|
deleteChar(&cmd);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '4':
|
case '4':
|
||||||
if ((c = getchar()) == '~') {
|
if ((c = (char)getchar()) == '~') {
|
||||||
// End key
|
// End key
|
||||||
positionCursorEnd(&cmd);
|
positionCursorEnd(&cmd);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '5':
|
case '5':
|
||||||
if ((c = getchar()) == '~') {
|
if ((c = (char)getchar()) == '~') {
|
||||||
// Page up key
|
// Page up key
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '6':
|
case '6':
|
||||||
if ((c = getchar()) == '~') {
|
if ((c = (char)getchar()) == '~') {
|
||||||
// Page down key
|
// Page down key
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -551,8 +551,8 @@ int main(int argc, char *argv[]) {
|
||||||
for (int i = 0; i < threads; i++) {
|
for (int i = 0; i < threads; i++) {
|
||||||
info *t_info = infos + i;
|
info *t_info = infos + i;
|
||||||
t_info->threadID = i;
|
t_info->threadID = i;
|
||||||
strcpy(t_info->db_name, db_name);
|
tstrncpy(t_info->db_name, db_name, MAX_DB_NAME_SIZE);
|
||||||
strcpy(t_info->tb_prefix, tb_prefix);
|
tstrncpy(t_info->tb_prefix, tb_prefix, MAX_TB_NAME_SIZE);
|
||||||
t_info->datatype = data_type;
|
t_info->datatype = data_type;
|
||||||
t_info->ncols_per_record = ncols_per_record;
|
t_info->ncols_per_record = ncols_per_record;
|
||||||
t_info->nrecords_per_table = nrecords_per_table;
|
t_info->nrecords_per_table = nrecords_per_table;
|
||||||
|
@ -1001,9 +1001,9 @@ int32_t generateData(char *res, char **data_type, int num_of_cols, int64_t times
|
||||||
} else if (strcasecmp(data_type[i % c], "bigint") == 0) {
|
} else if (strcasecmp(data_type[i % c], "bigint") == 0) {
|
||||||
pstr += sprintf(pstr, ", %" PRId64, trand() % 2147483648);
|
pstr += sprintf(pstr, ", %" PRId64, trand() % 2147483648);
|
||||||
} else if (strcasecmp(data_type[i % c], "float") == 0) {
|
} else if (strcasecmp(data_type[i % c], "float") == 0) {
|
||||||
pstr += sprintf(pstr, ", %10.4f", (float)(trand() / 1000));
|
pstr += sprintf(pstr, ", %10.4f", (float)(trand() / 1000.0));
|
||||||
} else if (strcasecmp(data_type[i % c], "double") == 0) {
|
} else if (strcasecmp(data_type[i % c], "double") == 0) {
|
||||||
double t = (double)(trand() / 1000000);
|
double t = (double)(trand() / 1000000.0);
|
||||||
pstr += sprintf(pstr, ", %20.8f", t);
|
pstr += sprintf(pstr, ", %20.8f", t);
|
||||||
} else if (strcasecmp(data_type[i % c], "bool") == 0) {
|
} else if (strcasecmp(data_type[i % c], "bool") == 0) {
|
||||||
bool b = trand() & 1;
|
bool b = trand() & 1;
|
||||||
|
|
|
@ -238,7 +238,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
|
||||||
fprintf(stderr, "Invalid path %s\n", arg);
|
fprintf(stderr, "Invalid path %s\n", arg);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
strcpy(arguments->input, full_path.we_wordv[0]);
|
tstrncpy(arguments->input, full_path.we_wordv[0], TSDB_FILENAME_LEN);
|
||||||
wordfree(&full_path);
|
wordfree(&full_path);
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
|
@ -246,7 +246,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
|
||||||
fprintf(stderr, "Invalid path %s\n", arg);
|
fprintf(stderr, "Invalid path %s\n", arg);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
strcpy(configDir, full_path.we_wordv[0]);
|
tstrncpy(configDir, full_path.we_wordv[0], TSDB_FILENAME_LEN);
|
||||||
wordfree(&full_path);
|
wordfree(&full_path);
|
||||||
break;
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
|
@ -537,11 +537,11 @@ int taosDumpOut(SDumpArguments *arguments) {
|
||||||
|
|
||||||
if (arguments->databases || arguments->all_databases) {
|
if (arguments->databases || arguments->all_databases) {
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
taosDumpDb(dbInfos[i], arguments, fp);
|
(void)taosDumpDb(dbInfos[i], arguments, fp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (arguments->arg_list_len == 1) {
|
if (arguments->arg_list_len == 1) {
|
||||||
taosDumpDb(dbInfos[0], arguments, fp);
|
(void)taosDumpDb(dbInfos[0], arguments, fp);
|
||||||
} else {
|
} else {
|
||||||
taosDumpCreateDbClause(dbInfos[0], arguments->with_property, fp);
|
taosDumpCreateDbClause(dbInfos[0], arguments->with_property, fp);
|
||||||
|
|
||||||
|
@ -560,9 +560,9 @@ int taosDumpOut(SDumpArguments *arguments) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tableRecordInfo.isMetric) { // dump whole metric
|
if (tableRecordInfo.isMetric) { // dump whole metric
|
||||||
taosDumpMetric(tableRecordInfo.tableRecord.metric, arguments, fp);
|
(void)taosDumpMetric(tableRecordInfo.tableRecord.metric, arguments, fp);
|
||||||
} else { // dump MTable and NTable
|
} else { // dump MTable and NTable
|
||||||
taosDumpTable(tableRecordInfo.tableRecord.name, tableRecordInfo.tableRecord.metric, arguments, fp);
|
(void)taosDumpTable(tableRecordInfo.tableRecord.name, tableRecordInfo.tableRecord.metric, arguments, fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -645,6 +645,7 @@ int taosDumpDb(SDbInfo *dbInfo, SDumpArguments *arguments, FILE *fp) {
|
||||||
(void)lseek(fd, 0, SEEK_SET);
|
(void)lseek(fd, 0, SEEK_SET);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
memset(&tableRecord, 0, sizeof(STableRecord));
|
||||||
ssize_t ret = read(fd, &tableRecord, sizeof(STableRecord));
|
ssize_t ret = read(fd, &tableRecord, sizeof(STableRecord));
|
||||||
if (ret <= 0) break;
|
if (ret <= 0) break;
|
||||||
|
|
||||||
|
@ -654,8 +655,9 @@ int taosDumpDb(SDbInfo *dbInfo, SDumpArguments *arguments, FILE *fp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
remove(".table.tmp");
|
||||||
|
|
||||||
return remove(".table.tmp");
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosDumpCreateTableClause(STableDef *tableDes, int numOfCols, SDumpArguments *arguments, FILE *fp) {
|
void taosDumpCreateTableClause(STableDef *tableDes, int numOfCols, SDumpArguments *arguments, FILE *fp) {
|
||||||
|
@ -877,7 +879,7 @@ int32_t taosDumpMetric(char *metric, SDumpArguments *arguments, FILE *fp) {
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
STableRecord tableRecord;
|
STableRecord tableRecord;
|
||||||
|
|
||||||
tstrncpy(tableRecord.metric, metric, TSDB_TABLE_NAME_LEN);
|
//tstrncpy(tableRecord.metric, metric, TSDB_TABLE_NAME_LEN);
|
||||||
|
|
||||||
sprintf(command, "select tbname from %s", metric);
|
sprintf(command, "select tbname from %s", metric);
|
||||||
TAOS_RES* result = taos_query(taos, command);
|
TAOS_RES* result = taos_query(taos, command);
|
||||||
|
@ -898,8 +900,8 @@ int32_t taosDumpMetric(char *metric, SDumpArguments *arguments, FILE *fp) {
|
||||||
|
|
||||||
while ((row = taos_fetch_row(result)) != NULL) {
|
while ((row = taos_fetch_row(result)) != NULL) {
|
||||||
memset(&tableRecord, 0, sizeof(STableRecord));
|
memset(&tableRecord, 0, sizeof(STableRecord));
|
||||||
strncpy(tableRecord.name, (char *)row[0], fields[0].bytes);
|
tstrncpy(tableRecord.name, (char *)row[0], fields[0].bytes);
|
||||||
strcpy(tableRecord.metric, metric);
|
tstrncpy(tableRecord.metric, metric, TSDB_TABLE_NAME_LEN);
|
||||||
twrite(fd, &tableRecord, sizeof(STableRecord));
|
twrite(fd, &tableRecord, sizeof(STableRecord));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -908,7 +910,8 @@ int32_t taosDumpMetric(char *metric, SDumpArguments *arguments, FILE *fp) {
|
||||||
|
|
||||||
(void)lseek(fd, 0, SEEK_SET);
|
(void)lseek(fd, 0, SEEK_SET);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
memset(&tableRecord, 0, sizeof(STableRecord));
|
||||||
ssize_t ret = read(fd, &tableRecord, sizeof(STableRecord));
|
ssize_t ret = read(fd, &tableRecord, sizeof(STableRecord));
|
||||||
if (ret <= 0) break;
|
if (ret <= 0) break;
|
||||||
|
|
||||||
|
@ -917,7 +920,7 @@ int32_t taosDumpMetric(char *metric, SDumpArguments *arguments, FILE *fp) {
|
||||||
taosDumpTable(tableRecord.name, tableRecord.metric, arguments, fp);
|
taosDumpTable(tableRecord.name, tableRecord.metric, arguments, fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
tclose(fd);
|
close(fd);
|
||||||
(void)remove(".table.tmp");
|
(void)remove(".table.tmp");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -162,7 +162,13 @@ static void taosGetSystemTimezone() {
|
||||||
FILE *f = fopen("/etc/timezone", "r");
|
FILE *f = fopen("/etc/timezone", "r");
|
||||||
char buf[65] = {0};
|
char buf[65] = {0};
|
||||||
if (f != NULL) {
|
if (f != NULL) {
|
||||||
(void)fread(buf, 64, 1, f);
|
int len = fread(buf, 64, 1, f);
|
||||||
|
if(len < 64 && ferror(f)) {
|
||||||
|
fclose(f);
|
||||||
|
uError("read /etc/timezone error, reason:%s", strerror(errno));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,7 +553,7 @@ void taosSetCoreDump() {
|
||||||
struct rlimit rlim;
|
struct rlimit rlim;
|
||||||
struct rlimit rlim_new;
|
struct rlimit rlim_new;
|
||||||
if (getrlimit(RLIMIT_CORE, &rlim) == 0) {
|
if (getrlimit(RLIMIT_CORE, &rlim) == 0) {
|
||||||
uPrint("the old unlimited para: rlim_cur=%d, rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
|
uPrint("the old unlimited para: rlim_cur=%" PRIu64, ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
|
||||||
rlim_new.rlim_cur = RLIM_INFINITY;
|
rlim_new.rlim_cur = RLIM_INFINITY;
|
||||||
rlim_new.rlim_max = RLIM_INFINITY;
|
rlim_new.rlim_max = RLIM_INFINITY;
|
||||||
if (setrlimit(RLIMIT_CORE, &rlim_new) != 0) {
|
if (setrlimit(RLIMIT_CORE, &rlim_new) != 0) {
|
||||||
|
@ -559,7 +565,7 @@ void taosSetCoreDump() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getrlimit(RLIMIT_CORE, &rlim) == 0) {
|
if (getrlimit(RLIMIT_CORE, &rlim) == 0) {
|
||||||
uPrint("the new unlimited para: rlim_cur=%d, rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
|
uPrint("the new unlimited para: rlim_cur=%" PRIu64, ", rlim_max=%" PRIu64, rlim.rlim_cur, rlim.rlim_max);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _TD_ARM_
|
#ifndef _TD_ARM_
|
||||||
|
|
|
@ -147,7 +147,7 @@ static void *taosThreadToOpenNewFile(void *param) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
taosLockFile(fd);
|
taosLockFile(fd);
|
||||||
lseek(fd, 0, SEEK_SET);
|
(void)lseek(fd, 0, SEEK_SET);
|
||||||
|
|
||||||
int32_t oldFd = tsLogObj.logHandle->fd;
|
int32_t oldFd = tsLogObj.logHandle->fd;
|
||||||
tsLogObj.logHandle->fd = fd;
|
tsLogObj.logHandle->fd = fd;
|
||||||
|
|
|
@ -92,7 +92,7 @@ void *taosThreadToOpenNewNote(void *param)
|
||||||
}
|
}
|
||||||
|
|
||||||
taosLockNote(fd, pNote);
|
taosLockNote(fd, pNote);
|
||||||
lseek(fd, 0, SEEK_SET);
|
(void)lseek(fd, 0, SEEK_SET);
|
||||||
|
|
||||||
int oldFd = pNote->taosNoteFd;
|
int oldFd = pNote->taosNoteFd;
|
||||||
pNote->taosNoteFd = fd;
|
pNote->taosNoteFd = fd;
|
||||||
|
|
Loading…
Reference in New Issue