From 4feaf77b8caf5c058d0816be754eabc62e78f875 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 19 Sep 2024 16:48:55 +0800 Subject: [PATCH 1/2] remove void --- source/libs/index/inc/indexUtil.h | 34 ++++----- source/libs/index/src/index.c | 42 +++++------ source/libs/index/src/indexCache.c | 66 +++++++++--------- source/libs/index/src/indexComm.c | 16 ++--- source/libs/index/src/indexFilter.c | 4 +- source/libs/index/src/indexFst.c | 88 ++++++++++++------------ source/libs/index/src/indexFstDfa.c | 2 +- source/libs/index/src/indexFstFile.c | 26 +++---- source/libs/index/src/indexFstRegister.c | 6 +- source/libs/index/src/indexFstUtil.c | 2 +- source/libs/index/src/indexTfile.c | 38 +++++----- 11 files changed, 163 insertions(+), 161 deletions(-) diff --git a/source/libs/index/inc/indexUtil.h b/source/libs/index/inc/indexUtil.h index 9eb8001d17..61c16e1217 100644 --- a/source/libs/index/inc/indexUtil.h +++ b/source/libs/index/inc/indexUtil.h @@ -21,29 +21,29 @@ extern "C" { #endif -#define SERIALIZE_MEM_TO_BUF(buf, key, mem) \ - do { \ - (void)memcpy((void *)buf, (void *)(&key->mem), sizeof(key->mem)); \ - buf += sizeof(key->mem); \ +#define SERIALIZE_MEM_TO_BUF(buf, key, mem) \ + do { \ + TAOS_UNUSED(memcpy((void *)buf, (void *)(&key->mem), sizeof(key->mem))); \ + buf += sizeof(key->mem); \ } while (0) -#define SERIALIZE_STR_MEM_TO_BUF(buf, key, mem, len) \ - do { \ - (void)memcpy((void *)buf, (void *)key->mem, len); \ - buf += len; \ +#define SERIALIZE_STR_MEM_TO_BUF(buf, key, mem, len) \ + do { \ + TAOS_UNUSED(memcpy((void *)buf, (void *)key->mem, len)); \ + buf += len; \ } while (0) -#define SERIALIZE_VAR_TO_BUF(buf, var, type) \ - do { \ - type c = var; \ - (void)memcpy((void *)buf, (void *)&c, sizeof(c)); \ - buf += sizeof(c); \ +#define SERIALIZE_VAR_TO_BUF(buf, var, type) \ + do { \ + type c = var; \ + TAOS_UNUSED(memcpy((void *)buf, (void *)&c, sizeof(c))); \ + buf += sizeof(c); \ } while (0) -#define SERIALIZE_STR_VAR_TO_BUF(buf, var, len) \ - do { \ - (void)memcpy((void *)buf, (void *)var, len); \ - buf += len; \ +#define SERIALIZE_STR_VAR_TO_BUF(buf, var, len) \ + do { \ + TAOS_UNUSED(memcpy((void *)buf, (void *)var, len)); \ + buf += len; \ } while (0) #define INDEX_MERGE_ADD_DEL(src, dst, tgt) \ diff --git a/source/libs/index/src/index.c b/source/libs/index/src/index.c index b2fd0afd68..066e496663 100644 --- a/source/libs/index/src/index.c +++ b/source/libs/index/src/index.c @@ -99,15 +99,15 @@ static int32_t idxMergeCacheAndTFile(SArray* result, IterateValue* icache, Itera static void idxPost(void* idx) { SIndex* pIdx = idx; - (void)tsem_post(&pIdx->sem); + TAOS_UNUSED(tsem_post(&pIdx->sem)); } static void indexWait(void* idx) { SIndex* pIdx = idx; - (void)tsem_wait(&pIdx->sem); + TAOS_UNUSED(tsem_wait(&pIdx->sem)); } int32_t indexOpen(SIndexOpts* opts, const char* path, SIndex** index) { - (void)taosThreadOnce(&isInit, indexEnvInit); + TAOS_UNUSED(taosThreadOnce(&isInit, indexEnvInit)); int code = TSDB_CODE_SUCCESS; SIndex* idx = taosMemoryCalloc(1, sizeof(SIndex)); @@ -137,8 +137,8 @@ int32_t indexOpen(SIndexOpts* opts, const char* path, SIndex** index) { TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, END); } - (void)taosThreadMutexInit(&idx->mtx, NULL); - (void)tsem_init(&idx->sem, 0, 0); + TAOS_UNUSED(taosThreadMutexInit(&idx->mtx, NULL)); + TAOS_UNUSED(tsem_init(&idx->sem, 0, 0)); idx->refId = idxAddRef(idx); idx->opts = *opts; @@ -158,8 +158,8 @@ END: void indexDestroy(void* handle) { if (handle == NULL) return; SIndex* idx = handle; - (void)taosThreadMutexDestroy(&idx->mtx); - (void)tsem_destroy(&idx->sem); + TAOS_UNUSED(taosThreadMutexDestroy(&idx->mtx)); + TAOS_UNUSED(tsem_destroy(&idx->sem)); idxTFileDestroy(idx->tindex); taosMemoryFree(idx->path); @@ -190,7 +190,7 @@ void indexClose(SIndex* sIdx) { } idxReleaseRef(sIdx->refId); - (void)idxRemoveRef(sIdx->refId); + TAOS_UNUSED(idxRemoveRef(sIdx->refId)); } int64_t idxAddRef(void* p) { // impl @@ -203,17 +203,17 @@ int32_t idxRemoveRef(int64_t ref) { void idxAcquireRef(int64_t ref) { // impl - (void)taosAcquireRef(indexRefMgt, ref); + TAOS_UNUSED(taosAcquireRef(indexRefMgt, ref)); } void idxReleaseRef(int64_t ref) { // impl - (void)taosReleaseRef(indexRefMgt, ref); + TAOS_UNUSED(taosReleaseRef(indexRefMgt, ref)); } int32_t indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) { // TODO(yihao): reduce the lock range int32_t code = 0; - (void)taosThreadMutexLock(&index->mtx); + TAOS_UNUSED(taosThreadMutexLock(&index->mtx)); for (int i = 0; i < taosArrayGetSize(fVals); i++) { SIndexTerm* p = taosArrayGetP(fVals, i); @@ -231,7 +231,7 @@ int32_t indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) { } } } - (void)taosThreadMutexUnlock(&index->mtx); + TAOS_UNUSED(taosThreadMutexUnlock(&index->mtx)); if (code != 0) { return code; @@ -278,7 +278,7 @@ int32_t indexSearch(SIndex* index, SIndexMultiTermQuery* multiQuerys, SArray* re return TSDB_CODE_OUT_OF_MEMORY; } } - (void)idxMergeFinalResults(iRslts, opera, result); + TAOS_UNUSED(idxMergeFinalResults(iRslts, opera, result)); idxInterRsltDestroy(iRslts); return 0; } @@ -421,7 +421,7 @@ void indexRebuild(SIndexJson* idx, void* iter) { schedMsg.fp = idxSchedRebuildIdx; schedMsg.ahandle = idx; idxAcquireRef(idx->refId); - (void)taosScheduleTask(indexQhandle, &schedMsg); + TAOS_UNUSED(taosScheduleTask(indexQhandle, &schedMsg)); } /* @@ -463,10 +463,10 @@ static int32_t idxTermSearch(SIndex* sIdx, SIndexTermQuery* query, SArray** resu int32_t sz = idxSerialCacheKey(&key, buf); - (void)taosThreadMutexLock(&sIdx->mtx); + TAOS_UNUSED(taosThreadMutexLock(&sIdx->mtx)); IndexCache** pCache = taosHashGet(sIdx->colObj, buf, sz); cache = (pCache == NULL) ? NULL : *pCache; - (void)taosThreadMutexUnlock(&sIdx->mtx); + TAOS_UNUSED(taosThreadMutexUnlock(&sIdx->mtx)); *result = taosArrayInit(4, sizeof(uint64_t)); if (*result == NULL) { @@ -757,9 +757,9 @@ static int64_t idxGetAvailableVer(SIndex* sIdx, IndexCache* cache) { IndexTFile* tf = (IndexTFile*)(sIdx->tindex); - (void)taosThreadMutexLock(&tf->mtx); + TAOS_UNUSED(taosThreadMutexLock(&tf->mtx)); TFileReader* rd = tfileCacheGet(tf->cache, &key); - (void)taosThreadMutexUnlock(&tf->mtx); + TAOS_UNUSED(taosThreadMutexUnlock(&tf->mtx)); if (rd != NULL) { ver = (ver > rd->header.version ? ver : rd->header.version) + 1; @@ -801,9 +801,9 @@ static int32_t idxGenTFile(SIndex* sIdx, IndexCache* cache, SArray* batch) { TFileHeader* header = &reader->header; ICacheKey key = {.suid = cache->suid, .colName = header->colName, .nColName = strlen(header->colName)}; - (void)taosThreadMutexLock(&tf->mtx); + TAOS_UNUSED(taosThreadMutexLock(&tf->mtx)); code = tfileCachePut(tf->cache, &key, reader); - (void)taosThreadMutexUnlock(&tf->mtx); + TAOS_UNUSED(taosThreadMutexUnlock(&tf->mtx)); return code; @@ -820,7 +820,7 @@ int32_t idxSerialCacheKey(ICacheKey* key, char* buf) { char* p = buf; char tbuf[65] = {0}; - (void)idxInt2str((int64_t)key->suid, tbuf, 0); + TAOS_UNUSED(idxInt2str((int64_t)key->suid, tbuf, 0)); SERIALIZE_STR_VAR_TO_BUF(buf, tbuf, strlen(tbuf)); SERIALIZE_VAR_TO_BUF(buf, '_', char); diff --git a/source/libs/index/src/indexCache.c b/source/libs/index/src/indexCache.c index 828a3e2e9e..613c2430c9 100644 --- a/source/libs/index/src/indexCache.c +++ b/source/libs/index/src/indexCache.c @@ -109,7 +109,7 @@ static int32_t cacheSearchTerm(void* cache, SIndexTerm* term, SIdxTRslt* tr, STe } taosMemoryFree(pCt); - (void)tSkipListDestroyIter(iter); + TAOS_UNUSED(tSkipListDestroyIter(iter)); return code; } static int32_t cacheSearchPrefix(void* cache, SIndexTerm* term, SIdxTRslt* tr, STermValueType* s) { @@ -153,7 +153,7 @@ static int32_t cacheSearchCompareFunc(void* cache, SIndexTerm* term, SIdxTRslt* break; } CacheTerm* c = (CacheTerm*)SL_GET_NODE_DATA(node); - TExeCond cond = cmpFn(c->colVal, pCt->colVal, pCt->colType); + TExeCond cond = cmpFn(c->colVal, pCt->colVal, pCt->colType); if (cond == FAILED) { code = terrno; goto _return; @@ -178,7 +178,7 @@ static int32_t cacheSearchCompareFunc(void* cache, SIndexTerm* term, SIdxTRslt* _return: taosMemoryFree(pCt); - (void)tSkipListDestroyIter(iter); + TAOS_UNUSED(tSkipListDestroyIter(iter)); return code; } static int32_t cacheSearchLessThan(void* cache, SIndexTerm* term, SIdxTRslt* tr, STermValueType* s) { @@ -244,7 +244,7 @@ static int32_t cacheSearchTerm_JSON(void* cache, SIndexTerm* term, SIdxTRslt* tr taosMemoryFree(pCt); taosMemoryFree(exBuf); - (void)tSkipListDestroyIter(iter); + TAOS_UNUSED(tSkipListDestroyIter(iter)); return code; } static int32_t cacheSearchSuffix_JSON(void* cache, SIndexTerm* term, SIdxTRslt* tr, STermValueType* s) { @@ -363,7 +363,7 @@ static int32_t cacheSearchCompareFunc_JSON(void* cache, SIndexTerm* term, SIdxTR _return: taosMemoryFree(pCt); taosMemoryFree(exBuf); - (void)tSkipListDestroyIter(iter); + TAOS_UNUSED(tSkipListDestroyIter(iter)); return code; } @@ -390,8 +390,8 @@ IndexCache* idxCacheCreate(SIndex* idx, uint64_t suid, const char* colName, int8 cache->suid = suid; cache->occupiedMem = 0; - (void)taosThreadMutexInit(&cache->mtx, NULL); - (void)taosThreadCondInit(&cache->finished, NULL); + TAOS_UNUSED(taosThreadMutexInit(&cache->mtx, NULL)); + TAOS_UNUSED(taosThreadCondInit(&cache->finished, NULL)); idxCacheRef(cache); if (idx != NULL) { @@ -402,10 +402,10 @@ IndexCache* idxCacheCreate(SIndex* idx, uint64_t suid, const char* colName, int8 void idxCacheDebug(IndexCache* cache) { MemTable* tbl = NULL; - (void)taosThreadMutexLock(&cache->mtx); + TAOS_UNUSED(taosThreadMutexLock(&cache->mtx)); tbl = cache->mem; idxMemRef(tbl); - (void)taosThreadMutexUnlock(&cache->mtx); + TAOS_UNUSED(taosThreadMutexUnlock(&cache->mtx)); { SSkipList* slt = tbl->mem; @@ -418,16 +418,16 @@ void idxCacheDebug(IndexCache* cache) { indexInfo("{colVal: %s, version: %" PRId64 "} \t", ct->colVal, ct->version); } } - (void)tSkipListDestroyIter(iter); + TAOS_UNUSED(tSkipListDestroyIter(iter)); idxMemUnRef(tbl); } { - (void)taosThreadMutexLock(&cache->mtx); + TAOS_UNUSED(taosThreadMutexLock(&cache->mtx)); tbl = cache->imm; idxMemRef(tbl); - (void)taosThreadMutexUnlock(&cache->mtx); + TAOS_UNUSED(taosThreadMutexUnlock(&cache->mtx)); if (tbl != NULL) { SSkipList* slt = tbl->mem; SSkipListIterator* iter = tSkipListCreateIter(slt); @@ -439,7 +439,7 @@ void idxCacheDebug(IndexCache* cache) { indexInfo("{colVal: %s, version: %" PRId64 "} \t", ct->colVal, ct->version); } } - (void)tSkipListDestroyIter(iter); + TAOS_UNUSED(tSkipListDestroyIter(iter)); } idxMemUnRef(tbl); @@ -456,29 +456,29 @@ void idxCacheDestroySkiplist(SSkipList* slt) { taosMemoryFree(ct); } } - (void)tSkipListDestroyIter(iter); + TAOS_UNUSED(tSkipListDestroyIter(iter)); tSkipListDestroy(slt); } void idxCacheBroadcast(void* cache) { IndexCache* pCache = cache; - (void)taosThreadCondBroadcast(&pCache->finished); + TAOS_UNUSED(taosThreadCondBroadcast(&pCache->finished)); } void idxCacheWait(void* cache) { IndexCache* pCache = cache; - (void)taosThreadCondWait(&pCache->finished, &pCache->mtx); + TAOS_UNUSED(taosThreadCondWait(&pCache->finished, &pCache->mtx)); } void idxCacheDestroyImm(IndexCache* cache) { if (cache == NULL) { return; } MemTable* tbl = NULL; - (void)taosThreadMutexLock(&cache->mtx); + TAOS_UNUSED(taosThreadMutexLock(&cache->mtx)); tbl = cache->imm; cache->imm = NULL; // or throw int bg thread idxCacheBroadcast(cache); - (void)taosThreadMutexUnlock(&cache->mtx); + TAOS_UNUSED(taosThreadMutexUnlock(&cache->mtx)); idxMemUnRef(tbl); idxMemUnRef(tbl); @@ -493,8 +493,8 @@ void idxCacheDestroy(void* cache) { idxMemUnRef(pCache->imm); taosMemoryFree(pCache->colName); - (void)taosThreadMutexDestroy(&pCache->mtx); - (void)taosThreadCondDestroy(&pCache->finished); + TAOS_UNUSED(taosThreadMutexDestroy(&pCache->mtx)); + TAOS_UNUSED(taosThreadCondDestroy(&pCache->finished)); if (pCache->index != NULL) { idxReleaseRef(((SIndex*)pCache->index)->refId); } @@ -509,7 +509,7 @@ Iterate* idxCacheIteratorCreate(IndexCache* cache) { if (iter == NULL) { return NULL; } - (void)taosThreadMutexLock(&cache->mtx); + TAOS_UNUSED(taosThreadMutexLock(&cache->mtx)); idxMemRef(cache->imm); @@ -520,7 +520,7 @@ Iterate* idxCacheIteratorCreate(IndexCache* cache) { iter->next = idxCacheIteratorNext; iter->getValue = idxCacheIteratorGetValue; - (void)taosThreadMutexUnlock(&cache->mtx); + TAOS_UNUSED(taosThreadMutexUnlock(&cache->mtx)); return iter; } @@ -528,7 +528,7 @@ void idxCacheIteratorDestroy(Iterate* iter) { if (iter == NULL) { return; } - (void)tSkipListDestroyIter(iter->iter); + TAOS_UNUSED(tSkipListDestroyIter(iter->iter)); iterateValueDestroy(&iter->val, true); taosMemoryFree(iter); } @@ -542,7 +542,7 @@ int idxCacheSchedToMerge(IndexCache* pCache, bool notify) { } schedMsg.msg = NULL; idxAcquireRef(pCache->index->refId); - (void)taosScheduleTask(indexQhandle, &schedMsg); + TAOS_UNUSED(taosScheduleTask(indexQhandle, &schedMsg)); return 0; } @@ -567,7 +567,7 @@ static void idxCacheMakeRoomForWrite(IndexCache* cache) { } // 1. sched to merge // 2. unref cache in bgwork - (void)idxCacheSchedToMerge(cache, quit); + TAOS_UNUSED(idxCacheSchedToMerge(cache, quit)); } } } @@ -603,15 +603,15 @@ int idxCachePut(void* cache, SIndexTerm* term, uint64_t uid) { // ugly code, refactor later int64_t estimate = sizeof(ct) + strlen(ct->colVal); - (void)taosThreadMutexLock(&pCache->mtx); + TAOS_UNUSED(taosThreadMutexLock(&pCache->mtx)); pCache->occupiedMem += estimate; idxCacheMakeRoomForWrite(pCache); MemTable* tbl = pCache->mem; idxMemRef(tbl); - (void)tSkipListPut(tbl->mem, (char*)ct); + TAOS_UNUSED(tSkipListPut(tbl->mem, (char*)ct)); idxMemUnRef(tbl); - (void)taosThreadMutexUnlock(&pCache->mtx); + TAOS_UNUSED(taosThreadMutexUnlock(&pCache->mtx)); idxCacheUnRef(pCache); return 0; } @@ -619,13 +619,13 @@ void idxCacheForceToMerge(void* cache) { IndexCache* pCache = cache; idxCacheRef(pCache); - (void)taosThreadMutexLock(&pCache->mtx); + TAOS_UNUSED(taosThreadMutexLock(&pCache->mtx)); indexInfo("%p is forced to merge into tfile", pCache); pCache->occupiedMem += MEM_SIGNAL_QUIT; idxCacheMakeRoomForWrite(pCache); - (void)taosThreadMutexUnlock(&pCache->mtx); + TAOS_UNUSED(taosThreadMutexUnlock(&pCache->mtx)); idxCacheUnRef(pCache); return; } @@ -656,12 +656,12 @@ int idxCacheSearch(void* cache, SIndexTermQuery* query, SIdxTRslt* result, STerm IndexCache* pCache = cache; MemTable *mem = NULL, *imm = NULL; - (void)taosThreadMutexLock(&pCache->mtx); + TAOS_UNUSED(taosThreadMutexLock(&pCache->mtx)); mem = pCache->mem; imm = pCache->imm; idxMemRef(mem); idxMemRef(imm); - (void)taosThreadMutexUnlock(&pCache->mtx); + TAOS_UNUSED(taosThreadMutexUnlock(&pCache->mtx)); int64_t st = taosGetTimestampUs(); @@ -797,7 +797,7 @@ static void idxDoMergeWork(SSchedMsg* msg) { int quit = msg->thandle ? true : false; taosMemoryFree(msg->thandle); - (void)idxFlushCacheToTFile(sidx, pCache, quit); + TAOS_UNUSED(idxFlushCacheToTFile(sidx, pCache, quit)); } static bool idxCacheIteratorNext(Iterate* itera) { SSkipListIterator* iter = itera->iter; diff --git a/source/libs/index/src/indexComm.c b/source/libs/index/src/indexComm.c index 0fab194044..fee0df5582 100644 --- a/source/libs/index/src/indexComm.c +++ b/source/libs/index/src/indexComm.c @@ -349,7 +349,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { if (*dst == NULL) { return terrno; } - (void)idxInt2str(*(int64_t*)src, *dst, -1); + TAOS_UNUSED(idxInt2str(*(int64_t*)src, *dst, -1)); tlen = strlen(*dst); break; case TSDB_DATA_TYPE_BOOL: @@ -358,7 +358,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { if (*dst == NULL) { return terrno; } - (void)idxInt2str(*(uint8_t*)src, *dst, 1); + TAOS_UNUSED(idxInt2str(*(uint8_t*)src, *dst, 1)); tlen = strlen(*dst); break; case TSDB_DATA_TYPE_TINYINT: @@ -366,7 +366,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { if (*dst == NULL) { return terrno; } - (void)idxInt2str(*(int8_t*)src, *dst, 1); + TAOS_UNUSED(idxInt2str(*(int8_t*)src, *dst, 1)); tlen = strlen(*dst); break; case TSDB_DATA_TYPE_SMALLINT: @@ -374,12 +374,12 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { if (*dst == NULL) { return terrno; } - (void)idxInt2str(*(int16_t*)src, *dst, -1); + TAOS_UNUSED(idxInt2str(*(int16_t*)src, *dst, -1)); tlen = strlen(*dst); break; case TSDB_DATA_TYPE_USMALLINT: *dst = taosMemoryCalloc(1, bufSize + 1); - (void)idxInt2str(*(uint16_t*)src, *dst, -1); + TAOS_UNUSED(idxInt2str(*(uint16_t*)src, *dst, -1)); tlen = strlen(*dst); break; case TSDB_DATA_TYPE_INT: @@ -387,7 +387,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { if (*dst == NULL) { return terrno; } - (void)idxInt2str(*(int32_t*)src, *dst, -1); + TAOS_UNUSED(idxInt2str(*(int32_t*)src, *dst, -1)); tlen = strlen(*dst); break; case TSDB_DATA_TYPE_UINT: @@ -395,7 +395,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { if (*dst == NULL) { return terrno; } - (void)idxInt2str(*(uint32_t*)src, *dst, 1); + TAOS_UNUSED(idxInt2str(*(uint32_t*)src, *dst, 1)); tlen = strlen(*dst); break; case TSDB_DATA_TYPE_BIGINT: @@ -411,7 +411,7 @@ int32_t idxConvertDataToStr(void* src, int8_t type, void** dst) { if (*dst == NULL) { return terrno; } - (void)idxInt2str(*(uint64_t*)src, *dst, 1); + TAOS_UNUSED(idxInt2str(*(uint64_t*)src, *dst, 1)); tlen = strlen(*dst); break; case TSDB_DATA_TYPE_FLOAT: diff --git a/source/libs/index/src/indexFilter.c b/source/libs/index/src/indexFilter.c index fa59fe23fe..e209cf24ed 100644 --- a/source/libs/index/src/indexFilter.c +++ b/source/libs/index/src/indexFilter.c @@ -1057,7 +1057,7 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) { pDst->status = res->status; sifFreeParam(res); - (void)taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES); + TAOS_UNUSED(taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES)); } sifFreeRes(ctx.pRes); return code; @@ -1089,7 +1089,7 @@ static int32_t sifGetFltHint(SNode *pNode, SIdxFltStatus *status, SMetaDataFilte } *status = res->status; sifFreeParam(res); - (void)taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES); + TAOS_UNUSED(taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES)); void *iter = taosHashIterate(ctx.pRes, NULL); while (iter != NULL) { diff --git a/source/libs/index/src/indexFst.c b/source/libs/index/src/indexFst.c index aa617c2de2..e87126b930 100644 --- a/source/libs/index/src/indexFst.c +++ b/source/libs/index/src/indexFst.c @@ -219,9 +219,9 @@ void fstStateCompileForOneTransNext(IdxFstFile* w, CompiledAddr addr, uint8_t in uint8_t v = fstStateCommInput(&s, &null); if (null) { // w->write_all(&[inp]) - (void)idxFileWrite(w, &inp, 1); + TAOS_UNUSED(idxFileWrite(w, &inp, 1)); } - (void)idxFileWrite(w, &(s.val), 1); + TAOS_UNUSED(idxFileWrite(w, &(s.val), 1)); // w->write_all(&[s.val]) return; } @@ -233,7 +233,7 @@ void fstStateCompileForOneTrans(IdxFstFile* w, CompiledAddr addr, FstTransition* FST_SET_OUTPUT_PACK_SIZE(packSizes, outPackSize); FST_SET_TRANSITION_PACK_SIZE(packSizes, transPackSize); - (void)idxFileWrite(w, (char*)&packSizes, sizeof(packSizes)); + TAOS_UNUSED(idxFileWrite(w, (char*)&packSizes, sizeof(packSizes))); FstState st = fstStateCreate(OneTrans); @@ -242,9 +242,9 @@ void fstStateCompileForOneTrans(IdxFstFile* w, CompiledAddr addr, FstTransition* bool null = false; uint8_t inp = fstStateCommInput(&st, &null); if (null == true) { - (void)idxFileWrite(w, (char*)&trn->inp, sizeof(trn->inp)); + TAOS_UNUSED(idxFileWrite(w, (char*)&trn->inp, sizeof(trn->inp))); } - (void)idxFileWrite(w, (char*)(&(st.val)), sizeof(st.val)); + TAOS_UNUSED(idxFileWrite(w, (char*)(&(st.val)), sizeof(st.val))); return; } void fstStateCompileForAnyTrans(IdxFstFile* w, CompiledAddr addr, FstBuilderNode* node) { @@ -290,7 +290,7 @@ void fstStateCompileForAnyTrans(IdxFstFile* w, CompiledAddr addr, FstBuilderNode } for (int32_t i = sz - 1; i >= 0; i--) { FstTransition* t = taosArrayGet(node->trans, i); - (void)idxFileWrite(w, (char*)&t->inp, 1); + TAOS_UNUSED(idxFileWrite(w, (char*)&t->inp, 1)); } if (sz > TRANS_INDEX_THRESHOLD) { // A value of 255 indicates that no transition exists for the byte at that idx @@ -300,24 +300,24 @@ void fstStateCompileForAnyTrans(IdxFstFile* w, CompiledAddr addr, FstBuilderNode FstTransition* t = taosArrayGet(node->trans, i); index[t->inp] = i; } - (void)idxFileWrite(w, (char*)index, 256); + TAOS_UNUSED(idxFileWrite(w, (char*)index, 256)); taosMemoryFree(index); } - (void)idxFileWrite(w, (char*)&packSizes, 1); + TAOS_UNUSED(idxFileWrite(w, (char*)&packSizes, 1)); bool null = false; - (void)fstStateStateNtrans(&st, &null); + TAOS_UNUSED(fstStateStateNtrans(&st, &null)); if (null == true) { // 256 can't be represented in a u8, so we abuse the fact that // the # of transitions can never be 1 here, since 1 is always // encoded in the state byte. uint8_t v = 1; if (sz == 256) { - (void)idxFileWrite(w, (char*)&v, 1); + TAOS_UNUSED(idxFileWrite(w, (char*)&v, 1)); } else { - (void)idxFileWrite(w, (char*)&sz, 1); + TAOS_UNUSED(idxFileWrite(w, (char*)&sz, 1)); } } - (void)idxFileWrite(w, (char*)(&(st.val)), 1); + TAOS_UNUSED(idxFileWrite(w, (char*)(&(st.val)), 1)); return; } @@ -343,7 +343,7 @@ uint8_t fstStateCommInput(FstState* s, bool* null) { uint64_t fstStateInputLen(FstState* s) { bool null = false; - (void)fstStateCommInput(s, &null); + TAOS_UNUSED(fstStateCommInput(s, &null)); return null ? 1 : 0; } @@ -479,7 +479,7 @@ uint64_t fstStateTransIndexSize(FstState* s, uint64_t version, uint64_t nTrans) } uint64_t fstStateNtransLen(FstState* s) { bool null = false; - (void)fstStateStateNtrans(s, &null); + TAOS_UNUSED(fstStateStateNtrans(s, &null)); return null == true ? 1 : 0; } uint64_t fstStateNtrans(FstState* s, FstSlice* slice) { @@ -651,11 +651,11 @@ bool fstNodeGetTransitionAddrAt(FstNode* node, uint64_t i, CompiledAddr* res) { bool s = true; FstState* st = &node->state; if (st->state == OneTransNext) { - (void)fstStateTransAddr(st, node); + TAOS_UNUSED(fstStateTransAddr(st, node)); } else if (st->state == OneTrans) { - (void)fstStateTransAddr(st, node); + TAOS_UNUSED(fstStateTransAddr(st, node)); } else if (st->state == AnyTrans) { - (void)fstStateTransAddrForAnyTrans(st, node, i); + TAOS_UNUSED(fstStateTransAddrForAnyTrans(st, node, i)); } else if (FST_STATE_EMPTY_FINAL(node)) { s = false; } else { @@ -730,13 +730,13 @@ FstBuilder* fstBuilderCreate(void* w, FstType ty) { char buf64[8] = {0}; void* pBuf64 = buf64; - (void)taosEncodeFixedU64(&pBuf64, VERSION); - (void)idxFileWrite(b->wrt, buf64, sizeof(buf64)); + TAOS_UNUSED(taosEncodeFixedU64(&pBuf64, VERSION)); + TAOS_UNUSED(idxFileWrite(b->wrt, buf64, sizeof(buf64))); pBuf64 = buf64; memset(buf64, 0, sizeof(buf64)); - (void)taosEncodeFixedU64(&pBuf64, ty); - (void)idxFileWrite(b->wrt, buf64, sizeof(buf64)); + TAOS_UNUSED(taosEncodeFixedU64(&pBuf64, ty)); + TAOS_UNUSED(idxFileWrite(b->wrt, buf64, sizeof(buf64))); return b; } @@ -835,7 +835,7 @@ CompiledAddr fstBuilderCompile(FstBuilder* b, FstBuilderNode* bn) { } CompiledAddr startAddr = (CompiledAddr)(FST_WRITER_COUNT(b->wrt)); - (void)fstBuilderNodeCompileTo(bn, b->wrt, b->lastAddr, startAddr); + TAOS_UNUSED(fstBuilderNodeCompileTo(bn, b->wrt, b->lastAddr, startAddr)); b->lastAddr = (CompiledAddr)(FST_WRITER_COUNT(b->wrt) - 1); if (entry->state == NOTFOUND) { FST_REGISTRY_CELL_INSERT(entry->cell, b->lastAddr); @@ -854,23 +854,23 @@ void* fstBuilderInsertInner(FstBuilder* b) { char buf64[8] = {0}; void* pBuf64 = buf64; - (void)taosEncodeFixedU64(&pBuf64, b->len); - (void)idxFileWrite(b->wrt, buf64, sizeof(buf64)); + TAOS_UNUSED(taosEncodeFixedU64(&pBuf64, b->len)); + TAOS_UNUSED(idxFileWrite(b->wrt, buf64, sizeof(buf64))); pBuf64 = buf64; - (void)taosEncodeFixedU64(&pBuf64, rootAddr); - (void)idxFileWrite(b->wrt, buf64, sizeof(buf64)); + TAOS_UNUSED(taosEncodeFixedU64(&pBuf64, rootAddr)); + TAOS_UNUSED(idxFileWrite(b->wrt, buf64, sizeof(buf64))); char buf32[4] = {0}; void* pBuf32 = buf32; uint32_t sum = idxFileMaskedCheckSum(b->wrt); - (void)taosEncodeFixedU32(&pBuf32, sum); - (void)idxFileWrite(b->wrt, buf32, sizeof(buf32)); + TAOS_UNUSED(taosEncodeFixedU32(&pBuf32, sum)); + TAOS_UNUSED(idxFileWrite(b->wrt, buf32, sizeof(buf32))); - (void)idxFileFlush(b->wrt); + TAOS_UNUSED(idxFileFlush(b->wrt)); return b->wrt; } -void fstBuilderFinish(FstBuilder* b) { (void)fstBuilderInsertInner(b); } +void fstBuilderFinish(FstBuilder* b) { TAOS_UNUSED(fstBuilderInsertInner(b)); } FstSlice fstNodeAsSlice(FstNode* node) { FstSlice* slice = &node->data; @@ -930,19 +930,19 @@ Fst* fstCreate(FstSlice* slice) { uint64_t skip = 0; uint64_t version; - (void)taosDecodeFixedU64(buf, &version); + TAOS_UNUSED(taosDecodeFixedU64(buf, &version)); skip += sizeof(version); if (version == 0 || version > VERSION) { return NULL; } uint64_t type; - (void)taosDecodeFixedU64(buf + skip, &type); + TAOS_UNUSED(taosDecodeFixedU64(buf + skip, &type)); skip += sizeof(type); uint32_t checkSum = 0; len -= sizeof(checkSum); - (void)taosDecodeFixedU32(buf + len, &checkSum); + TAOS_UNUSED(taosDecodeFixedU32(buf + len, &checkSum)); if (taosCheckChecksum(buf, len, checkSum)) { indexError("index file is corrupted"); // verify fst @@ -950,11 +950,11 @@ Fst* fstCreate(FstSlice* slice) { } CompiledAddr rootAddr; len -= sizeof(rootAddr); - (void)taosDecodeFixedU64(buf + len, &rootAddr); + TAOS_UNUSED(taosDecodeFixedU64(buf + len, &rootAddr)); uint64_t fstLen; len -= sizeof(fstLen); - (void)taosDecodeFixedU64(buf + len, &fstLen); + TAOS_UNUSED(taosDecodeFixedU64(buf + len, &fstLen)); // TODO(validate root addr) Fst* fst = (Fst*)taosMemoryCalloc(1, sizeof(Fst)); if (fst == NULL) { @@ -976,7 +976,7 @@ Fst* fstCreate(FstSlice* slice) { *s = fstSliceCopy(slice, 0, FST_SLICE_LEN(slice) - 1); fst->data = s; - (void)taosThreadMutexInit(&fst->mtx, NULL); + TAOS_UNUSED(taosThreadMutexInit(&fst->mtx, NULL)); return fst; FST_CREAT_FAILED: @@ -990,7 +990,7 @@ void fstDestroy(Fst* fst) { taosMemoryFree(fst->meta); fstSliceDestroy(fst->data); taosMemoryFree(fst->data); - (void)taosThreadMutexDestroy(&fst->mtx); + TAOS_UNUSED(taosThreadMutexDestroy(&fst->mtx)); } taosMemoryFree(fst); } @@ -1018,7 +1018,7 @@ bool fstGet(Fst* fst, FstSlice* b, Output* out) { } FstTransition trn; - (void)fstNodeGetTransitionAt(root, res, &trn); + TAOS_UNUSED(fstNodeGetTransitionAt(root, res, &trn)); tOut += trn.out; root = fstGetNode(fst, trn.addr); if (taosArrayPush(nodes, &root) == NULL) { @@ -1145,7 +1145,7 @@ FStmSt* stmStCreate(Fst* fst, FAutoCtx* automation, FstBoundWithData* min, FstBo sws->stack = (SArray*)taosArrayInit(256, sizeof(FstStreamState)); sws->endAt = max; - (void)stmStSeekMin(sws, min); + TAOS_UNUSED(stmStSeekMin(sws, min)); return sws; } @@ -1198,7 +1198,7 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) { uint64_t res = 0; if (fstNodeFindInput(node, b, &res)) { FstTransition trn; - (void)fstNodeGetTransitionAt(node, res, &trn); + TAOS_UNUSED(fstNodeGetTransitionAt(node, res, &trn)); void* preState = autState; autState = automFuncs[aut->type].accept(aut, preState, b); if (taosArrayPush(sws->inp, &b) == NULL) { @@ -1244,12 +1244,12 @@ bool stmStSeekMin(FStmSt* sws, FstBoundWithData* min) { FstStreamState* s = taosArrayGet(sws->stack, sz - 1); if (inclusize) { s->trans -= 1; - (void)taosArrayPop(sws->inp); + TAOS_UNUSED(taosArrayPop(sws->inp)); } else { FstNode* n = s->node; uint64_t trans = s->trans; FstTransition trn; - (void)fstNodeGetTransitionAt(n, trans - 1, &trn); + TAOS_UNUSED(fstNodeGetTransitionAt(n, trans - 1, &trn)); FstStreamState s = { .node = fstGetNode(sws->fst, trn.addr), .trans = 0, .out = {.null = false, .out = out}, .autState = autState}; if (taosArrayPush(sws->stack, &s) == NULL) { @@ -1283,13 +1283,13 @@ FStmStRslt* stmStNextWith(FStmSt* sws, streamCallback__fn callback) { FstStreamState* p = (FstStreamState*)taosArrayPop(sws->stack); if (p->trans >= FST_NODE_LEN(p->node) || !automFuncs[aut->type].canMatch(aut, p->autState)) { if (FST_NODE_ADDR(p->node) != fstGetRootAddr(sws->fst)) { - (void)taosArrayPop(sws->inp); + TAOS_UNUSED(taosArrayPop(sws->inp)); } fstStreamStateDestroy(p); continue; } FstTransition trn; - (void)fstNodeGetTransitionAt(p->node, p->trans, &trn); + TAOS_UNUSED(fstNodeGetTransitionAt(p->node, p->trans, &trn)); Output out = p->out.out + trn.out; void* nextState = automFuncs[aut->type].accept(aut, p->autState, trn.inp); diff --git a/source/libs/index/src/indexFstDfa.c b/source/libs/index/src/indexFstDfa.c index c95847525f..81352414f5 100644 --- a/source/libs/index/src/indexFstDfa.c +++ b/source/libs/index/src/indexFstDfa.c @@ -132,7 +132,7 @@ bool dfaBuilderRunState(FstDfaBuilder *builder, FstSparseSet *cur, FstSparseSet bool succ = sparSetAdd(cur, ip, NULL); if (succ == false) return false; } - (void)dfaRun(builder->dfa, cur, next, byte); + TAOS_UNUSED(dfaRun(builder->dfa, cur, next, byte)); t = taosArrayGet(builder->dfa->states, state); diff --git a/source/libs/index/src/indexFstFile.c b/source/libs/index/src/indexFstFile.c index 5c6a39d13c..efe890aa3a 100644 --- a/source/libs/index/src/indexFstFile.c +++ b/source/libs/index/src/indexFstFile.c @@ -30,7 +30,9 @@ typedef struct { } SDataBlock; static void deleteDataBlockFromLRU(const void* key, size_t keyLen, void* value, void* ud) { - (void)ud; + TAOS_UNUSED(ud); + TAOS_UNUSED(key); + TAOS_UNUSED(keyLen); taosMemoryFree(value); } @@ -38,7 +40,7 @@ static FORCE_INLINE void idxGenLRUKey(char* buf, const char* path, int32_t block char* p = buf; SERIALIZE_STR_VAR_TO_BUF(p, path, strlen(path)); SERIALIZE_VAR_TO_BUF(p, '_', char); - (void)idxInt2str(blockId, p, 0); + TAOS_UNUSED(idxInt2str(blockId, p, 0)); return; } static FORCE_INLINE int idxFileCtxDoWrite(IFileCtx* ctx, uint8_t* buf, int len) { @@ -48,7 +50,7 @@ static FORCE_INLINE int idxFileCtxDoWrite(IFileCtx* ctx, uint8_t* buf, int len) if (len + ctx->file.wBufOffset >= cap) { int32_t nw = cap - ctx->file.wBufOffset; memcpy(ctx->file.wBuf + ctx->file.wBufOffset, buf, nw); - (void)taosWriteFile(ctx->file.pFile, ctx->file.wBuf, cap); + TAOS_UNUSED(taosWriteFile(ctx->file.pFile, ctx->file.wBuf, cap)); memset(ctx->file.wBuf, 0, cap); ctx->file.wBufOffset = 0; @@ -58,7 +60,7 @@ static FORCE_INLINE int idxFileCtxDoWrite(IFileCtx* ctx, uint8_t* buf, int len) nw = (len / cap) * cap; if (nw != 0) { - (void)taosWriteFile(ctx->file.pFile, buf, nw); + TAOS_UNUSED(taosWriteFile(ctx->file.pFile, buf, nw)); } len -= nw; @@ -115,7 +117,7 @@ static int idxFileCtxDoReadFrom(IFileCtx* ctx, uint8_t* buf, int len, int32_t of SDataBlock* blk = taosLRUCacheValue(ctx->lru, h); nread = TMIN(blkLeft, len); memcpy(buf + total, blk->buf + blkOffset, nread); - (void)taosLRUCacheRelease(ctx->lru, h, false); + TAOS_UNUSED(taosLRUCacheRelease(ctx->lru, h, false)); } else { int32_t left = ctx->file.size - offset; if (left < kBlockSize) { @@ -166,7 +168,7 @@ static FORCE_INLINE int idxFileCtxGetSize(IFileCtx* ctx) { return ctx->offset; } else { int64_t file_size = 0; - (void)taosStatFile(ctx->file.buf, &file_size, NULL, NULL); + TAOS_UNUSED(taosStatFile(ctx->file.buf, &file_size, NULL, NULL)); return (int)file_size; } } @@ -254,16 +256,16 @@ void idxFileCtxDestroy(IFileCtx* ctx, bool remove) { int32_t nw = taosWriteFile(ctx->file.pFile, ctx->file.wBuf, ctx->file.wBufOffset); ctx->file.wBufOffset = 0; } - (void)(ctx->flush(ctx)); + TAOS_UNUSED(ctx->flush(ctx)); taosMemoryFreeClear(ctx->file.wBuf); - (void)taosCloseFile(&ctx->file.pFile); + TAOS_UNUSED(taosCloseFile(&ctx->file.pFile)); if (ctx->file.readOnly) { #ifdef USE_MMAP munmap(ctx->file.ptr, ctx->file.size); #endif } if (remove) { - (void)unlink(ctx->file.buf); + TAOS_UNUSED(unlink(ctx->file.buf)); } } taosMemoryFree(ctx); @@ -279,7 +281,7 @@ IdxFstFile* idxFileCreate(void* wrt) { return cw; } void idxFileDestroy(IdxFstFile* cw) { - (void)idxFileFlush(cw); + TAOS_UNUSED(idxFileFlush(cw)); taosMemoryFree(cw); } @@ -317,7 +319,7 @@ uint32_t idxFileMaskedCheckSum(IdxFstFile* write) { int idxFileFlush(IdxFstFile* write) { IFileCtx* ctx = write->wrt; - (void)(ctx->flush(ctx)); + TAOS_UNUSED(ctx->flush(ctx)); return 1; } @@ -327,7 +329,7 @@ void idxFilePackUintIn(IdxFstFile* writer, uint64_t n, uint8_t nBytes) { buf[i] = (uint8_t)n; n = n >> 8; } - (void)idxFileWrite(writer, buf, nBytes); + TAOS_UNUSED(idxFileWrite(writer, buf, nBytes)); taosMemoryFree(buf); return; } diff --git a/source/libs/index/src/indexFstRegister.c b/source/libs/index/src/indexFstRegister.c index cc069c5d0f..ce34bb50d0 100644 --- a/source/libs/index/src/indexFstRegister.c +++ b/source/libs/index/src/indexFstRegister.c @@ -128,7 +128,7 @@ FstRegistryEntry* fstRegistryGetEntry(FstRegistry* registry, FstBuilderNode* bNo entry->addr = cell->addr; return entry; } else { - (void)fstBuilderNodeCloneFrom(cell->node, bNode); + TAOS_UNUSED(fstBuilderNodeCloneFrom(cell->node, bNode)); entry->state = NOTFOUND; entry->cell = cell; // copy or not } @@ -148,7 +148,7 @@ FstRegistryEntry* fstRegistryGetEntry(FstRegistry* registry, FstBuilderNode* bNo return entry; } // clone from bNode, refactor later - (void)fstBuilderNodeCloneFrom(cell2->node, bNode); + TAOS_UNUSED(fstBuilderNodeCloneFrom(cell2->node, bNode)); fstRegistryCellSwap(registry->table, start, start + 1); FstRegistryCell* cCell = taosArrayGet(registry->table, start); @@ -169,7 +169,7 @@ FstRegistryEntry* fstRegistryGetEntry(FstRegistry* registry, FstBuilderNode* bNo uint64_t last = end - 1; FstRegistryCell* cell = (FstRegistryCell*)taosArrayGet(registry->table, last); // clone from bNode, refactor later - (void)fstBuilderNodeCloneFrom(cell->node, bNode); + TAOS_UNUSED(fstBuilderNodeCloneFrom(cell->node, bNode)); fstRegistryCellPromote(registry->table, last, start); FstRegistryCell* cCell = taosArrayGet(registry->table, start); diff --git a/source/libs/index/src/indexFstUtil.c b/source/libs/index/src/indexFstUtil.c index 92cece3890..f0df2f7124 100644 --- a/source/libs/index/src/indexFstUtil.c +++ b/source/libs/index/src/indexFstUtil.c @@ -91,7 +91,7 @@ FstSlice fstSliceCreate(uint8_t* data, uint64_t len) { // just shallow copy FstSlice fstSliceCopy(FstSlice* s, int32_t start, int32_t end) { FstString* str = s->str; - (void)atomic_add_fetch_32(&str->ref, 1); + TAOS_UNUSED(atomic_add_fetch_32(&str->ref, 1)); FstSlice t = {.str = str, .start = start + s->start, .end = end + s->start}; return t; diff --git a/source/libs/index/src/indexTfile.c b/source/libs/index/src/indexTfile.c index eb00cc7990..37a373cd5c 100644 --- a/source/libs/index/src/indexTfile.c +++ b/source/libs/index/src/indexTfile.c @@ -374,7 +374,7 @@ static int32_t tfSearchCompareFunc(void* reader, SIndexTerm* tem, SIdxTRslt* tr, goto _return; } if (MATCH == cond) { - (void)tfileReaderLoadTableIds((TFileReader*)reader, rt->out.out, tr->total); + TAOS_UNUSED(tfileReaderLoadTableIds((TFileReader*)reader, rt->out.out, tr->total)); } else if (CONTINUE == cond) { } else if (BREAK == cond) { swsResultDestroy(rt); @@ -528,7 +528,7 @@ static int32_t tfSearchCompareFunc_JSON(void* reader, SIndexTerm* tem, SIdxTRslt } } if (MATCH == cond) { - (void)tfileReaderLoadTableIds((TFileReader*)reader, rt->out.out, tr->total); + TAOS_UNUSED(tfileReaderLoadTableIds((TFileReader*)reader, rt->out.out, tr->total)); } else if (CONTINUE == cond) { } else if (BREAK == cond) { swsResultDestroy(rt); @@ -639,7 +639,7 @@ int32_t tfileWriterPut(TFileWriter* tw, void* data, bool order) { if (fn == NULL) { return terrno; } - (void)taosArraySortPWithExt((SArray*)(data), tfileValueCompare, &fn); + TAOS_UNUSED(taosArraySortPWithExt((SArray*)(data), tfileValueCompare, &fn)); } int32_t sz = taosArrayGetSize((SArray*)data); @@ -654,7 +654,7 @@ int32_t tfileWriterPut(TFileWriter* tw, void* data, bool order) { if (tbsz == 0) continue; fstOffset += TF_TABLE_TATOAL_SIZE(tbsz); } - (void)tfileWriteFstOffset(tw, fstOffset); + TAOS_UNUSED(tfileWriteFstOffset(tw, fstOffset)); int32_t cap = 4 * 1024; char* buf = taosMemoryCalloc(1, cap); @@ -682,7 +682,7 @@ int32_t tfileWriterPut(TFileWriter* tw, void* data, bool order) { char* p = buf; tfileSerialTableIdsToBuf(p, v->tableId); - (void)(tw->ctx->write(tw->ctx, buf, ttsz)); + TAOS_UNUSED((tw->ctx->write(tw->ctx, buf, ttsz))); v->offset = tw->offset; tw->offset += ttsz; memset(buf, 0, cap); @@ -710,7 +710,7 @@ int32_t tfileWriterPut(TFileWriter* tw, void* data, bool order) { } } fstBuilderDestroy(tw->fb); - (void)tfileWriteFooter(tw); + TAOS_UNUSED(tfileWriteFooter(tw)); return 0; } void tfileWriterClose(TFileWriter* tw) { @@ -739,7 +739,7 @@ IndexTFile* idxTFileCreate(SIndex* idx, const char* path) { tfileCacheDestroy(cache); return NULL; } - (void)taosThreadMutexInit(&tfile->mtx, NULL); + TAOS_UNUSED(taosThreadMutexInit(&tfile->mtx, NULL)); tfile->cache = cache; return tfile; } @@ -747,7 +747,7 @@ void idxTFileDestroy(IndexTFile* tfile) { if (tfile == NULL) { return; } - (void)taosThreadMutexDestroy(&tfile->mtx); + TAOS_UNUSED(taosThreadMutexDestroy(&tfile->mtx)); tfileCacheDestroy(tfile->cache); taosMemoryFree(tfile); } @@ -764,9 +764,9 @@ int idxTFileSearch(void* tfile, SIndexTermQuery* query, SIdxTRslt* result) { SIndexTerm* term = query->term; ICacheKey key = {.suid = term->suid, .colType = term->colType, .colName = term->colName, .nColName = term->nColName}; - (void)taosThreadMutexLock(&pTfile->mtx); + TAOS_UNUSED(taosThreadMutexLock(&pTfile->mtx)); TFileReader* reader = tfileCacheGet(pTfile->cache, &key); - (void)taosThreadMutexUnlock(&pTfile->mtx); + TAOS_UNUSED(taosThreadMutexUnlock(&pTfile->mtx)); if (reader == NULL) { return 0; } @@ -870,9 +870,9 @@ TFileReader* tfileGetReaderByCol(IndexTFile* tf, uint64_t suid, char* colName) { TFileReader* rd = NULL; ICacheKey key = {.suid = suid, .colType = TSDB_DATA_TYPE_BINARY, .colName = colName, .nColName = strlen(colName)}; - (void)taosThreadMutexLock(&tf->mtx); + TAOS_UNUSED(taosThreadMutexLock(&tf->mtx)); rd = tfileCacheGet(tf->cache, &key); - (void)taosThreadMutexUnlock(&tf->mtx); + TAOS_UNUSED(taosThreadMutexUnlock(&tf->mtx)); return rd; } @@ -978,7 +978,7 @@ static int tfileWriteData(TFileWriter* write, TFileValue* tval) { static int tfileWriteFooter(TFileWriter* write) { char buf[sizeof(FILE_MAGIC_NUMBER) + 1] = {0}; void* pBuf = (void*)buf; - (void)taosEncodeFixedU64((void**)(void*)&pBuf, FILE_MAGIC_NUMBER); + TAOS_UNUSED(taosEncodeFixedU64((void**)(void*)&pBuf, FILE_MAGIC_NUMBER)); int nwrite = write->ctx->write(write->ctx, (uint8_t*)buf, (int32_t)strlen(buf)); indexInfo("tfile write footer size: %d", write->ctx->size(write->ctx)); @@ -1088,7 +1088,7 @@ static int tfileReaderVerify(TFileReader* reader) { return TSDB_CODE_INDEX_INVALID_FILE; } - (void)taosDecodeFixedU64(buf, &tMagicNumber); + TAOS_UNUSED(taosDecodeFixedU64(buf, &tMagicNumber)); return tMagicNumber == FILE_MAGIC_NUMBER ? 0 : TSDB_CODE_INDEX_INVALID_FILE; } @@ -1143,15 +1143,15 @@ static int32_t tfileGetFileList(const char* path, SArray** ppResult) { TAOS_CHECK_GOTO(TSDB_CODE_OUT_OF_MEMORY, NULL, _exception); } } - (void)taosCloseDir(&pDir); + TAOS_UNUSED(taosCloseDir(&pDir)); taosArraySort(files, tfileCompare); - (void)tfileRmExpireFile(files); + TAOS_UNUSED(tfileRmExpireFile(files)); *ppResult = files; return 0; _exception: - (void)taosCloseDir(&pDir); + TAOS_UNUSED(taosCloseDir(&pDir)); if (files != NULL) { taosArrayDestroyEx(files, tfileDestroyFileName); taosArrayDestroy(files); @@ -1181,12 +1181,12 @@ static int tfileParseFileName(const char* filename, uint64_t* suid, char* col, i } // tfile name suid-colId-version.tindex static void tfileGenFileName(char* filename, uint64_t suid, const char* col, int64_t version) { - (void)sprintf(filename, "%" PRIu64 "-%s-%" PRId64 ".tindex", suid, col, version); + TAOS_UNUSED(sprintf(filename, "%" PRIu64 "-%s-%" PRId64 ".tindex", suid, col, version)); return; } static void FORCE_INLINE tfileGenFileFullName(char* fullname, const char* path, uint64_t suid, const char* col, int64_t version) { char filename[128] = {0}; tfileGenFileName(filename, suid, col, version); - (void)sprintf(fullname, "%s/%s", path, filename); + TAOS_UNUSED(sprintf(fullname, "%s/%s", path, filename)); } From 6ba0c720dae8f9679d2ddcc78ffbe13c02560bfd Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Fri, 20 Sep 2024 17:45:27 +0800 Subject: [PATCH 2/2] fix invalid read --- source/client/src/clientImpl.c | 14 +++++++------- source/dnode/mgmt/mgmt_dnode/src/dmHandle.c | 5 ++++- source/dnode/mnode/impl/src/mndMain.c | 14 ++++++++++---- source/libs/sync/src/syncMain.c | 2 +- tools/shell/src/shellNettest.c | 2 +- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 1c0be6b3ac..18cdd58639 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -37,7 +37,6 @@ void setQueryRequest(int64_t rId) { pReq->isQuery = true; (void)releaseRequest(rId); } - } static bool stringLengthCheck(const char* str, size_t maxsize) { @@ -2245,7 +2244,7 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int } else if (tTagIsJson(data)) { char* jsonString = NULL; parseTagDatatoJson(data, &jsonString); - if(jsonString == NULL) { + if (jsonString == NULL) { tscError("doConvertJson error: parseTagDatatoJson failed"); return terrno; } @@ -2517,10 +2516,10 @@ TSDB_SERVER_STATUS taos_check_server_status(const char* fqdn, int port, char* de void* clientRpc = NULL; SServerStatusRsp statusRsp = {0}; SEpSet epSet = {.inUse = 0, .numOfEps = 1}; - SRpcMsg rpcMsg = {.info.ahandle = (void*)0x9526, .msgType = TDMT_DND_SERVER_STATUS}; - SRpcMsg rpcRsp = {0}; - SRpcInit rpcInit = {0}; - char pass[TSDB_PASSWORD_LEN + 1] = {0}; + SRpcMsg rpcMsg = {.info.ahandle = (void*)0x9527, .info.notFreeAhandle = 1, .msgType = TDMT_DND_SERVER_STATUS}; + SRpcMsg rpcRsp = {0}; + SRpcInit rpcInit = {0}; + char pass[TSDB_PASSWORD_LEN + 1] = {0}; rpcInit.label = "CHK"; rpcInit.numOfThreads = 1; @@ -3032,7 +3031,8 @@ void taosAsyncFetchImpl(SRequestObj* pRequest, __taos_async_fn_t fp, void* param void doRequestCallback(SRequestObj* pRequest, int32_t code) { pRequest->inCallback = true; int64_t this = pRequest->self; - if (tsQueryTbNotExistAsEmpty && TD_RES_QUERY(&pRequest->resType) && pRequest->isQuery && (code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_TDB_TABLE_NOT_EXIST)) { + if (tsQueryTbNotExistAsEmpty && TD_RES_QUERY(&pRequest->resType) && pRequest->isQuery && + (code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_TDB_TABLE_NOT_EXIST)) { code = TSDB_CODE_SUCCESS; pRequest->type = TSDB_SQL_RETRIEVE_EMPTY_RESULT; } diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c index ae12bf6c99..020a8077b2 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c @@ -69,6 +69,7 @@ static void dmMayShouldUpdateIpWhiteList(SDnodeMgmt *pMgmt, int64_t ver) { .contLen = contLen, .msgType = TDMT_MND_RETRIEVE_IP_WHITE, .info.ahandle = (void *)0x9527, + .info.notFreeAhandle = 1, .info.refId = 0, .info.noResp = 0, .info.handle = 0}; @@ -185,6 +186,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) { .contLen = contLen, .msgType = TDMT_MND_STATUS, .info.ahandle = (void *)0x9527, + .info.notFreeAhandle = 1, .info.refId = 0, .info.noResp = 0, .info.handle = 0}; @@ -234,6 +236,7 @@ void dmSendNotifyReq(SDnodeMgmt *pMgmt, SNotifyReq *pReq) { .contLen = contLen, .msgType = TDMT_MND_NOTIFY, .info.ahandle = (void *)0x9527, + .info.notFreeAhandle = 1, .info.refId = 0, .info.noResp = 1, .info.handle = 0}; @@ -483,7 +486,7 @@ int32_t dmProcessRetrieve(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) { } int32_t len = blockEncode(pBlock, pStart, numOfCols); - if(len < 0) { + if (len < 0) { dError("failed to retrieve data since %s", tstrerror(code)); blockDataDestroy(pBlock); rpcFreeCont(pRsp); diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index a0dd30f11a..6e1a745cfa 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -210,8 +210,11 @@ static void mndPullupGrant(SMnode *pMnode) { int32_t contLen = 0; void *pReq = mndBuildTimerMsg(&contLen); if (pReq != NULL) { - SRpcMsg rpcMsg = { - .msgType = TDMT_MND_GRANT_HB_TIMER, .pCont = pReq, .contLen = contLen, .info.ahandle = (void *)0x9527}; + SRpcMsg rpcMsg = {.msgType = TDMT_MND_GRANT_HB_TIMER, + .pCont = pReq, + .contLen = contLen, + .info.notFreeAhandle = 1, + .info.ahandle = (void *)0x9527}; // TODO check return value (void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); } @@ -222,8 +225,11 @@ static void mndIncreaseUpTime(SMnode *pMnode) { int32_t contLen = 0; void *pReq = mndBuildTimerMsg(&contLen); if (pReq != NULL) { - SRpcMsg rpcMsg = { - .msgType = TDMT_MND_UPTIME_TIMER, .pCont = pReq, .contLen = contLen, .info.ahandle = (void *)0x9528}; + SRpcMsg rpcMsg = {.msgType = TDMT_MND_UPTIME_TIMER, + .pCont = pReq, + .contLen = contLen, + .info.notFreeAhandle = 1, + .info.ahandle = (void *)0x9527}; // TODO check return value (void)tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 4dce54fc1a..e3b3f6b43d 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -403,7 +403,7 @@ int32_t syncSendTimeoutRsp(int64_t rid, int64_t seq) { TAOS_RETURN(code); } - SRpcMsg rpcMsg = {0}; + SRpcMsg rpcMsg = {0, .info.notFreeAhandle = 1}; int32_t ret = syncRespMgrGetAndDel(pNode->pSyncRespMgr, seq, &rpcMsg.info); rpcMsg.code = TSDB_CODE_SYN_TIMEOUT; diff --git a/tools/shell/src/shellNettest.c b/tools/shell/src/shellNettest.c index 9fe92212ca..2e5ec7bc24 100644 --- a/tools/shell/src/shellNettest.c +++ b/tools/shell/src/shellNettest.c @@ -61,7 +61,7 @@ static void shellWorkAsClient() { uint64_t startTime = taosGetTimestampUs(); for (int32_t i = 0; i < pArgs->pktNum; ++i) { - SRpcMsg rpcMsg = {.info.ahandle = (void *)0x9525, .msgType = TDMT_DND_NET_TEST}; + SRpcMsg rpcMsg = {.info.ahandle = (void *)0x9525, .info.notFreeAhandle = 1, .msgType = TDMT_DND_NET_TEST}; rpcMsg.pCont = rpcMallocCont(pArgs->pktLen); rpcMsg.contLen = pArgs->pktLen;