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

Merge pull request #5520 from taosdata/hotfix/TD-3298

[TD-3298]<hotfix>: fix coverity scan error
...@@ -27,7 +27,7 @@ SDisk *tfsNewDisk(int level, int id, const char *dir) { ...@@ -27,7 +27,7 @@ SDisk *tfsNewDisk(int level, int id, const char *dir) {
pDisk->level = level; pDisk->level = level;
pDisk->id = id; pDisk->id = id;
strncpy(pDisk->dir, dir, TSDB_FILENAME_LEN); tstrncpy(pDisk->dir, dir, TSDB_FILENAME_LEN);
return pDisk; return pDisk;
} }
......
...@@ -187,7 +187,7 @@ void tfsInitFile(TFILE *pf, int level, int id, const char *bname) { ...@@ -187,7 +187,7 @@ void tfsInitFile(TFILE *pf, int level, int id, const char *bname) {
pf->level = level; pf->level = level;
pf->id = id; pf->id = id;
strncpy(pf->rname, bname, TSDB_FILENAME_LEN); tstrncpy(pf->rname, bname, TSDB_FILENAME_LEN);
char tmpName[TMPNAME_LEN] = {0}; char tmpName[TMPNAME_LEN] = {0};
snprintf(tmpName, TMPNAME_LEN, "%s/%s", DISK_DIR(pDisk), bname); snprintf(tmpName, TMPNAME_LEN, "%s/%s", DISK_DIR(pDisk), bname);
...@@ -230,15 +230,15 @@ void *tfsDecodeFile(void *buf, TFILE *pf) { ...@@ -230,15 +230,15 @@ void *tfsDecodeFile(void *buf, TFILE *pf) {
void tfsbasename(const TFILE *pf, char *dest) { void tfsbasename(const TFILE *pf, char *dest) {
char tname[TSDB_FILENAME_LEN] = "\0"; char tname[TSDB_FILENAME_LEN] = "\0";
strncpy(tname, pf->aname, TSDB_FILENAME_LEN); tstrncpy(tname, pf->aname, TSDB_FILENAME_LEN);
strncpy(dest, basename(tname), TSDB_FILENAME_LEN); tstrncpy(dest, basename(tname), TSDB_FILENAME_LEN);
} }
void tfsdirname(const TFILE *pf, char *dest) { void tfsdirname(const TFILE *pf, char *dest) {
char tname[TSDB_FILENAME_LEN] = "\0"; char tname[TSDB_FILENAME_LEN] = "\0";
strncpy(tname, pf->aname, TSDB_FILENAME_LEN); tstrncpy(tname, pf->aname, TSDB_FILENAME_LEN);
strncpy(dest, dirname(tname), TSDB_FILENAME_LEN); tstrncpy(dest, dirname(tname), TSDB_FILENAME_LEN);
} }
// DIR APIs ==================================== // DIR APIs ====================================
...@@ -344,7 +344,7 @@ TDIR *tfsOpendir(const char *rname) { ...@@ -344,7 +344,7 @@ TDIR *tfsOpendir(const char *rname) {
} }
tfsInitDiskIter(&(tdir->iter)); tfsInitDiskIter(&(tdir->iter));
strncpy(tdir->dirname, rname, TSDB_FILENAME_LEN); tstrncpy(tdir->dirname, rname, TSDB_FILENAME_LEN);
if (tfsOpendirImpl(tdir) < 0) { if (tfsOpendirImpl(tdir) < 0) {
free(tdir); free(tdir);
......
...@@ -334,7 +334,7 @@ static FORCE_INLINE int tsdbOpenDFileSet(SDFileSet* pSet, int flags) { ...@@ -334,7 +334,7 @@ static FORCE_INLINE int tsdbOpenDFileSet(SDFileSet* pSet, int flags) {
static FORCE_INLINE void tsdbRemoveDFileSet(SDFileSet* pSet) { static FORCE_INLINE void tsdbRemoveDFileSet(SDFileSet* pSet) {
for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) { for (TSDB_FILE_T ftype = 0; ftype < TSDB_FILE_MAX; ftype++) {
tsdbRemoveDFile(TSDB_DFILE_IN_SET(pSet, ftype)); (void)tsdbRemoveDFile(TSDB_DFILE_IN_SET(pSet, ftype));
} }
} }
......
...@@ -164,7 +164,7 @@ static int tsdbCommitMeta(STsdbRepo *pRepo) { ...@@ -164,7 +164,7 @@ static int tsdbCommitMeta(STsdbRepo *pRepo) {
tsdbError("vgId:%d failed to update META record, uid %" PRIu64 " since %s", REPO_ID(pRepo), pAct->uid, tsdbError("vgId:%d failed to update META record, uid %" PRIu64 " since %s", REPO_ID(pRepo), pAct->uid,
tstrerror(terrno)); tstrerror(terrno));
tsdbCloseMFile(&mf); tsdbCloseMFile(&mf);
tsdbApplyMFileChange(&mf, pOMFile); (void)tsdbApplyMFileChange(&mf, pOMFile);
// TODO: need to reload metaCache // TODO: need to reload metaCache
return -1; return -1;
} }
...@@ -304,7 +304,7 @@ static int tsdbCommitTSData(STsdbRepo *pRepo) { ...@@ -304,7 +304,7 @@ static int tsdbCommitTSData(STsdbRepo *pRepo) {
SDFileSet *pSet = NULL; SDFileSet *pSet = NULL;
int fid; int fid;
memset(&commith, 0, sizeof(SMemTable *)); memset(&commith, 0, sizeof(commith));
if (pMem->numOfRows <= 0) { if (pMem->numOfRows <= 0) {
// No memory data, just apply retention on each file on disk // No memory data, just apply retention on each file on disk
...@@ -399,9 +399,9 @@ static void tsdbEndCommit(STsdbRepo *pRepo, int eno) { ...@@ -399,9 +399,9 @@ static void tsdbEndCommit(STsdbRepo *pRepo, int eno) {
if (pRepo->appH.notifyStatus) pRepo->appH.notifyStatus(pRepo->appH.appH, TSDB_STATUS_COMMIT_OVER, eno); if (pRepo->appH.notifyStatus) pRepo->appH.notifyStatus(pRepo->appH.appH, TSDB_STATUS_COMMIT_OVER, eno);
SMemTable *pIMem = pRepo->imem; SMemTable *pIMem = pRepo->imem;
tsdbLockRepo(pRepo); (void)tsdbLockRepo(pRepo);
pRepo->imem = NULL; pRepo->imem = NULL;
tsdbUnlockRepo(pRepo); (void)tsdbUnlockRepo(pRepo);
tsdbUnRefMemTable(pRepo, pIMem); tsdbUnRefMemTable(pRepo, pIMem);
tsem_post(&(pRepo->readyToCommit)); tsem_post(&(pRepo->readyToCommit));
} }
...@@ -1136,12 +1136,12 @@ static int tsdbMoveBlock(SCommitH *pCommith, int bidx) { ...@@ -1136,12 +1136,12 @@ static int tsdbMoveBlock(SCommitH *pCommith, int bidx) {
} }
static int tsdbCommitAddBlock(SCommitH *pCommith, const SBlock *pSupBlock, const SBlock *pSubBlocks, int nSubBlocks) { static int tsdbCommitAddBlock(SCommitH *pCommith, const SBlock *pSupBlock, const SBlock *pSubBlocks, int nSubBlocks) {
if (taosArrayPush(pCommith->aSupBlk, pSupBlock) < 0) { if (taosArrayPush(pCommith->aSupBlk, pSupBlock) == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
return -1; return -1;
} }
if (pSubBlocks && taosArrayPushBatch(pCommith->aSubBlk, pSubBlocks, nSubBlocks) < 0) { if (pSubBlocks && taosArrayPushBatch(pCommith->aSubBlk, pSubBlocks, nSubBlocks) == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
return -1; return -1;
} }
...@@ -1379,7 +1379,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid ...@@ -1379,7 +1379,7 @@ static int tsdbSetAndOpenCommitFile(SCommitH *pCommith, SDFileSet *pSet, int fid
tstrerror(terrno)); tstrerror(terrno));
tsdbCloseDFileSet(pWSet); tsdbCloseDFileSet(pWSet);
tsdbRemoveDFile(pWHeadf); (void)tsdbRemoveDFile(pWHeadf);
if (pCommith->isRFileSet) { if (pCommith->isRFileSet) {
tsdbCloseAndUnsetFSet(&(pCommith->readh)); tsdbCloseAndUnsetFSet(&(pCommith->readh));
return -1; return -1;
......
...@@ -380,7 +380,7 @@ static int tsdbSaveFSStatus(SFSStatus *pStatus, int vid) { ...@@ -380,7 +380,7 @@ static int tsdbSaveFSStatus(SFSStatus *pStatus, int vid) {
if (taosWrite(fd, pBuf, fsheader.len) < fsheader.len) { if (taosWrite(fd, pBuf, fsheader.len) < fsheader.len) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
close(fd); close(fd);
remove(tfname); (void)remove(tfname);
taosTZfree(pBuf); taosTZfree(pBuf);
return -1; return -1;
} }
...@@ -413,7 +413,7 @@ static void tsdbApplyFSTxnOnDisk(SFSStatus *pFrom, SFSStatus *pTo) { ...@@ -413,7 +413,7 @@ static void tsdbApplyFSTxnOnDisk(SFSStatus *pFrom, SFSStatus *pTo) {
sizeTo = taosArrayGetSize(pTo->df); sizeTo = taosArrayGetSize(pTo->df);
// Apply meta file change // Apply meta file change
tsdbApplyMFileChange(pFrom->pmf, pTo->pmf); (void)tsdbApplyMFileChange(pFrom->pmf, pTo->pmf);
// Apply SDFileSet change // Apply SDFileSet change
if (ifrom >= sizeFrom) { if (ifrom >= sizeFrom) {
...@@ -853,7 +853,7 @@ static int tsdbScanRootDir(STsdbRepo *pRepo) { ...@@ -853,7 +853,7 @@ static int tsdbScanRootDir(STsdbRepo *pRepo) {
continue; continue;
} }
tfsremove(pf); (void)tfsremove(pf);
tsdbDebug("vgId:%d invalid file %s is removed", REPO_ID(pRepo), TFILE_NAME(pf)); tsdbDebug("vgId:%d invalid file %s is removed", REPO_ID(pRepo), TFILE_NAME(pf));
} }
...@@ -879,7 +879,7 @@ static int tsdbScanDataDir(STsdbRepo *pRepo) { ...@@ -879,7 +879,7 @@ static int tsdbScanDataDir(STsdbRepo *pRepo) {
tfsbasename(pf, bname); tfsbasename(pf, bname);
if (!tsdbIsTFileInFS(pfs, pf)) { if (!tsdbIsTFileInFS(pfs, pf)) {
tfsremove(pf); (void)tfsremove(pf);
tsdbDebug("vgId:%d invalid file %s is removed", REPO_ID(pRepo), TFILE_NAME(pf)); tsdbDebug("vgId:%d invalid file %s is removed", REPO_ID(pRepo), TFILE_NAME(pf));
} }
} }
...@@ -939,7 +939,7 @@ static int tsdbRestoreMeta(STsdbRepo *pRepo) { ...@@ -939,7 +939,7 @@ static int tsdbRestoreMeta(STsdbRepo *pRepo) {
if (strcmp(bname, tsdbTxnFname[TSDB_TXN_TEMP_FILE]) == 0) { if (strcmp(bname, tsdbTxnFname[TSDB_TXN_TEMP_FILE]) == 0) {
// Skip current.t file // Skip current.t file
tsdbInfo("vgId:%d file %s exists, remove it", REPO_ID(pRepo), TFILE_NAME(pf)); tsdbInfo("vgId:%d file %s exists, remove it", REPO_ID(pRepo), TFILE_NAME(pf));
tfsremove(pf); (void)tfsremove(pf);
continue; continue;
} }
...@@ -1045,7 +1045,7 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) { ...@@ -1045,7 +1045,7 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) {
int code = regexec(&regex, bname, 0, NULL, 0); int code = regexec(&regex, bname, 0, NULL, 0);
if (code == 0) { if (code == 0) {
if (taosArrayPush(fArray, (void *)pf) < 0) { if (taosArrayPush(fArray, (void *)pf) == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
tfsClosedir(tdir); tfsClosedir(tdir);
taosArrayDestroy(fArray); taosArrayDestroy(fArray);
...@@ -1055,7 +1055,7 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) { ...@@ -1055,7 +1055,7 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) {
} else if (code == REG_NOMATCH) { } else if (code == REG_NOMATCH) {
// Not match // Not match
tsdbInfo("vgId:%d invalid file %s exists, remove it", REPO_ID(pRepo), TFILE_NAME(pf)); tsdbInfo("vgId:%d invalid file %s exists, remove it", REPO_ID(pRepo), TFILE_NAME(pf));
tfsremove(pf); (void)tfsremove(pf);
continue; continue;
} else { } else {
// Has other error // Has other error
......
...@@ -523,7 +523,7 @@ static int tsdbApplyDFileChange(SDFile *from, SDFile *to) { ...@@ -523,7 +523,7 @@ static int tsdbApplyDFileChange(SDFile *from, SDFile *to) {
tsdbRollBackDFile(to); tsdbRollBackDFile(to);
} }
} else { } else {
tsdbRemoveDFile(from); (void)tsdbRemoveDFile(from);
} }
} }
} }
......
...@@ -139,7 +139,7 @@ int tsdbLoadBlockIdx(SReadH *pReadh) { ...@@ -139,7 +139,7 @@ int tsdbLoadBlockIdx(SReadH *pReadh) {
ptr = tsdbDecodeSBlockIdx(ptr, &blkIdx); ptr = tsdbDecodeSBlockIdx(ptr, &blkIdx);
ASSERT(ptr != NULL); ASSERT(ptr != NULL);
if (taosArrayPush(pReadh->aBlkIdx, (void *)(&blkIdx)) < 0) { if (taosArrayPush(pReadh->aBlkIdx, (void *)(&blkIdx)) == NULL) {
terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; terrno = TSDB_CODE_TDB_OUT_OF_MEMORY;
return -1; return -1;
} }
......
...@@ -47,7 +47,6 @@ static FORCE_INLINE int taosCalcChecksumAppend(TSCKSUM csi, uint8_t *stream, uin ...@@ -47,7 +47,6 @@ static FORCE_INLINE int taosCalcChecksumAppend(TSCKSUM csi, uint8_t *stream, uin
} }
static FORCE_INLINE int taosCheckChecksum(const uint8_t *stream, uint32_t ssize, TSCKSUM checksum) { static FORCE_INLINE int taosCheckChecksum(const uint8_t *stream, uint32_t ssize, TSCKSUM checksum) {
if (ssize < 0) return 0;
return (checksum == (*crc32c)(0, stream, (size_t)ssize)); return (checksum == (*crc32c)(0, stream, (size_t)ssize));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册