From dbb8cfceaf166223146d16d97b3777a1265353d3 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Fri, 25 Feb 2022 18:07:30 +0800 Subject: [PATCH] [TD-13062]: file system judge pointer error. --- source/dnode/vnode/src/tsdb/tsdbFile.c | 4 ++-- source/libs/index/src/index_fst_counting_writer.c | 2 +- source/libs/tdb/src/db/tdbEnv.c | 2 +- source/libs/tdb/src/db/tdbPgFile.c | 2 +- source/libs/transport/test/rserver.c | 2 +- source/libs/wal/src/walSeek.c | 8 ++++---- source/libs/wal/src/walWrite.c | 6 +++--- source/util/src/tlog.c | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbFile.c b/source/dnode/vnode/src/tsdb/tsdbFile.c index 36fb2b1110..5a00fa20a0 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFile.c +++ b/source/dnode/vnode/src/tsdb/tsdbFile.c @@ -356,7 +356,7 @@ int tsdbCreateDFile(STsdb *pRepo, SDFile *pDFile, bool updateHeader) { ASSERT(pDFile->info.size == 0 && pDFile->info.magic == TSDB_FILE_INIT_MAGIC); pDFile->pFile = taosOpenFile(TSDB_FILE_FULL_NAME(pDFile), TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); - if (pDFile->pFile < 0) { + if (pDFile->pFile == NULL) { if (errno == ENOENT) { // Try to create directory recursively char *s = strdup(TSDB_FILE_REL_NAME(pDFile)); @@ -367,7 +367,7 @@ int tsdbCreateDFile(STsdb *pRepo, SDFile *pDFile, bool updateHeader) { tfree(s); pDFile->pFile = taosOpenFile(TSDB_FILE_FULL_NAME(pDFile), TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_TRUNC); - if (pDFile->pFile < 0) { + if (pDFile->pFile == NULL) { terrno = TAOS_SYSTEM_ERROR(errno); return -1; } diff --git a/source/libs/index/src/index_fst_counting_writer.c b/source/libs/index/src/index_fst_counting_writer.c index 86aa257b48..78c7a8d193 100644 --- a/source/libs/index/src/index_fst_counting_writer.c +++ b/source/libs/index/src/index_fst_counting_writer.c @@ -105,7 +105,7 @@ WriterCtx* writerCtxCreate(WriterType type, const char* path, bool readOnly, int #endif } memcpy(ctx->file.buf, path, strlen(path)); - if (ctx->file.pFile < 0) { + if (ctx->file.pFile == NULL) { indexError("failed to open file, error %d", errno); goto END; } diff --git a/source/libs/tdb/src/db/tdbEnv.c b/source/libs/tdb/src/db/tdbEnv.c index 2afce30828..a415d6d60e 100644 --- a/source/libs/tdb/src/db/tdbEnv.c +++ b/source/libs/tdb/src/db/tdbEnv.c @@ -140,7 +140,7 @@ static int tdbEnvDestroy(TENV *pEnv) { int tdbEnvBeginTxn(TENV *pEnv) { pEnv->jpFile = taosOpenFile(pEnv->jname, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_READ); - if (pEnv->jpFile < 0) { + if (pEnv->jpFile == NULL) { return -1; } diff --git a/source/libs/tdb/src/db/tdbPgFile.c b/source/libs/tdb/src/db/tdbPgFile.c index 48f8ed1792..12f062ebf7 100644 --- a/source/libs/tdb/src/db/tdbPgFile.c +++ b/source/libs/tdb/src/db/tdbPgFile.c @@ -95,7 +95,7 @@ int pgFileOpen(SPgFile **ppPgFile, const char *fname, TENV *pEnv) { int pgFileClose(SPgFile *pPgFile) { if (pPgFile) { - if (pPgFile->pFile >= 0) { + if (pPgFile->pFile != NULL) { taosCloseFile(&pPgFile->pFile); } diff --git a/source/libs/transport/test/rserver.c b/source/libs/transport/test/rserver.c index 794497500c..5432a07649 100644 --- a/source/libs/transport/test/rserver.c +++ b/source/libs/transport/test/rserver.c @@ -43,7 +43,7 @@ void processShellMsg() { for (int i = 0; i < numOfMsgs; ++i) { taosGetQitem(qall, (void **)&pRpcMsg); - if (pDataFile >= 0) { + if (pDataFile != NULL) { if (taosWriteFile(pDataFile, pRpcMsg->pCont, pRpcMsg->contLen) < 0) { tInfo("failed to write data file, reason:%s", strerror(errno)); } diff --git a/source/libs/wal/src/walSeek.c b/source/libs/wal/src/walSeek.c index 7aae9138c1..6b3abcd0f9 100644 --- a/source/libs/wal/src/walSeek.c +++ b/source/libs/wal/src/walSeek.c @@ -58,13 +58,13 @@ int walSetWrite(SWal* pWal) { char fnameStr[WAL_FILE_LEN]; walBuildIdxName(pWal, fileFirstVer, fnameStr); pIdxTFile = taosOpenFile(fnameStr, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_APPEND); - if (pIdxTFile < 0) { + if (pIdxTFile == NULL) { terrno = TAOS_SYSTEM_ERROR(errno); return -1; } walBuildLogName(pWal, fileFirstVer, fnameStr); pLogTFile = taosOpenFile(fnameStr, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_APPEND); - if (pLogTFile < 0) { + if (pLogTFile == NULL) { terrno = TAOS_SYSTEM_ERROR(errno); return -1; } @@ -104,14 +104,14 @@ int walChangeWrite(SWal* pWal, int64_t ver) { int64_t fileFirstVer = pFileInfo->firstVer; walBuildIdxName(pWal, fileFirstVer, fnameStr); pIdxTFile = taosOpenFile(fnameStr, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_APPEND); - if (pIdxTFile < 0) { + if (pIdxTFile == NULL) { terrno = TAOS_SYSTEM_ERROR(errno); pWal->pWriteIdxTFile = NULL; return -1; } walBuildLogName(pWal, fileFirstVer, fnameStr); pLogTFile = taosOpenFile(fnameStr, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_APPEND); - if (pLogTFile < 0) { + if (pLogTFile == NULL) { taosCloseFile(&pIdxTFile); terrno = TAOS_SYSTEM_ERROR(errno); pWal->pWriteLogTFile = NULL; diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c index f9bb168234..ba07134003 100644 --- a/source/libs/wal/src/walWrite.c +++ b/source/libs/wal/src/walWrite.c @@ -89,7 +89,7 @@ int32_t walRollback(SWal *pWal, int64_t ver) { walBuildLogName(pWal, walGetCurFileFirstVer(pWal), fnameStr); TdFilePtr pLogTFile = taosOpenFile(fnameStr, TD_FILE_WRITE | TD_FILE_READ); - if (pLogTFile < 0) { + if (pLogTFile == NULL) { // TODO pthread_mutex_unlock(&pWal->mutex); return -1; @@ -221,13 +221,13 @@ int walRoll(SWal *pWal) { char fnameStr[WAL_FILE_LEN]; walBuildIdxName(pWal, newFileFirstVersion, fnameStr); pIdxTFile = taosOpenFile(fnameStr, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_APPEND); - if (pIdxTFile < 0) { + if (pIdxTFile == NULL) { terrno = TAOS_SYSTEM_ERROR(errno); return -1; } walBuildLogName(pWal, newFileFirstVersion, fnameStr); pLogTFile = taosOpenFile(fnameStr, TD_FILE_CTEATE | TD_FILE_WRITE | TD_FILE_APPEND); - if (pLogTFile < 0) { + if (pLogTFile == NULL) { terrno = TAOS_SYSTEM_ERROR(errno); return -1; } diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index 52593741b4..567885b0f4 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -416,7 +416,7 @@ void taosPrintLog(const char *flags, int32_t dflag, const char *format, ...) { buffer[len++] = '\n'; buffer[len] = 0; - if ((dflag & DEBUG_FILE) && tsLogObj.logHandle && tsLogObj.logHandle->pFile >= 0) { + if ((dflag & DEBUG_FILE) && tsLogObj.logHandle && tsLogObj.logHandle->pFile != NULL) { if (tsAsyncLog) { taosPushLogBuffer(tsLogObj.logHandle, buffer, len); } else { @@ -483,7 +483,7 @@ void taosPrintLongString(const char *flags, int32_t dflag, const char *format, . buffer[len++] = '\n'; buffer[len] = 0; - if ((dflag & DEBUG_FILE) && tsLogObj.logHandle && tsLogObj.logHandle->pFile >= 0) { + if ((dflag & DEBUG_FILE) && tsLogObj.logHandle && tsLogObj.logHandle->pFile != NULL) { if (tsAsyncLog) { taosPushLogBuffer(tsLogObj.logHandle, buffer, len); } else { -- GitLab