提交 4018b282 编写于 作者: H Hui Li

[modify for coverity scan]

上级 603e31a5
...@@ -120,6 +120,7 @@ static FORCE_INLINE int32_t isValidNumber(const SSQLToken* pToken) { ...@@ -120,6 +120,7 @@ static FORCE_INLINE int32_t isValidNumber(const SSQLToken* pToken) {
type = TK_FLOAT; type = TK_FLOAT;
goto _end; goto _end;
break;
} }
case '0': { case '0': {
...@@ -137,6 +138,7 @@ static FORCE_INLINE int32_t isValidNumber(const SSQLToken* pToken) { ...@@ -137,6 +138,7 @@ static FORCE_INLINE int32_t isValidNumber(const SSQLToken* pToken) {
goto _end; goto _end;
} }
break;
} }
case '1': case '1':
case '2': case '2':
......
...@@ -95,9 +95,6 @@ void* taosArrayGetP(const SArray* pArray, size_t index) { ...@@ -95,9 +95,6 @@ void* taosArrayGetP(const SArray* pArray, size_t index) {
assert(index < pArray->size); assert(index < pArray->size);
void* d = TARRAY_GET_ELEM(pArray, index); void* d = TARRAY_GET_ELEM(pArray, index);
if (d == NULL) {
return NULL;
}
return *(void**)d; return *(void**)d;
} }
......
...@@ -119,7 +119,7 @@ static FORCE_INLINE void taosCacheReleaseNode(SCacheObj *pCacheObj, SCacheDataNo ...@@ -119,7 +119,7 @@ static FORCE_INLINE void taosCacheReleaseNode(SCacheObj *pCacheObj, SCacheDataNo
int32_t size = pNode->size; int32_t size = pNode->size;
taosHashRemove(pCacheObj->pHashTable, pNode->key, pNode->keySize); taosHashRemove(pCacheObj->pHashTable, pNode->key, pNode->keySize);
uTrace("key:%s is removed from cache,total:%d,size:%ldbytes", pNode->key, pCacheObj->totalSize, size); uTrace("key:%s is removed from cache,total:%" PRId64 ",size:%dbytes", pNode->key, pCacheObj->totalSize, size);
if (pCacheObj->freeFp) pCacheObj->freeFp(pNode->data); if (pCacheObj->freeFp) pCacheObj->freeFp(pNode->data);
free(pNode); free(pNode);
} }
...@@ -288,7 +288,7 @@ void *taosCachePut(SCacheObj *pCacheObj, const char *key, const void *pData, siz ...@@ -288,7 +288,7 @@ void *taosCachePut(SCacheObj *pCacheObj, const char *key, const void *pData, siz
if (NULL != pNode) { if (NULL != pNode) {
pCacheObj->totalSize += pNode->size; pCacheObj->totalSize += pNode->size;
uTrace("key:%s %p added into cache, added:%" PRIu64 ", expire:%" PRIu64 ", total:%d, size:%" PRId64 " bytes", uTrace("key:%s %p added into cache, added:%" PRIu64 ", expire:%" PRIu64 ", total:%" PRId64 ", size:%" PRId64 " bytes",
key, pNode, pNode->addedTime, pNode->expiredTime, pCacheObj->totalSize, dataSize); key, pNode, pNode->addedTime, pNode->expiredTime, pCacheObj->totalSize, dataSize);
} else { } else {
uError("key:%s failed to added into cache, out of memory", key); uError("key:%s failed to added into cache, out of memory", key);
...@@ -506,7 +506,7 @@ void taosAddToTrash(SCacheObj *pCacheObj, SCacheDataNode *pNode) { ...@@ -506,7 +506,7 @@ void taosAddToTrash(SCacheObj *pCacheObj, SCacheDataNode *pNode) {
void taosRemoveFromTrashCan(SCacheObj *pCacheObj, STrashElem *pElem) { void taosRemoveFromTrashCan(SCacheObj *pCacheObj, STrashElem *pElem) {
if (pElem->pData->signature != (uint64_t)pElem->pData) { if (pElem->pData->signature != (uint64_t)pElem->pData) {
uError("key:sig:%d %p data has been released, ignore", pElem->pData->signature, pElem->pData); uError("key:sig:0x%x %p data has been released, ignore", pElem->pData->signature, pElem->pData);
return; return;
} }
...@@ -560,7 +560,6 @@ void taosTrashCanEmpty(SCacheObj *pCacheObj, bool force) { ...@@ -560,7 +560,6 @@ void taosTrashCanEmpty(SCacheObj *pCacheObj, bool force) {
} }
} }
assert(pCacheObj->numOfElemsInTrash >= 0);
__cache_unlock(pCacheObj); __cache_unlock(pCacheObj);
} }
......
...@@ -74,7 +74,7 @@ static void taosReadInt32Config(SGlobalCfg *cfg, char *input_value) { ...@@ -74,7 +74,7 @@ static void taosReadInt32Config(SGlobalCfg *cfg, char *input_value) {
*option = value; *option = value;
cfg->cfgStatus = TAOS_CFG_CSTATUS_FILE; cfg->cfgStatus = TAOS_CFG_CSTATUS_FILE;
} else { } else {
uWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, input_value, uWarn("config option:%s, input value:%s, is configured by %s, use %d", cfg->option, input_value,
tsCfgStatusStr[cfg->cfgStatus], *option); tsCfgStatusStr[cfg->cfgStatus], *option);
} }
} }
...@@ -106,7 +106,11 @@ static void taosReadDirectoryConfig(SGlobalCfg *cfg, char *input_value) { ...@@ -106,7 +106,11 @@ static void taosReadDirectoryConfig(SGlobalCfg *cfg, char *input_value) {
} else { } else {
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_FILE) { if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_FILE) {
wordexp_t full_path; wordexp_t full_path;
wordexp(input_value, &full_path, 0); if (0 != wordexp(input_value, &full_path, 0)) {
printf("\nconfig dir: %s wordexp fail! reason:%s\n", input_value, strerror(errno));
wordfree(&full_path);
return;
}
if (full_path.we_wordv != NULL && full_path.we_wordv[0] != NULL) { if (full_path.we_wordv != NULL && full_path.we_wordv[0] != NULL) {
strcpy(option, full_path.we_wordv[0]); strcpy(option, full_path.we_wordv[0]);
} }
...@@ -240,7 +244,12 @@ void taosReadGlobalLogCfg() { ...@@ -240,7 +244,12 @@ void taosReadGlobalLogCfg() {
sdbDebugFlag = 135; sdbDebugFlag = 135;
wordexp_t full_path; wordexp_t full_path;
wordexp(configDir, &full_path, 0); if ( 0 != wordexp(configDir, &full_path, 0)) {
printf("\nconfig file: %s wordexp fail! reason:%s\n", configDir, strerror(errno));
wordfree(&full_path);
return;
}
if (full_path.we_wordv != NULL && full_path.we_wordv[0] != NULL) { if (full_path.we_wordv != NULL && full_path.we_wordv[0] != NULL) {
if (strlen(full_path.we_wordv[0]) >= TSDB_FILENAME_LEN) { if (strlen(full_path.we_wordv[0]) >= TSDB_FILENAME_LEN) {
printf("\nconfig file: %s path overflow max len %d, all variables are set to default\n", full_path.we_wordv[0], TSDB_FILENAME_LEN - 1); printf("\nconfig file: %s path overflow max len %d, all variables are set to default\n", full_path.we_wordv[0], TSDB_FILENAME_LEN - 1);
......
...@@ -142,6 +142,10 @@ static void *taosThreadToOpenNewFile(void *param) { ...@@ -142,6 +142,10 @@ static void *taosThreadToOpenNewFile(void *param) {
umask(0); umask(0);
int32_t fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO); int32_t fd = open(name, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU | S_IRWXG | S_IRWXO);
if (fd < 0) {
uError("open new log file fail! fd:%d reason:%s", fd, strerror(errno));
return NULL;
}
taosLockFile(fd); taosLockFile(fd);
lseek(fd, 0, SEEK_SET); lseek(fd, 0, SEEK_SET);
...@@ -184,7 +188,7 @@ void taosResetLog() { ...@@ -184,7 +188,7 @@ void taosResetLog() {
tsLogObj.lines = tsLogObj.maxLines + 10; tsLogObj.lines = tsLogObj.maxLines + 10;
taosOpenNewLogFile(); taosOpenNewLogFile();
remove(lastName); (void)remove(lastName);
uPrint("=================================="); uPrint("==================================");
uPrint(" reset log file "); uPrint(" reset log file ");
...@@ -279,7 +283,10 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) { ...@@ -279,7 +283,10 @@ static int32_t taosOpenLogFile(char *fn, int32_t maxLines, int32_t maxFileNum) {
// only an estimate for number of lines // only an estimate for number of lines
struct stat filestat; struct stat filestat;
fstat(tsLogObj.logHandle->fd, &filestat); if (fstat(tsLogObj.logHandle->fd, &filestat) < 0) {
printf("\nfailed to fstat log file:%s, reason:%s\n", name, strerror(errno));
return -1;
}
size = (int32_t)filestat.st_size; size = (int32_t)filestat.st_size;
tsLogObj.lines = size / 60; tsLogObj.lines = size / 60;
......
...@@ -214,7 +214,10 @@ int taosOpenNoteWithMaxLines(char *fn, int maxLines, int maxNoteNum, taosNoteInf ...@@ -214,7 +214,10 @@ int taosOpenNoteWithMaxLines(char *fn, int maxLines, int maxNoteNum, taosNoteInf
// only an estimate for number of lines // only an estimate for number of lines
struct stat filestat; struct stat filestat;
fstat(pNote->taosNoteFd, &filestat); if (fstat(pNote->taosNoteFd, &filestat) < 0) {
fprintf(stderr, "failed to fstat note file:%s reason:%s\n", name, strerror(errno));
return -1;
}
size = (int)filestat.st_size; size = (int)filestat.st_size;
pNote->taosNoteLines = size / 60; pNote->taosNoteLines = size / 60;
......
...@@ -72,49 +72,6 @@ void deltaToUtcInitOnce() { ...@@ -72,49 +72,6 @@ void deltaToUtcInitOnce() {
return; return;
} }
int64_t user_mktime(struct tm * tm)
{
#define TAOS_MINUTE 60
#define TAOS_HOUR (60*TAOS_MINUTE)
#define TAOS_DAY (24*TAOS_HOUR)
#define TAOS_YEAR (365*TAOS_DAY)
static int month[12] = {
0,
TAOS_DAY*(31),
TAOS_DAY*(31+29),
TAOS_DAY*(31+29+31),
TAOS_DAY*(31+29+31+30),
TAOS_DAY*(31+29+31+30+31),
TAOS_DAY*(31+29+31+30+31+30),
TAOS_DAY*(31+29+31+30+31+30+31),
TAOS_DAY*(31+29+31+30+31+30+31+31),
TAOS_DAY*(31+29+31+30+31+30+31+31+30),
TAOS_DAY*(31+29+31+30+31+30+31+31+30+31),
TAOS_DAY*(31+29+31+30+31+30+31+31+30+31+30)
};
int64_t res;
int year;
year= tm->tm_year - 70;
res= TAOS_YEAR*year + TAOS_DAY*((year+1)/4);
res+= month[tm->tm_mon];
if(tm->tm_mon > 1 && ((year+2)%4)) {
res-= TAOS_DAY;
}
res+= TAOS_DAY*(tm->tm_mday-1);
res+= TAOS_HOUR*tm->tm_hour;
res+= TAOS_MINUTE*tm->tm_min;
res+= tm->tm_sec;
return res + m_deltaUtc;
}
static int64_t parseFraction(char* str, char** end, int32_t timePrec); static int64_t parseFraction(char* str, char** end, int32_t timePrec);
static int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec); static int32_t parseTimeWithTz(char* timestr, int64_t* time, int32_t timePrec);
static int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec); static int32_t parseLocaltime(char* timestr, int64_t* time, int32_t timePrec);
......
...@@ -139,7 +139,7 @@ static void unlockTimerList(timer_list_t* list) { ...@@ -139,7 +139,7 @@ static void unlockTimerList(timer_list_t* list) {
int64_t tid = taosGetPthreadId(); int64_t tid = taosGetPthreadId();
if (atomic_val_compare_exchange_64(&(list->lockedBy), tid, 0) != tid) { if (atomic_val_compare_exchange_64(&(list->lockedBy), tid, 0) != tid) {
assert(false); assert(false);
tmrError("%d trying to unlock a timer list not locked by current thread.", tid); tmrError("%" PRId64 " trying to unlock a timer list not locked by current thread.", tid);
} }
} }
...@@ -514,14 +514,17 @@ static void taosTmrModuleInit(void) { ...@@ -514,14 +514,17 @@ static void taosTmrModuleInit(void) {
tmrError("failed to create the mutex for wheel, reason:%s", strerror(errno)); tmrError("failed to create the mutex for wheel, reason:%s", strerror(errno));
return; return;
} }
pthread_mutex_lock(&wheel->mutex);
wheel->nextScanAt = now + wheel->resolution; wheel->nextScanAt = now + wheel->resolution;
wheel->index = 0; wheel->index = 0;
wheel->slots = (tmr_obj_t**)calloc(wheel->size, sizeof(tmr_obj_t*)); wheel->slots = (tmr_obj_t**)calloc(wheel->size, sizeof(tmr_obj_t*));
if (wheel->slots == NULL) { if (wheel->slots == NULL) {
tmrError("failed to allocate wheel slots"); tmrError("failed to allocate wheel slots");
pthread_mutex_unlock(&wheel->mutex);
return; return;
} }
timerMap.size += wheel->size; timerMap.size += wheel->size;
pthread_mutex_unlock(&wheel->mutex);
} }
timerMap.count = 0; timerMap.count = 0;
......
...@@ -709,7 +709,7 @@ void taosRemoveDir(char *rootDir) { ...@@ -709,7 +709,7 @@ void taosRemoveDir(char *rootDir) {
if (de->d_type & DT_DIR) { if (de->d_type & DT_DIR) {
taosRemoveDir(filename); taosRemoveDir(filename);
} else { } else {
remove(filename); (void)remove(filename);
uPrint("file:%s is removed", filename); uPrint("file:%s is removed", filename);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册