提交 02436e6d 编写于 作者: H Hui Li

[modify for covrity scan]

上级 3c1850ac
......@@ -168,7 +168,7 @@ void shellReadCommand(TAOS *con, char *command) {
int count = countPrefixOnes(c);
utf8_array[0] = c;
for (int k = 1; k < count; k++) {
c = getchar();
c = (char)getchar();
utf8_array[k] = c;
}
insertChar(&cmd, utf8_array, count);
......@@ -214,10 +214,10 @@ void shellReadCommand(TAOS *con, char *command) {
break;
}
} else if (c == '\033') {
c = getchar();
c = (char)getchar();
switch (c) {
case '[':
c = getchar();
c = (char)getchar();
switch (c) {
case 'A': // Up arrow
if (hist_counter != history.hstart) {
......@@ -244,35 +244,35 @@ void shellReadCommand(TAOS *con, char *command) {
moveCursorLeft(&cmd);
break;
case '1':
if ((c = getchar()) == '~') {
if ((c = (char)getchar()) == '~') {
// Home key
positionCursorHome(&cmd);
}
break;
case '2':
if ((c = getchar()) == '~') {
if ((c = (char)getchar()) == '~') {
// Insert key
}
break;
case '3':
if ((c = getchar()) == '~') {
if ((c = (char)getchar()) == '~') {
// Delete key
deleteChar(&cmd);
}
break;
case '4':
if ((c = getchar()) == '~') {
if ((c = (char)getchar()) == '~') {
// End key
positionCursorEnd(&cmd);
}
break;
case '5':
if ((c = getchar()) == '~') {
if ((c = (char)getchar()) == '~') {
// Page up key
}
break;
case '6':
if ((c = getchar()) == '~') {
if ((c = (char)getchar()) == '~') {
// Page down key
}
break;
......
......@@ -551,8 +551,8 @@ int main(int argc, char *argv[]) {
for (int i = 0; i < threads; i++) {
info *t_info = infos + i;
t_info->threadID = i;
strcpy(t_info->db_name, db_name);
strcpy(t_info->tb_prefix, tb_prefix);
tstrncpy(t_info->db_name, db_name, MAX_DB_NAME_SIZE);
tstrncpy(t_info->tb_prefix, tb_prefix, MAX_TB_NAME_SIZE);
t_info->datatype = data_type;
t_info->ncols_per_record = ncols_per_record;
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) {
pstr += sprintf(pstr, ", %" PRId64, trand() % 2147483648);
} 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) {
double t = (double)(trand() / 1000000);
double t = (double)(trand() / 1000000.0);
pstr += sprintf(pstr, ", %20.8f", t);
} else if (strcasecmp(data_type[i % c], "bool") == 0) {
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);
return -1;
}
strcpy(arguments->input, full_path.we_wordv[0]);
tstrncpy(arguments->input, full_path.we_wordv[0], TSDB_FILENAME_LEN);
wordfree(&full_path);
break;
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);
return -1;
}
strcpy(configDir, full_path.we_wordv[0]);
tstrncpy(configDir, full_path.we_wordv[0], TSDB_FILENAME_LEN);
wordfree(&full_path);
break;
case 'e':
......@@ -537,11 +537,11 @@ int taosDumpOut(SDumpArguments *arguments) {
if (arguments->databases || arguments->all_databases) {
for (int i = 0; i < count; i++) {
taosDumpDb(dbInfos[i], arguments, fp);
(void)taosDumpDb(dbInfos[i], arguments, fp);
}
} else {
if (arguments->arg_list_len == 1) {
taosDumpDb(dbInfos[0], arguments, fp);
(void)taosDumpDb(dbInfos[0], arguments, fp);
} else {
taosDumpCreateDbClause(dbInfos[0], arguments->with_property, fp);
......@@ -560,9 +560,9 @@ int taosDumpOut(SDumpArguments *arguments) {
}
if (tableRecordInfo.isMetric) { // dump whole metric
taosDumpMetric(tableRecordInfo.tableRecord.metric, arguments, fp);
(void)taosDumpMetric(tableRecordInfo.tableRecord.metric, arguments, fp);
} 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);
while (1) {
memset(&tableRecord, 0, sizeof(STableRecord));
ssize_t ret = read(fd, &tableRecord, sizeof(STableRecord));
if (ret <= 0) break;
......@@ -654,8 +655,9 @@ int taosDumpDb(SDbInfo *dbInfo, SDumpArguments *arguments, FILE *fp) {
}
close(fd);
remove(".table.tmp");
return remove(".table.tmp");
return 0;
}
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;
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);
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) {
memset(&tableRecord, 0, sizeof(STableRecord));
strncpy(tableRecord.name, (char *)row[0], fields[0].bytes);
strcpy(tableRecord.metric, metric);
tstrncpy(tableRecord.name, (char *)row[0], fields[0].bytes);
tstrncpy(tableRecord.metric, metric, TSDB_TABLE_NAME_LEN);
twrite(fd, &tableRecord, sizeof(STableRecord));
}
......@@ -908,7 +910,8 @@ int32_t taosDumpMetric(char *metric, SDumpArguments *arguments, FILE *fp) {
(void)lseek(fd, 0, SEEK_SET);
while (1) {
while (1) {
memset(&tableRecord, 0, sizeof(STableRecord));
ssize_t ret = read(fd, &tableRecord, sizeof(STableRecord));
if (ret <= 0) break;
......@@ -917,7 +920,7 @@ int32_t taosDumpMetric(char *metric, SDumpArguments *arguments, FILE *fp) {
taosDumpTable(tableRecord.name, tableRecord.metric, arguments, fp);
}
tclose(fd);
close(fd);
(void)remove(".table.tmp");
return 0;
......
......@@ -162,7 +162,13 @@ static void taosGetSystemTimezone() {
FILE *f = fopen("/etc/timezone", "r");
char buf[65] = {0};
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);
}
......@@ -547,7 +553,7 @@ void taosSetCoreDump() {
struct rlimit rlim;
struct rlimit rlim_new;
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_max = RLIM_INFINITY;
if (setrlimit(RLIMIT_CORE, &rlim_new) != 0) {
......@@ -559,7 +565,7 @@ void taosSetCoreDump() {
}
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_
......
......@@ -147,7 +147,7 @@ static void *taosThreadToOpenNewFile(void *param) {
return NULL;
}
taosLockFile(fd);
lseek(fd, 0, SEEK_SET);
(void)lseek(fd, 0, SEEK_SET);
int32_t oldFd = tsLogObj.logHandle->fd;
tsLogObj.logHandle->fd = fd;
......
......@@ -92,7 +92,7 @@ void *taosThreadToOpenNewNote(void *param)
}
taosLockNote(fd, pNote);
lseek(fd, 0, SEEK_SET);
(void)lseek(fd, 0, SEEK_SET);
int oldFd = pNote->taosNoteFd;
pNote->taosNoteFd = fd;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册