未验证 提交 f8799745 编写于 作者: S Shengliang Guan 提交者: GitHub

Merge pull request #3100 from taosdata/feature/2.0tsdb

fix part of coverity scan problem
......@@ -132,7 +132,7 @@ int tsdbOpenFileH(STsdbRepo *pRepo) {
char *fname = malloc(strlen(tDataDir) + strlen(dp->d_name) + 2);
if (fname == NULL) goto _err;
sprintf(fname, "%s/%s", tDataDir, dp->d_name);
remove(fname);
(void)remove(fname);
free(fname);
} else if (code == REG_NOMATCH) {
tsdbError("vgId:%d invalid file %s exists, ignore it", REPO_ID(pRepo), dp->d_name);
......@@ -447,6 +447,8 @@ void tsdbGetFileInfoImpl(char *fname, uint32_t *magic, int32_t *size) {
*magic = info.magic;
*size = (int32_t)offset;
return;
_err:
if (fd >= 0) close(fd);
*magic = TSDB_FILE_INIT_MAGIC;
......
......@@ -683,11 +683,11 @@ static int tsdbCommitToFile(STsdbRepo *pRepo, int fid, SCommitIter *iters, SRWHe
pthread_rwlock_wrlock(&(pFileH->fhlock));
rename(helperNewHeadF(pHelper)->fname, helperHeadF(pHelper)->fname);
(void)rename(helperNewHeadF(pHelper)->fname, helperHeadF(pHelper)->fname);
pGroup->files[TSDB_FILE_TYPE_HEAD].info = helperNewHeadF(pHelper)->info;
if (newLast) {
rename(helperNewLastF(pHelper)->fname, helperLastF(pHelper)->fname);
(void)rename(helperNewLastF(pHelper)->fname, helperLastF(pHelper)->fname);
pGroup->files[TSDB_FILE_TYPE_LAST].info = helperNewLastF(pHelper)->info;
} else {
pGroup->files[TSDB_FILE_TYPE_LAST].info = helperLastF(pHelper)->info;
......
......@@ -351,6 +351,8 @@ void tsdbGetStoreInfo(char *fname, uint32_t *magic, int32_t *size) {
*magic = info.magic;
*size = (int32_t)offset;
return;
_err:
if (fd >= 0) close(fd);
*magic = TD_KVSTORE_INIT_MAGIC;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册