Merge pull request #17571 from taosdata/fix/TD-19655-V30
fix(all): fixed coverity scan problems for second submiting
This commit is contained in:
commit
2ba8fef013
|
@ -191,7 +191,7 @@ int32_t taosRenameFile(const char *oldName, const char *newName) {
|
|||
printf("failed to rename file %s to %s, reason:%s\n", oldName, newName, strerror(errno));
|
||||
}
|
||||
|
||||
return !code;
|
||||
return code ? 0 : -1;
|
||||
#else
|
||||
int32_t code = rename(oldName, newName);
|
||||
if (code < 0) {
|
||||
|
|
|
@ -2274,6 +2274,9 @@ int32_t tsCompressBool(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t
|
|||
return tsCompressBoolImp(pIn, nEle, pOut);
|
||||
} else if (cmprAlg == TWO_STAGE_COMP) {
|
||||
int32_t len = tsCompressBoolImp(pIn, nEle, pBuf);
|
||||
if (len < 0) {
|
||||
return -1;
|
||||
}
|
||||
return tsCompressStringImp(pBuf, len, pOut, nOut);
|
||||
} else {
|
||||
assert(0);
|
||||
|
|
|
@ -263,7 +263,7 @@ double tdigestQuantile(TDigest *t, double q) {
|
|||
b = c;
|
||||
right = (b->weight * a->mean + a->weight * b->mean) / (a->weight + b->weight);
|
||||
if (idx < weight_so_far + a->weight) {
|
||||
double p = (idx - weight_so_far) / a->weight;
|
||||
double p = (idx - weight_so_far) / ((a->weight == 0) ? 1 : a->weight);
|
||||
return left * (1 - p) + right * p;
|
||||
}
|
||||
weight_so_far += a->weight;
|
||||
|
|
|
@ -109,7 +109,7 @@ void tEndEncode(SEncoder* pCoder) {
|
|||
pCoder->size = pNode->size;
|
||||
pCoder->pos = pNode->pos;
|
||||
|
||||
tEncodeI32(pCoder, len);
|
||||
(void)tEncodeI32(pCoder, len);
|
||||
|
||||
TD_CODER_MOVE_POS(pCoder, len);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ int32_t taosEnvNameToCfgName(const char *envNameStr, char *cfgNameStr, int32_t c
|
|||
}
|
||||
|
||||
int32_t taosEnvToCfg(const char *envStr, char *cfgStr) {
|
||||
if (envStr == NULL && cfgStr == NULL) {
|
||||
if (envStr == NULL || cfgStr == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (cfgStr != envStr) strcpy(cfgStr, envStr);
|
||||
|
|
|
@ -639,7 +639,7 @@ void taosHashTableResize(SHashObj *pHashObj) {
|
|||
}
|
||||
|
||||
int64_t st = taosGetTimestampUs();
|
||||
void *pNewEntryList = taosMemoryRealloc(pHashObj->hashList, sizeof(void *) * newCapacity);
|
||||
SHashEntry **pNewEntryList = taosMemoryRealloc(pHashObj->hashList, sizeof(SHashEntry *) * newCapacity);
|
||||
if (pNewEntryList == NULL) {
|
||||
// uDebug("cache resize failed due to out of memory, capacity remain:%zu", pHashObj->capacity);
|
||||
return;
|
||||
|
|
|
@ -207,7 +207,8 @@ static void taosKeepOldLog(char *oldName) {
|
|||
char fileName[LOG_FILE_NAME_LEN + 20];
|
||||
snprintf(fileName, LOG_FILE_NAME_LEN + 20, "%s.%" PRId64, tsLogObj.logName, fileSec);
|
||||
|
||||
taosRenameFile(oldName, fileName);
|
||||
(void)taosRenameFile(oldName, fileName);
|
||||
|
||||
if (tsLogKeepDays < 0) {
|
||||
char compressFileName[LOG_FILE_NAME_LEN + 20];
|
||||
snprintf(compressFileName, LOG_FILE_NAME_LEN + 20, "%s.%" PRId64 ".gz", tsLogObj.logName, fileSec);
|
||||
|
|
|
@ -337,6 +337,7 @@ static int taosLRUCacheShardInit(SLRUCacheShard *shard, size_t capacity, bool st
|
|||
|
||||
taosThreadMutexInit(&shard->mutex, NULL);
|
||||
|
||||
taosThreadMutexLock(&shard->mutex);
|
||||
shard->capacity = 0;
|
||||
shard->highPriPoolUsage = 0;
|
||||
shard->strictCapacity = strict;
|
||||
|
@ -349,6 +350,7 @@ static int taosLRUCacheShardInit(SLRUCacheShard *shard, size_t capacity, bool st
|
|||
shard->lru.next = &shard->lru;
|
||||
shard->lru.prev = &shard->lru;
|
||||
shard->lruLowPri = &shard->lru;
|
||||
taosThreadMutexUnlock(&shard->mutex);
|
||||
|
||||
taosLRUCacheShardSetCapacity(shard, capacity);
|
||||
|
||||
|
|
|
@ -534,7 +534,9 @@ void destroyDiskbasedBuf(SDiskbasedBuf* pBuf) {
|
|||
}
|
||||
}
|
||||
|
||||
taosRemoveFile(pBuf->path);
|
||||
if (taosRemoveFile(pBuf->path) < 0) {
|
||||
uDebug("WARNING tPage remove file failed. path=%s", pBuf->path);
|
||||
}
|
||||
taosMemoryFreeClear(pBuf->path);
|
||||
|
||||
size_t n = taosArrayGetSize(pBuf->pIdList);
|
||||
|
|
|
@ -78,7 +78,7 @@ bool insertWord(STire* tire, char* word);
|
|||
bool deleteWord(STire* tire, char* word);
|
||||
|
||||
// match prefix words, if match is not NULL , put all item to match and return match
|
||||
SMatch* matchPrefix(STire* tire, char* prefix, SMatch* match);
|
||||
void matchPrefix(STire* tire, char* prefix, SMatch* match);
|
||||
|
||||
// get all items from tires tree
|
||||
SMatch* enumAll(STire* tire);
|
||||
|
|
|
@ -564,6 +564,7 @@ void parseCommand(SWords* command, bool pattern) {
|
|||
// free SShellCmd
|
||||
void freeCommand(SWords* command) {
|
||||
SWord* item = command->head;
|
||||
command->head = NULL;
|
||||
// loop
|
||||
while (item) {
|
||||
SWord* tmp = item;
|
||||
|
@ -815,7 +816,9 @@ char* matchNextPrefix(STire* tire, char* pre) {
|
|||
match = enumAll(tire);
|
||||
} else {
|
||||
// NOT EMPTY
|
||||
match = matchPrefix(tire, pre, NULL);
|
||||
match = (SMatch*)taosMemoryMalloc(sizeof(SMatch));
|
||||
memset(match, 0, sizeof(SMatch));
|
||||
matchPrefix(tire, pre, match);
|
||||
}
|
||||
|
||||
// save to lastMatch
|
||||
|
@ -828,7 +831,7 @@ char* matchNextPrefix(STire* tire, char* pre) {
|
|||
// check valid
|
||||
if (match == NULL || match->head == NULL) {
|
||||
// no one matched
|
||||
return false;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (cursorVar == -1) {
|
||||
|
|
|
@ -308,25 +308,21 @@ void matchPrefixFromTree(STire* tire, char* prefix, SMatch* match) {
|
|||
}
|
||||
}
|
||||
|
||||
SMatch* matchPrefix(STire* tire, char* prefix, SMatch* match) {
|
||||
SMatch* rMatch = match; // define return match
|
||||
if (rMatch == NULL) {
|
||||
rMatch = (SMatch*)taosMemoryMalloc(sizeof(SMatch));
|
||||
memset(rMatch, 0, sizeof(SMatch));
|
||||
void matchPrefix(STire* tire, char* prefix, SMatch* match) {
|
||||
if (match == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (tire->type) {
|
||||
case TIRE_TREE:
|
||||
matchPrefixFromTree(tire, prefix, rMatch);
|
||||
matchPrefixFromTree(tire, prefix, match);
|
||||
break;
|
||||
case TIRE_LIST:
|
||||
matchPrefixFromList(tire, prefix, rMatch);
|
||||
matchPrefixFromList(tire, prefix, match);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return rMatch;
|
||||
}
|
||||
|
||||
// get all items from tires tree
|
||||
|
@ -360,11 +356,12 @@ void enumFromTree(STire* tire, SMatch* match) {
|
|||
}
|
||||
|
||||
// this branch have data
|
||||
if (c->end)
|
||||
if (c->end) {
|
||||
addWordToMatch(match, pre);
|
||||
else
|
||||
} else {
|
||||
matchPrefix(tire, pre, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get all items from tires tree
|
||||
|
|
Loading…
Reference in New Issue