From 65471ac1a5a4e6595ffee2b519eef0c99053c6dd Mon Sep 17 00:00:00 2001 From: hope Date: Fri, 14 May 2021 00:20:21 +0800 Subject: [PATCH] fix some type error, and add compile-instruction in order to reduce potential errors --- .gitignore | 1 + CMakeLists.txt | 7 ++++++- packaging/release.sh | 4 ++-- src/client/src/tscSubquery.c | 4 ++-- src/kit/taosdemo/taosdemo.c | 2 +- src/mnode/src/mnodeDnode.c | 6 +++--- src/plugins/http/src/httpGzip.c | 4 ++-- src/plugins/http/src/httpParser.c | 6 +++--- src/plugins/http/src/httpTgHandle.c | 2 +- src/rpc/src/rpcTcp.c | 2 +- src/sync/src/syncMain.c | 14 +++++++------- src/sync/src/syncMsg.c | 4 ++-- src/tsdb/inc/tsdbMeta.h | 8 ++++---- src/tsdb/src/tsdbFS.c | 12 ++++++------ src/tsdb/src/tsdbFile.c | 10 +++++----- src/tsdb/src/tsdbMeta.c | 10 +++++----- src/util/src/tdes.c | 14 +++++++------- src/wal/src/walWrite.c | 2 +- 18 files changed, 59 insertions(+), 53 deletions(-) diff --git a/.gitignore b/.gitignore index 1ff1108056..da47590a2f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ build/ .vscode/ .idea/ cmake-build-debug/ +cmake-build-release/ cscope.out .DS_Store debug/ diff --git a/CMakeLists.txt b/CMakeLists.txt index e0d6e82923..0a3531908c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ IF (CMAKE_VERSION VERSION_LESS 3.0) PROJECT(TDengine CXX) SET(PROJECT_VERSION_MAJOR "${LIB_MAJOR_VERSION}") SET(PROJECT_VERSION_MINOR "${LIB_MINOR_VERSION}") - SET(PROJECT_VERSION_PATCH"${LIB_PATCH_VERSION}") + SET(PROJECT_VERSION_PATCH "${LIB_PATCH_VERSION}") SET(PROJECT_VERSION "${LIB_VERSION_STRING}") ELSE () CMAKE_POLICY(SET CMP0048 NEW) @@ -42,6 +42,11 @@ INCLUDE(cmake/env.inc) INCLUDE(cmake/version.inc) INCLUDE(cmake/install.inc) +#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -Wall -Wshadow -Wextra -Werror") +#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -Wall -Wshadow -Wextra -Werror") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -Wall -Wshadow -Werror") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -Wall -Wshadow -Werror") + ADD_SUBDIRECTORY(deps) ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(tests) diff --git a/packaging/release.sh b/packaging/release.sh index 68f947ccab..1e54bc2872 100755 --- a/packaging/release.sh +++ b/packaging/release.sh @@ -1,11 +1,11 @@ #!/bin/bash # -# Generate the deb package for ubunt, or rpm package for centos, or tar.gz package for other linux os +# Generate the deb package for ubuntu, or rpm package for centos, or tar.gz package for other linux os set -e #set -x -# releash.sh -v [cluster | edge] +# release.sh -v [cluster | edge] # -c [aarch32 | aarch64 | x64 | x86 | mips64 ...] # -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | Ningsi60 | Ningsi80 |...] # -V [stable | beta] diff --git a/src/client/src/tscSubquery.c b/src/client/src/tscSubquery.c index e9f87b3115..101cb6f714 100644 --- a/src/client/src/tscSubquery.c +++ b/src/client/src/tscSubquery.c @@ -55,9 +55,9 @@ static void skipRemainValue(STSBuf* pTSBuf, tVariant* tag1) { } while (tsBufNextPos(pTSBuf)) { - STSElem el1 = tsBufGetElem(pTSBuf); + el1 = tsBufGetElem(pTSBuf); - int32_t res = tVariantCompare(el1.tag, tag1); + res = tVariantCompare(el1.tag, tag1); if (res != 0) { // it is a record with new tag return; } diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 72044753d8..49d89dc597 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -4661,7 +4661,7 @@ static int64_t generateData(char *recBuf, char **data_type, double t = rand_double(); pstr += sprintf(pstr, ",%20.8f", t); } else if (strcasecmp(data_type[i % c], "BOOL") == 0) { - bool b = rand_bool() & 1; + bool b = taosRandom() & 1; pstr += sprintf(pstr, ",%s", b ? "true" : "false"); } else if (strcasecmp(data_type[i % c], "BINARY") == 0) { char *s = malloc(lenOfBinary); diff --git a/src/mnode/src/mnodeDnode.c b/src/mnode/src/mnodeDnode.c index b513da29f4..3525bcac18 100644 --- a/src/mnode/src/mnodeDnode.c +++ b/src/mnode/src/mnodeDnode.c @@ -522,13 +522,13 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) { pStatus->lastReboot = htonl(pStatus->lastReboot); pStatus->numOfCores = htons(pStatus->numOfCores); - uint32_t version = htonl(pStatus->version); - if (version != tsVersion) { + uint32_t _version = htonl(pStatus->version); + if (_version != tsVersion) { pDnode = mnodeGetDnodeByEp(pStatus->dnodeEp); if (pDnode != NULL && pDnode->status != TAOS_DN_STATUS_READY) { pDnode->offlineReason = TAOS_DN_OFF_VERSION_NOT_MATCH; } - mError("dnode:%d, status msg version:%d not equal with cluster:%d", pStatus->dnodeId, version, tsVersion); + mError("dnode:%d, status msg version:%d not equal with cluster:%d", pStatus->dnodeId, _version, tsVersion); return TSDB_CODE_MND_INVALID_MSG_VERSION; } diff --git a/src/plugins/http/src/httpGzip.c b/src/plugins/http/src/httpGzip.c index ecda0e1fe0..6a6e995c18 100644 --- a/src/plugins/http/src/httpGzip.c +++ b/src/plugins/http/src/httpGzip.c @@ -132,10 +132,10 @@ int32_t ehttp_gzip_write(ehttp_gzip_t *gzip, const char *buf, int32_t len) { if (ret != Z_STREAM_END) continue; } - int32_t len = (int32_t)(gzip->gzip->next_out - (z_const Bytef *)gzip->chunk); + int32_t _len = (int32_t)(gzip->gzip->next_out - (z_const Bytef *)gzip->chunk); gzip->gzip->next_out[0] = '\0'; - gzip->callbacks.on_data(gzip, gzip->arg, gzip->chunk, len); + gzip->callbacks.on_data(gzip, gzip->arg, gzip->chunk, _len); gzip->gzip->next_out = (z_const Bytef *)gzip->chunk; gzip->gzip->avail_out = gzip->conf.chunk_size; } diff --git a/src/plugins/http/src/httpParser.c b/src/plugins/http/src/httpParser.c index 18cea56cfe..599991da63 100644 --- a/src/plugins/http/src/httpParser.c +++ b/src/plugins/http/src/httpParser.c @@ -163,9 +163,9 @@ static int32_t httpOnRequestLine(HttpParser *pParser, char *method, char *target // parse decode method for (int32_t i = 0; i < tsHttpServer.methodScannerLen; i++) { - HttpDecodeMethod *method = tsHttpServer.methodScanner[i]; - if (strcmp(method->module, pParser->path[0].str) == 0) { - pContext->decodeMethod = method; + HttpDecodeMethod *_method = tsHttpServer.methodScanner[i]; + if (strcmp(_method->module, pParser->path[0].str) == 0) { + pContext->decodeMethod = _method; break; } } diff --git a/src/plugins/http/src/httpTgHandle.c b/src/plugins/http/src/httpTgHandle.c index c1d006ff5a..69ac3e19c5 100644 --- a/src/plugins/http/src/httpTgHandle.c +++ b/src/plugins/http/src/httpTgHandle.c @@ -209,7 +209,7 @@ void tgParseSchemaMetric(cJSON *metric) { parsedOk = false; goto ParseEnd; } - int32_t nameLen = (int32_t)strlen(field->valuestring); + nameLen = (int32_t)strlen(field->valuestring); if (nameLen == 0 || nameLen >= TSDB_TABLE_NAME_LEN) { parsedOk = false; goto ParseEnd; diff --git a/src/rpc/src/rpcTcp.c b/src/rpc/src/rpcTcp.c index 09857610d2..029629eff0 100644 --- a/src/rpc/src/rpcTcp.c +++ b/src/rpc/src/rpcTcp.c @@ -576,7 +576,7 @@ static void *taosProcessTcpData(void *param) { } while (pThreadObj->pHead) { - SFdObj *pFdObj = pThreadObj->pHead; + pFdObj = pThreadObj->pHead; pThreadObj->pHead = pFdObj->next; taosReportBrokenLink(pFdObj); } diff --git a/src/sync/src/syncMain.c b/src/sync/src/syncMain.c index e5f2d94c4a..3d8f54ad9b 100644 --- a/src/sync/src/syncMain.c +++ b/src/sync/src/syncMain.c @@ -389,17 +389,17 @@ int32_t syncForwardToPeer(int64_t rid, void *data, void *mhandle, int32_t qtype, return code; } -void syncConfirmForward(int64_t rid, uint64_t version, int32_t code, bool force) { +void syncConfirmForward(int64_t rid, uint64_t _version, int32_t code, bool force) { SSyncNode *pNode = syncAcquireNode(rid); if (pNode == NULL) return; SSyncPeer *pPeer = pNode->pMaster; if (pPeer && (pNode->quorum > 1 || force)) { SFwdRsp rsp; - syncBuildSyncFwdRsp(&rsp, pNode->vgId, version, code); + syncBuildSyncFwdRsp(&rsp, pNode->vgId, _version, code); if (taosWriteMsg(pPeer->peerFd, &rsp, sizeof(SFwdRsp)) == sizeof(SFwdRsp)) { - sTrace("%s, forward-rsp is sent, code:0x%x hver:%" PRIu64, pPeer->id, code, version); + sTrace("%s, forward-rsp is sent, code:0x%x hver:%" PRIu64, pPeer->id, code, _version); } else { sDebug("%s, failed to send forward-rsp, restart", pPeer->id); syncRestartConnection(pPeer); @@ -1302,14 +1302,14 @@ static void syncProcessBrokenLink(int64_t rid) { syncReleasePeer(pPeer); } -static int32_t syncSaveFwdInfo(SSyncNode *pNode, uint64_t version, void *mhandle) { +static int32_t syncSaveFwdInfo(SSyncNode *pNode, uint64_t _version, void *mhandle) { SSyncFwds *pSyncFwds = pNode->pSyncFwds; int64_t time = taosGetTimestampMs(); if (pSyncFwds->fwds >= SYNC_MAX_FWDS) { // pSyncFwds->first = (pSyncFwds->first + 1) % SYNC_MAX_FWDS; // pSyncFwds->fwds--; - sError("vgId:%d, failed to save fwd info, hver:%" PRIu64 " fwds:%d", pNode->vgId, version, pSyncFwds->fwds); + sError("vgId:%d, failed to save fwd info, hver:%" PRIu64 " fwds:%d", pNode->vgId, _version, pSyncFwds->fwds); return TSDB_CODE_SYN_TOO_MANY_FWDINFO; } @@ -1319,12 +1319,12 @@ static int32_t syncSaveFwdInfo(SSyncNode *pNode, uint64_t version, void *mhandle SFwdInfo *pFwdInfo = pSyncFwds->fwdInfo + pSyncFwds->last; memset(pFwdInfo, 0, sizeof(SFwdInfo)); - pFwdInfo->version = version; + pFwdInfo->version = _version; pFwdInfo->mhandle = mhandle; pFwdInfo->time = time; pSyncFwds->fwds++; - sTrace("vgId:%d, fwd info is saved, hver:%" PRIu64 " fwds:%d ", pNode->vgId, version, pSyncFwds->fwds); + sTrace("vgId:%d, fwd info is saved, hver:%" PRIu64 " fwds:%d ", pNode->vgId, _version, pSyncFwds->fwds); return 0; } diff --git a/src/sync/src/syncMsg.c b/src/sync/src/syncMsg.c index 3348f1ec33..64d4e72fac 100644 --- a/src/sync/src/syncMsg.c +++ b/src/sync/src/syncMsg.c @@ -61,13 +61,13 @@ void syncBuildSyncFwdMsg(SSyncHead *pHead, int32_t vgId, int32_t len) { syncBuildHead(pHead); } -void syncBuildSyncFwdRsp(SFwdRsp *pMsg, int32_t vgId, uint64_t version, int32_t code) { +void syncBuildSyncFwdRsp(SFwdRsp *pMsg, int32_t vgId, uint64_t _version, int32_t code) { pMsg->head.type = TAOS_SMSG_SYNC_FWD_RSP; pMsg->head.vgId = vgId; pMsg->head.len = sizeof(SFwdRsp) - sizeof(SSyncHead); syncBuildHead(&pMsg->head); - pMsg->version = version; + pMsg->version = _version; pMsg->code = code; } diff --git a/src/tsdb/inc/tsdbMeta.h b/src/tsdb/inc/tsdbMeta.h index cc916fa689..7484071ce3 100644 --- a/src/tsdb/inc/tsdbMeta.h +++ b/src/tsdb/inc/tsdbMeta.h @@ -69,7 +69,7 @@ void tsdbFreeMeta(STsdbMeta* pMeta); int tsdbOpenMeta(STsdbRepo* pRepo); int tsdbCloseMeta(STsdbRepo* pRepo); STable* tsdbGetTableByUid(STsdbMeta* pMeta, uint64_t uid); -STSchema* tsdbGetTableSchemaByVersion(STable* pTable, int16_t version); +STSchema* tsdbGetTableSchemaByVersion(STable* pTable, int16_t _version); int tsdbWLockRepoMeta(STsdbRepo* pRepo); int tsdbRLockRepoMeta(STsdbRepo* pRepo); int tsdbUnlockRepoMeta(STsdbRepo* pRepo); @@ -89,16 +89,16 @@ static FORCE_INLINE int tsdbCompareSchemaVersion(const void *key1, const void *k } } -static FORCE_INLINE STSchema* tsdbGetTableSchemaImpl(STable* pTable, bool lock, bool copy, int16_t version) { +static FORCE_INLINE STSchema* tsdbGetTableSchemaImpl(STable* pTable, bool lock, bool copy, int16_t _version) { STable* pDTable = (TABLE_TYPE(pTable) == TSDB_CHILD_TABLE) ? pTable->pSuper : pTable; STSchema* pSchema = NULL; STSchema* pTSchema = NULL; if (lock) TSDB_RLOCK_TABLE(pDTable); - if (version < 0) { // get the latest version of schema + if (_version < 0) { // get the latest version of schema pTSchema = pDTable->schema[pDTable->numOfSchemas - 1]; } else { // get the schema with version - void* ptr = taosbsearch(&version, pDTable->schema, pDTable->numOfSchemas, sizeof(STSchema*), + void* ptr = taosbsearch(&_version, pDTable->schema, pDTable->numOfSchemas, sizeof(STSchema*), tsdbCompareSchemaVersion, TD_EQ); if (ptr == NULL) { terrno = TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION; diff --git a/src/tsdb/src/tsdbFS.c b/src/tsdb/src/tsdbFS.c index f6e721e3d3..fd9b5e77e3 100644 --- a/src/tsdb/src/tsdbFS.c +++ b/src/tsdb/src/tsdbFS.c @@ -957,10 +957,10 @@ static int tsdbRestoreMeta(STsdbRepo *pRepo) { regfree(®ex); return -1; } else { - uint32_t version = 0; + uint32_t _version = 0; if (strcmp(bname, "meta") != 0) { - sscanf(bname, "meta-ver%" PRIu32, &version); - pfs->cstatus->meta.version = version; + sscanf(bname, "meta-ver%" PRIu32, &_version); + pfs->cstatus->meta.version = _version; } pfs->cstatus->pmf = &(pfs->cstatus->mf); @@ -1103,10 +1103,10 @@ static int tsdbRestoreDFileSet(STsdbRepo *pRepo) { int tvid, tfid; TSDB_FILE_T ttype; uint32_t tversion; - char bname[TSDB_FILENAME_LEN]; + char _bname[TSDB_FILENAME_LEN]; - tfsbasename(pf, bname); - tsdbParseDFilename(bname, &tvid, &tfid, &ttype, &tversion); + tfsbasename(pf, _bname); + tsdbParseDFilename(_bname, &tvid, &tfid, &ttype, &tversion); ASSERT(tvid == REPO_ID(pRepo)); diff --git a/src/tsdb/src/tsdbFile.c b/src/tsdb/src/tsdbFile.c index 5db993e463..50fa393e9f 100644 --- a/src/tsdb/src/tsdbFile.c +++ b/src/tsdb/src/tsdbFile.c @@ -410,7 +410,7 @@ int tsdbUpdateDFileHeader(SDFile *pDFile) { int tsdbLoadDFileHeader(SDFile *pDFile, SDFInfo *pInfo) { char buf[TSDB_FILE_HEAD_SIZE] = "\0"; - uint32_t version; + uint32_t _version; ASSERT(TSDB_FILE_OPENED(pDFile)); @@ -428,7 +428,7 @@ int tsdbLoadDFileHeader(SDFile *pDFile, SDFInfo *pInfo) { } void *pBuf = buf; - pBuf = taosDecodeFixedU32(pBuf, &version); + pBuf = taosDecodeFixedU32(pBuf, &_version); pBuf = tsdbDecodeDFInfo(pBuf, pInfo); return 0; } @@ -660,12 +660,12 @@ int tsdbScanAndTryFixDFileSet(STsdbRepo *pRepo, SDFileSet *pSet) { return 0; } -int tsdbParseDFilename(const char *fname, int *vid, int *fid, TSDB_FILE_T *ftype, uint32_t *version) { +int tsdbParseDFilename(const char *fname, int *vid, int *fid, TSDB_FILE_T *ftype, uint32_t *_version) { char *p = NULL; - *version = 0; + *_version = 0; *ftype = TSDB_FILE_MAX; - sscanf(fname, "v%df%d.%m[a-z]-ver%" PRIu32, vid, fid, &p, version); + sscanf(fname, "v%df%d.%m[a-z]-ver%" PRIu32, vid, fid, &p, _version); for (TSDB_FILE_T i = 0; i < TSDB_FILE_MAX; i++) { if (strcmp(p, TSDB_FNAME_SUFFIX[i]) == 0) { *ftype = i; diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index 3e6263b9d3..e6cbc4da9e 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -531,8 +531,8 @@ STable *tsdbGetTableByUid(STsdbMeta *pMeta, uint64_t uid) { return *(STable **)ptr; } -STSchema *tsdbGetTableSchemaByVersion(STable *pTable, int16_t version) { - return tsdbGetTableSchemaImpl(pTable, true, false, version); +STSchema *tsdbGetTableSchemaByVersion(STable *pTable, int16_t _version) { + return tsdbGetTableSchemaImpl(pTable, true, false, _version); } int tsdbWLockRepoMeta(STsdbRepo *pRepo) { @@ -891,9 +891,9 @@ static void tsdbRemoveTableFromMeta(STsdbRepo *pRepo, STable *pTable, bool rmFro maxCols = 0; maxRowBytes = 0; for (int i = 0; i < pMeta->maxTables; i++) { - STable *pTable = pMeta->tables[i]; - if (pTable != NULL) { - pSchema = tsdbGetTableSchemaImpl(pTable, false, false, -1); + STable *_pTable = pMeta->tables[i]; + if (_pTable != NULL) { + pSchema = tsdbGetTableSchemaImpl(_pTable, false, false, -1); maxCols = MAX(maxCols, schemaNCols(pSchema)); maxRowBytes = MAX(maxRowBytes, schemaTLen(pSchema)); } diff --git a/src/util/src/tdes.c b/src/util/src/tdes.c index 6e003756a3..f72ddcaa3b 100644 --- a/src/util/src/tdes.c +++ b/src/util/src/tdes.c @@ -155,26 +155,26 @@ void generate_key(unsigned char* key) { } } -void print_key_set(key_set key_set) { +void print_key_set(key_set _key_set) { int i; printf("K: \n"); for (i = 0; i < 8; i++) { - printf("%02X : ", key_set.k[i]); - print_char_as_binary(key_set.k[i]); + printf("%02X : ", _key_set.k[i]); + print_char_as_binary(_key_set.k[i]); printf("\n"); } printf("\nC: \n"); for (i = 0; i < 4; i++) { - printf("%02X : ", key_set.c[i]); - print_char_as_binary(key_set.c[i]); + printf("%02X : ", _key_set.c[i]); + print_char_as_binary(_key_set.c[i]); printf("\n"); } printf("\nD: \n"); for (i = 0; i < 4; i++) { - printf("%02X : ", key_set.d[i]); - print_char_as_binary(key_set.d[i]); + printf("%02X : ", _key_set.d[i]); + print_char_as_binary(_key_set.d[i]); printf("\n"); } printf("\n"); diff --git a/src/wal/src/walWrite.c b/src/wal/src/walWrite.c index 4368ddd7d3..0981d7a996 100644 --- a/src/wal/src/walWrite.c +++ b/src/wal/src/walWrite.c @@ -199,7 +199,7 @@ int32_t walRestore(void *handle, void *pVnode, FWalWrite writeFp) { snprintf(walName, sizeof(pWal->name), "%s/%s%" PRId64, pWal->path, WAL_PREFIX, fileId); wInfo("vgId:%d, file:%s, will be restored", pWal->vgId, walName); - int32_t code = walRestoreWalFile(pWal, pVnode, writeFp, walName, fileId); + code = walRestoreWalFile(pWal, pVnode, writeFp, walName, fileId); if (code != TSDB_CODE_SUCCESS) { wError("vgId:%d, file:%s, failed to restore since %s", pWal->vgId, walName, tstrerror(code)); continue; -- GitLab