From 4401080328ad56532084169a69d3e64bbca98886 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 31 Aug 2022 18:06:17 +0800 Subject: [PATCH] enh: make cmake .. -DCMAKE_BUILD_TYPE=Release work --- source/dnode/mgmt/node_mgmt/src/dmTransport.c | 2 +- source/libs/executor/src/executil.c | 2 +- source/libs/executor/src/executorimpl.c | 4 ++-- source/libs/function/src/builtinsimpl.c | 1 + source/libs/function/src/tudf.c | 2 +- source/libs/function/src/udfd.c | 8 ++++---- source/libs/index/src/indexComm.c | 1 + source/libs/sync/src/syncIndexMgr.c | 3 +++ source/libs/transport/src/trans.c | 2 +- source/util/src/talgo.c | 1 + source/util/src/tcompare.c | 1 + source/util/src/tlog.c | 5 ++++- tests/test/c/sdbDump.c | 6 ++++++ tests/tsim/src/simExe.c | 3 +++ tools/shell/src/shellCommand.c | 3 +++ tools/shell/src/shellEngine.c | 5 ++++- 16 files changed, 37 insertions(+), 12 deletions(-) diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index a059db6b00..b91b82b72e 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -301,7 +301,7 @@ int32_t dmInitServer(SDnode *pDnode) { SDnodeTrans *pTrans = &pDnode->trans; SRpcInit rpcInit = {0}; - strncpy(rpcInit.localFqdn, tsLocalFqdn, strlen(tsLocalFqdn)); + strncpy(rpcInit.localFqdn, tsLocalFqdn, TSDB_FQDN_LEN); rpcInit.localPort = tsServerPort; rpcInit.label = "DND-S"; rpcInit.numOfThreads = tsNumOfRpcThreads; diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 80c1494f8d..70180d6dc0 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -1190,7 +1190,7 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, fmGetFuncExecFuncs(pCtx->functionId, &pCtx->fpSet); } else { char* udfName = pExpr->pExpr->_function.pFunctNode->functionName; - strncpy(pCtx->udfName, udfName, strlen(udfName)); + strncpy(pCtx->udfName, udfName, TSDB_FUNC_NAME_LEN); fmGetUdafExecFuncs(pCtx->functionId, &pCtx->fpSet); } pCtx->fpSet.getEnv(pExpr->pExpr->_function.pFunctNode, &env); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index f3ff13ef85..b53d35a1a1 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -3982,8 +3982,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo STableKeyInfo* pKeyInfo = taosArrayGet(pTableListInfo->pTableList, i); qDebug("creating stream task: add table %" PRId64, pKeyInfo->uid); } - } #endif + } pTaskInfo->schemaInfo.qsw = extractQueriedColumnSchema(&pTableScanNode->scan); pOperator = createStreamScanOperatorInfo(pHandle, pTableScanNode, pTagCond, pTaskInfo); @@ -4449,7 +4449,7 @@ _complete: return code; } -static void doDestroyTableList(STableListInfo* pTableqinfoList) { +void doDestroyTableList(STableListInfo* pTableqinfoList) { taosArrayDestroy(pTableqinfoList->pTableList); taosHashCleanup(pTableqinfoList->map); if (pTableqinfoList->needSortTableByGroupId) { diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index b71d06231e..84d3a04807 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -1160,6 +1160,7 @@ static int32_t findRowIndex(int32_t start, int32_t num, SColumnInfoData* pCol, c } ASSERT(0); + return 0; } int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c index d5a3e91eea..5de9c52cc1 100644 --- a/source/libs/function/src/tudf.c +++ b/source/libs/function/src/tudf.c @@ -81,7 +81,7 @@ static int32_t udfSpawnUdfd(SUdfdData* pData) { taosDirName(path); #endif } else { - strncpy(path, tsProcPath, strlen(tsProcPath)); + strncpy(path, tsProcPath, PATH_MAX); taosDirName(path); } #ifdef WINDOWS diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index 5b27e030b9..a45e4585e8 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -453,7 +453,7 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { goto _return; } taosCloseFile(&file); - strncpy(udf->path, path, strlen(path)); + strncpy(udf->path, path, PATH_MAX); tFreeSFuncInfo(pFuncInfo); taosArrayDestroy(retrieveRsp.pFuncInfos); msgInfo->code = 0; @@ -566,17 +566,17 @@ int32_t udfdLoadUdf(char *udfName, SUdf *udf) { uv_dlsym(&udf->lib, processFuncName, (void **)(&udf->aggProcFunc)); char startFuncName[TSDB_FUNC_NAME_LEN + 6] = {0}; char *startSuffix = "_start"; - strncpy(startFuncName, processFuncName, strlen(processFuncName)); + strncpy(startFuncName, processFuncName, sizeof(startFuncName)); strncat(startFuncName, startSuffix, strlen(startSuffix)); uv_dlsym(&udf->lib, startFuncName, (void **)(&udf->aggStartFunc)); char finishFuncName[TSDB_FUNC_NAME_LEN + 7] = {0}; char *finishSuffix = "_finish"; - strncpy(finishFuncName, processFuncName, strlen(processFuncName)); + strncpy(finishFuncName, processFuncName, sizeof(finishFuncName)); strncat(finishFuncName, finishSuffix, strlen(finishSuffix)); uv_dlsym(&udf->lib, finishFuncName, (void **)(&udf->aggFinishFunc)); char mergeFuncName[TSDB_FUNC_NAME_LEN + 6] = {0}; char *mergeSuffix = "_merge"; - strncpy(finishFuncName, processFuncName, strlen(processFuncName)); + strncpy(finishFuncName, processFuncName, sizeof(finishFuncName)); strncat(finishFuncName, mergeSuffix, strlen(mergeSuffix)); uv_dlsym(&udf->lib, finishFuncName, (void **)(&udf->aggMergeFunc)); } diff --git a/source/libs/index/src/indexComm.c b/source/libs/index/src/indexComm.c index 4f33d98f9e..cd52d122f7 100644 --- a/source/libs/index/src/indexComm.c +++ b/source/libs/index/src/indexComm.c @@ -171,6 +171,7 @@ TExeCond tCompare(__compar_fn_t func, int8_t cmptype, void* a, void* b, int8_t d return tDoCompare(func, cmptype, &va, &vb); } assert(0); + return BREAK; #endif } TExeCond tDoCompare(__compar_fn_t func, int8_t comparType, void* a, void* b) { diff --git a/source/libs/sync/src/syncIndexMgr.c b/source/libs/sync/src/syncIndexMgr.c index 07c4fa8429..3bda9bcd51 100644 --- a/source/libs/sync/src/syncIndexMgr.c +++ b/source/libs/sync/src/syncIndexMgr.c @@ -163,6 +163,7 @@ int64_t syncIndexMgrGetStartTime(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pR } } ASSERT(0); + return -1; } void syncIndexMgrSetRecvTime(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId, int64_t recvTime) { @@ -190,6 +191,7 @@ int64_t syncIndexMgrGetRecvTime(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRa } } ASSERT(0); + return -1; } // for debug ------------------- @@ -245,4 +247,5 @@ SyncTerm syncIndexMgrGetTerm(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftI } } ASSERT(0); + return -1; } \ No newline at end of file diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c index 0a0dcef378..9e0a8f2a10 100644 --- a/source/libs/transport/src/trans.c +++ b/source/libs/transport/src/trans.c @@ -43,7 +43,7 @@ void* rpcOpen(const SRpcInit* pInit) { return NULL; } if (pInit->label) { - tstrncpy(pRpc->label, pInit->label, strlen(pInit->label) + 1); + tstrncpy(pRpc->label, pInit->label, TSDB_LABEL_LEN); } // register callback handle pRpc->cfp = pInit->cfp; diff --git a/source/util/src/talgo.c b/source/util/src/talgo.c index 5353cd9bfe..699f0db7a1 100644 --- a/source/util/src/talgo.c +++ b/source/util/src/talgo.c @@ -201,6 +201,7 @@ void *taosbsearch(const void *key, const void *base, int32_t nmemb, int32_t size return (c > 0) ? p : (midx > 0 ? p - size : NULL); } else { ASSERT(0); + return NULL; } } diff --git a/source/util/src/tcompare.c b/source/util/src/tcompare.c index 7032f39744..cbda4e4655 100644 --- a/source/util/src/tcompare.c +++ b/source/util/src/tcompare.c @@ -244,6 +244,7 @@ int32_t compareJsonVal(const void *pLeft, const void *pRight) { return 0; }else{ assert(0); + return 0; } } diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index 06ebbf27fb..d35670cb7f 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -446,7 +446,10 @@ static inline void taosPrintLogImp(ELogLevel level, int32_t dflag, const char *b } if (dflag & DEBUG_SCREEN) { - write(1, buffer, (uint32_t)len); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + write(STDOUT_FILENO, buffer, (uint32_t)len); +#pragma GCC diagnostic pop } } diff --git a/tests/test/c/sdbDump.c b/tests/test/c/sdbDump.c index aef5056031..b90b781e44 100644 --- a/tests/test/c/sdbDump.c +++ b/tests/test/c/sdbDump.c @@ -20,6 +20,9 @@ #include "tconfig.h" #include "tjson.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + #define TMP_DNODE_DIR TD_TMP_DIR_PATH "dumpsdb" #define TMP_MNODE_DIR TD_TMP_DIR_PATH "dumpsdb" TD_DIRSEP "mnode" #define TMP_SDB_DATA_DIR TD_TMP_DIR_PATH "dumpsdb" TD_DIRSEP "mnode" TD_DIRSEP "data" @@ -429,6 +432,7 @@ int32_t parseArgs(int32_t argc, char *argv[]) { char cmd[PATH_MAX * 2] = {0}; snprintf(cmd, sizeof(cmd), "rm -rf %s", TMP_DNODE_DIR); + system(cmd); #ifdef WINDOWS taosMulMkDir(TMP_SDB_DATA_DIR); @@ -467,3 +471,5 @@ int32_t main(int32_t argc, char *argv[]) { return dumpSdb(); } + +#pragma GCC diagnostic pop \ No newline at end of file diff --git a/tests/tsim/src/simExe.c b/tests/tsim/src/simExe.c index b993a8dbf1..16732ff9a1 100644 --- a/tests/tsim/src/simExe.c +++ b/tests/tsim/src/simExe.c @@ -464,7 +464,10 @@ void simStoreSystemContentResult(SScript *script, char *filename) { taosCloseFile(&pFile); char rmCmd[MAX_FILE_NAME_LEN] = {0}; sprintf(rmCmd, "rm -f %s", filename); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" system(rmCmd); +#pragma GCC diagnostic pop } } diff --git a/tools/shell/src/shellCommand.c b/tools/shell/src/shellCommand.c index d87e10fd08..b73317e991 100644 --- a/tools/shell/src/shellCommand.c +++ b/tools/shell/src/shellCommand.c @@ -510,7 +510,10 @@ int32_t shellReadCommand(char *command) { shellClearLineAfter(&cmd); break; case 12: // Ctrl + L; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" system("clear"); +#pragma GCC diagnostic pop shellShowOnScreen(&cmd); break; case 21: // Ctrl + U; diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index e54b98a0a6..45d5489803 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -62,7 +62,10 @@ int32_t shellRunSingleCommand(char *command) { } if (shellRegexMatch(command, "^[\t ]*clear[ \t;]*$", REG_EXTENDED | REG_ICASE)) { - system("clear"); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + system("clear"); +#pragma GCC diagnostic pop return 0; } -- GitLab