From 5f49e3608b87ca05138b80a3945f93e690e4af8e Mon Sep 17 00:00:00 2001 From: Hui Li Date: Tue, 23 Jun 2020 17:44:48 +0800 Subject: [PATCH] modify for coverity scan --- src/kit/taosdump/taosdump.c | 18 ++++++++++++------ src/util/src/hash.c | 3 ++- src/util/src/ttime.c | 9 +++++++-- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c index 63cdf259d6..0b1890c5ab 100644 --- a/src/kit/taosdump/taosdump.c +++ b/src/kit/taosdump/taosdump.c @@ -911,21 +911,27 @@ int32_t taosDumpMetric(char *metric, SDumpArguments *arguments, FILE *fp) { (void)lseek(fd, 0, SEEK_SET); - STableRecord tableInfo; + //STableRecord tableInfo; char tableName[TSDB_TABLE_NAME_LEN] ; char metricName[TSDB_TABLE_NAME_LEN]; - while (1) { - memset(&tableInfo, 0, sizeof(STableRecord)); + ssize_t ret; + while (1) { + //memset(&tableInfo, 0, sizeof(STableRecord)); memset(tableName, 0, TSDB_TABLE_NAME_LEN); memset(metricName, 0, TSDB_TABLE_NAME_LEN); - ssize_t ret = read(fd, &tableInfo, sizeof(STableRecord)); + //ssize_t ret = read(fd, &tableInfo, sizeof(STableRecord)); + //if (ret <= 0) break; + ret = read(fd, tableName, TSDB_TABLE_NAME_LEN); + if (ret <= 0) break; + + ret = read(fd, metricName, TSDB_TABLE_NAME_LEN); if (ret <= 0) break; //tableInfo.name[sizeof(tableInfo.name) - 1] = 0; //tableInfo.metric[sizeof(tableInfo.metric) - 1] = 0; //taosDumpTable(tableInfo.name, tableInfo.metric, arguments, fp); - tstrncpy(tableName, tableInfo.name, TSDB_TABLE_NAME_LEN-1); - tstrncpy(metricName, tableInfo.metric, TSDB_TABLE_NAME_LEN-1); + //tstrncpy(tableName, tableInfo.name, TSDB_TABLE_NAME_LEN-1); + //tstrncpy(metricName, tableInfo.metric, TSDB_TABLE_NAME_LEN-1); taosDumpTable(tableName, metricName, arguments, fp); } diff --git a/src/util/src/hash.c b/src/util/src/hash.c index 1de013c416..4ad06791a6 100644 --- a/src/util/src/hash.c +++ b/src/util/src/hash.c @@ -468,7 +468,8 @@ void taosHashTableResize(SHashObj *pHashObj) { return; } - void *pNewEntry = realloc(pHashObj->hashList, POINTER_BYTES * newSize); + int32_t pointerSize = POINTER_BYTES; + void *pNewEntry = realloc(pHashObj->hashList, pointerSize * newSize); if (pNewEntry == NULL) {// todo handle error // uTrace("cache resize failed due to out of memory, capacity remain:%d", pHashObj->capacity); return; diff --git a/src/util/src/ttime.c b/src/util/src/ttime.c index 5feda312b1..dfec632012 100644 --- a/src/util/src/ttime.c +++ b/src/util/src/ttime.c @@ -56,8 +56,13 @@ int64_t user_mktime64(const unsigned int year0, const unsigned int mon0, year -= 1; } - int64_t res = (((((int64_t) (year/4 - year/100 + year/400 + (int64_t)(367*mon)/12 + day) + - year*365 - 719499)*24 + hour)*60 + min)*60 + sec); + //int64_t res = (((((int64_t) (year/4 - year/100 + year/400 + 367*mon/12 + day) + + // year*365 - 719499)*24 + hour)*60 + min)*60 + sec); + int64_t res; + res = 367*((int64_t)mon)/12; + res += year/4 - year/100 + year/400 + day + year*365 - 719499; + res = res*24; + res = ((res + hour) * 60 + min) * 60 + sec; return (res + timezone); } -- GitLab