From 8fa7038ee6b220bdd581b0082aebf2f12fd285dc Mon Sep 17 00:00:00 2001 From: slguan Date: Sun, 8 Dec 2019 15:27:25 +0800 Subject: [PATCH 01/17] [TBASE-1297] --- src/modules/http/src/httpServer.c | 6 +++--- src/modules/http/src/tgHandle.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/http/src/httpServer.c b/src/modules/http/src/httpServer.c index 232119b32a..171f811b7d 100644 --- a/src/modules/http/src/httpServer.c +++ b/src/modules/http/src/httpServer.c @@ -106,7 +106,7 @@ void httpCleanUpContextTimer(HttpContext *pContext) { } } -void httpCleanUpContext(HttpContext *pContext) { +void httpCleanUpContext(HttpContext *pContext, void *unused) { httpTrace("context:%p, start the clean up operation, sig:%p", pContext, pContext->signature); void *sig = atomic_val_compare_exchange_ptr(&pContext->signature, pContext, 0); if (sig == NULL) { @@ -184,7 +184,7 @@ bool httpInitContext(HttpContext *pContext) { void httpCloseContext(HttpThread *pThread, HttpContext *pContext) { - taosTmrReset(httpCleanUpContext, HTTP_DELAY_CLOSE_TIME_MS, pContext, pThread->pServer->timerHandle, &pContext->timer); + taosTmrReset((TAOS_TMR_CALLBACK)httpCleanUpContext, HTTP_DELAY_CLOSE_TIME_MS, pContext, pThread->pServer->timerHandle, &pContext->timer); httpTrace("context:%p, fd:%d, ip:%s, state:%s will be closed after:%d ms, timer:%p", pContext, pContext->fd, pContext->ipstr, httpContextStateStr(pContext->state), HTTP_DELAY_CLOSE_TIME_MS, pContext->timer); } @@ -273,7 +273,7 @@ void httpCleanUpConnect(HttpServer *pServer) { taosCloseSocket(pThread->pollFd); while (pThread->pHead) { - httpCleanUpContext(pThread->pHead); + httpCleanUpContext(pThread->pHead, 0); } pthread_cancel(pThread->thread); diff --git a/src/modules/http/src/tgHandle.c b/src/modules/http/src/tgHandle.c index ac17d6da09..bfbe7001a0 100644 --- a/src/modules/http/src/tgHandle.c +++ b/src/modules/http/src/tgHandle.c @@ -215,7 +215,7 @@ ParseEnd: } } -int tgParseSchema(char *content, char*fileName) { +int tgParseSchema(const char *content, char*fileName) { cJSON *root = cJSON_Parse(content); if (root == NULL) { httpError("failed to parse telegraf schema file:%s, invalid json format, content:%s", fileName, content); @@ -248,7 +248,7 @@ int tgParseSchema(char *content, char*fileName) { return size; } -int tgReadSchema(const char *fileName) { +int tgReadSchema(char *fileName) { FILE *fp = fopen(fileName, "r"); if (fp == NULL) { return -1; From 02d509e6a7c70469b39389006ecb150ec8485fee Mon Sep 17 00:00:00 2001 From: fang Date: Mon, 9 Dec 2019 09:40:23 +0800 Subject: [PATCH 02/17] solve static check questions --- src/client/src/tscPrepare.c | 2 +- src/client/src/tscProfile.c | 2 +- src/client/src/tscSQLParser.c | 42 +++++++++++++++++------------------ 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index 7e62afefe6..8b8361fc8d 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -65,6 +65,7 @@ static int normalStmtAddPart(SNormalStmt* stmt, bool isParam, char* str, uint32_ } stmt->sizeParts = size; stmt->parts = (SNormalStmtPart*)tmp; + free(tmp); //fang memory leak } stmt->parts[stmt->numParts].isParam = isParam; @@ -75,7 +76,6 @@ static int normalStmtAddPart(SNormalStmt* stmt, bool isParam, char* str, uint32_ if (isParam) { ++stmt->numParams; } - return TSDB_CODE_SUCCESS; } diff --git a/src/client/src/tscProfile.c b/src/client/src/tscProfile.c index 61bc9dd99e..930198cbc3 100644 --- a/src/client/src/tscProfile.c +++ b/src/client/src/tscProfile.c @@ -198,7 +198,7 @@ void tscKillStream(STscObj *pObj, uint32_t killId) { pthread_mutex_unlock(&pObj->mutex); - tscTrace("%p stream:%p is killed, streamId:%d", pStream->pSql, pStream, killId); + tscTrace("%p stream:%p is killed, streamId:%d", pStream->pSql, pStream, killId); //fang, pStream could be null taos_close_stream(pStream); if (pStream->callback) { diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 752c5d123f..20e4c3e518 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -248,7 +248,6 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { } case USE_DATABASE: { - const char* msg = "db name too long"; pCmd->command = TSDB_SQL_USE_DB; SSQLToken* pToken = &pInfo->pDCLInfo->a[0]; @@ -258,6 +257,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { } if (pToken->n > TSDB_DB_NAME_LEN) { + const char* msg = "db name too long"; //fang, reduce scope return invalidSqlErrMsg(pCmd, msg); } @@ -295,8 +295,6 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { case ALTER_DATABASE: case CREATE_DATABASE: { - const char* msg2 = "name too long"; - const char* msg3 = "invalid db name"; if (pInfo->sqlType == ALTER_DATABASE) { pCmd->command = TSDB_SQL_ALTER_DB; @@ -307,11 +305,13 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { SCreateDBInfo* pCreateDB = &(pInfo->pDCLInfo->dbOpt); if (tscValidateName(&pCreateDB->dbname) != TSDB_CODE_SUCCESS) { - return invalidSqlErrMsg(pCmd, msg3); + const char* msg3 = "invalid db name"; + return invalidSqlErrMsg(pCmd, msg3);//fang reduce scope } int32_t ret = setObjFullName(pMeterMetaInfo->name, getAccountId(pSql), &(pCreateDB->dbname), NULL, NULL); if (ret != TSDB_CODE_SUCCESS) { + const char* msg2 = "name too long"; //fang reduce scope return invalidSqlErrMsg(pCmd, msg2); } @@ -347,14 +347,9 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { pCmd->command = (pInfo->sqlType == CREATE_USER) ? TSDB_SQL_CREATE_USER : TSDB_SQL_CREATE_ACCT; assert(pInfo->pDCLInfo->nTokens >= 2); - const char* msg = "name or password too long"; - const char* msg1 = "password can not be empty"; - const char* msg2 = "invalid user/account name"; - const char* msg3 = "password needs single quote marks enclosed"; - const char* msg4 = "invalid state option, available options[no, r, w, all]"; - if (pInfo->pDCLInfo->a[1].type != TK_STRING) { - return invalidSqlErrMsg(pCmd, msg3); + const char* msg3 = "password needs single quote marks enclosed"; + return invalidSqlErrMsg(pCmd, msg3);//fang reduce scope } strdequote(pInfo->pDCLInfo->a[1].z); @@ -362,15 +357,18 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { pInfo->pDCLInfo->a[1].n = strlen(pInfo->pDCLInfo->a[1].z); if (pInfo->pDCLInfo->a[1].n <= 0) { - return invalidSqlErrMsg(pCmd, msg1); + const char* msg1 = "password can not be empty"; + return invalidSqlErrMsg(pCmd, msg1);//fang reduce scope } if (pInfo->pDCLInfo->a[0].n > TSDB_USER_LEN || pInfo->pDCLInfo->a[1].n > TSDB_PASSWORD_LEN) { - return invalidSqlErrMsg(pCmd, msg); + const char* msg = "name or password too long"; + return invalidSqlErrMsg(pCmd, msg); //fang reduce scope } if (tscValidateName(&pInfo->pDCLInfo->a[0]) != TSDB_CODE_SUCCESS) { - return invalidSqlErrMsg(pCmd, msg2); + const char* msg2 = "invalid user/account name"; + return invalidSqlErrMsg(pCmd, msg2); //fang reduce scope } strncpy(pMeterMetaInfo->name, pInfo->pDCLInfo->a[0].z, pInfo->pDCLInfo->a[0].n); // name @@ -403,7 +401,8 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { } else if (strncmp(pAcctOpt->stat.z, "no", 2) == 0 && pAcctOpt->stat.n == 2) { pCmd->defaultVal[8] = 0; } else { - return invalidSqlErrMsg(pCmd, msg4); + const char* msg4 = "invalid state option, available options[no, r, w, all]"; + return invalidSqlErrMsg(pCmd, msg4); //fang reduce scope } } } @@ -415,13 +414,10 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { assert(num >= 1 && num <= 2); const char* msg = "password too long"; - const char* msg1 = "password can not be empty"; - const char* msg2 = "invalid user/account name"; - const char* msg3 = "password needs single quote marks enclosed"; - const char* msg4 = "invalid state option, available options[no, r, w, all]"; if (num == 2) { if (pInfo->pDCLInfo->a[1].type != TK_STRING) { + const char* msg3 = "password needs single quote marks enclosed"; return invalidSqlErrMsg(pCmd, msg3); } @@ -430,6 +426,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { pInfo->pDCLInfo->a[1].n = strlen(pInfo->pDCLInfo->a[1].z); if (pInfo->pDCLInfo->a[1].n <= 0) { + const char* msg1 = "password can not be empty"; return invalidSqlErrMsg(pCmd, msg1); } @@ -445,6 +442,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { } if (tscValidateName(&pInfo->pDCLInfo->a[0]) != TSDB_CODE_SUCCESS) { + const char* msg2 = "invalid user/account name"; return invalidSqlErrMsg(pCmd, msg2); } @@ -475,6 +473,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { } else if (strncmp(pAcctOpt->stat.z, "no", 2) == 0 && pAcctOpt->stat.n == 2) { pCmd->defaultVal[8] = 0; } else { + const char* msg4 = "invalid state option, available options[no, r, w, all]"; return invalidSqlErrMsg(pCmd, msg4); } } @@ -1868,8 +1867,6 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem SMeterMetaInfo* pMeterMetaInfo = NULL; int32_t optr = pItem->pNode->nSQLOptr; - int32_t numOfAddedColumn = 1; - const char* msg1 = "not support column types"; const char* msg2 = "invalid parameters"; const char* msg3 = "illegal column name"; @@ -2166,6 +2163,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem int16_t resultSize = pSchema[index.columnIndex].bytes; char val[8] = {0}; + int32_t numOfAddedColumn = 1; //fang reduce scope if (optr == TK_PERCENTILE || optr == TK_APERCENTILE) { tVariantDump(pVariant, val, TSDB_DATA_TYPE_DOUBLE); @@ -2190,6 +2188,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem SSqlExpr* pExpr = tscSqlExprInsert(pCmd, colIdx, functionId, &index, resultType, resultSize, resultSize); addExprParams(pExpr, val, TSDB_DATA_TYPE_DOUBLE, sizeof(double), 0); } else { + tVariantDump(pVariant, val, TSDB_DATA_TYPE_BIGINT); int64_t nTop = *((int32_t*)val); @@ -2928,6 +2927,7 @@ static SColumnFilterInfo* addColumnFilterInfo(SColumnBase* pColumn) { char* tmp = realloc(pColumn->filterInfo, sizeof(SColumnFilterInfo) * (size)); if (tmp != NULL) { pColumn->filterInfo = (SColumnFilterInfo*)tmp; + free(tmp); //fang, memory leak } pColumn->numOfFilters++; From b93b86862a7b5b9760a602562a20d7451b324b29 Mon Sep 17 00:00:00 2001 From: fang Date: Mon, 9 Dec 2019 10:00:02 +0800 Subject: [PATCH 03/17] solve static check --- src/client/src/tscPrepare.c | 2 +- src/client/src/tscProfile.c | 6 ++++-- src/client/src/tscSQLParser.c | 20 ++++++++++---------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index 8b8361fc8d..2f1db58117 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -65,7 +65,7 @@ static int normalStmtAddPart(SNormalStmt* stmt, bool isParam, char* str, uint32_ } stmt->sizeParts = size; stmt->parts = (SNormalStmtPart*)tmp; - free(tmp); //fang memory leak + free(tmp); } stmt->parts[stmt->numParts].isParam = isParam; diff --git a/src/client/src/tscProfile.c b/src/client/src/tscProfile.c index 930198cbc3..15390ef201 100644 --- a/src/client/src/tscProfile.c +++ b/src/client/src/tscProfile.c @@ -197,8 +197,10 @@ void tscKillStream(STscObj *pObj, uint32_t killId) { } pthread_mutex_unlock(&pObj->mutex); - - tscTrace("%p stream:%p is killed, streamId:%d", pStream->pSql, pStream, killId); //fang, pStream could be null + + if (pStream) { + tscTrace("%p stream:%p is killed, streamId:%d", pStream->pSql, pStream, killId); + } taos_close_stream(pStream); if (pStream->callback) { diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 20e4c3e518..cb73a6e9bd 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -257,7 +257,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { } if (pToken->n > TSDB_DB_NAME_LEN) { - const char* msg = "db name too long"; //fang, reduce scope + const char* msg = "db name too long"; return invalidSqlErrMsg(pCmd, msg); } @@ -306,12 +306,12 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { SCreateDBInfo* pCreateDB = &(pInfo->pDCLInfo->dbOpt); if (tscValidateName(&pCreateDB->dbname) != TSDB_CODE_SUCCESS) { const char* msg3 = "invalid db name"; - return invalidSqlErrMsg(pCmd, msg3);//fang reduce scope + return invalidSqlErrMsg(pCmd, msg3); } int32_t ret = setObjFullName(pMeterMetaInfo->name, getAccountId(pSql), &(pCreateDB->dbname), NULL, NULL); if (ret != TSDB_CODE_SUCCESS) { - const char* msg2 = "name too long"; //fang reduce scope + const char* msg2 = "name too long"; return invalidSqlErrMsg(pCmd, msg2); } @@ -349,7 +349,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { if (pInfo->pDCLInfo->a[1].type != TK_STRING) { const char* msg3 = "password needs single quote marks enclosed"; - return invalidSqlErrMsg(pCmd, msg3);//fang reduce scope + return invalidSqlErrMsg(pCmd, msg3); } strdequote(pInfo->pDCLInfo->a[1].z); @@ -358,17 +358,17 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { if (pInfo->pDCLInfo->a[1].n <= 0) { const char* msg1 = "password can not be empty"; - return invalidSqlErrMsg(pCmd, msg1);//fang reduce scope + return invalidSqlErrMsg(pCmd, msg1); } if (pInfo->pDCLInfo->a[0].n > TSDB_USER_LEN || pInfo->pDCLInfo->a[1].n > TSDB_PASSWORD_LEN) { const char* msg = "name or password too long"; - return invalidSqlErrMsg(pCmd, msg); //fang reduce scope + return invalidSqlErrMsg(pCmd, msg); } if (tscValidateName(&pInfo->pDCLInfo->a[0]) != TSDB_CODE_SUCCESS) { const char* msg2 = "invalid user/account name"; - return invalidSqlErrMsg(pCmd, msg2); //fang reduce scope + return invalidSqlErrMsg(pCmd, msg2); } strncpy(pMeterMetaInfo->name, pInfo->pDCLInfo->a[0].z, pInfo->pDCLInfo->a[0].n); // name @@ -402,7 +402,7 @@ int32_t tscToSQLCmd(SSqlObj* pSql, struct SSqlInfo* pInfo) { pCmd->defaultVal[8] = 0; } else { const char* msg4 = "invalid state option, available options[no, r, w, all]"; - return invalidSqlErrMsg(pCmd, msg4); //fang reduce scope + return invalidSqlErrMsg(pCmd, msg4); } } } @@ -2163,7 +2163,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, int32_t colIdx, tSQLExprItem* pItem int16_t resultSize = pSchema[index.columnIndex].bytes; char val[8] = {0}; - int32_t numOfAddedColumn = 1; //fang reduce scope + int32_t numOfAddedColumn = 1; if (optr == TK_PERCENTILE || optr == TK_APERCENTILE) { tVariantDump(pVariant, val, TSDB_DATA_TYPE_DOUBLE); @@ -2927,7 +2927,7 @@ static SColumnFilterInfo* addColumnFilterInfo(SColumnBase* pColumn) { char* tmp = realloc(pColumn->filterInfo, sizeof(SColumnFilterInfo) * (size)); if (tmp != NULL) { pColumn->filterInfo = (SColumnFilterInfo*)tmp; - free(tmp); //fang, memory leak + free(tmp); } pColumn->numOfFilters++; From 27f51a5cea1bdcb0e7b2ef0df5649e59e6ae38ed Mon Sep 17 00:00:00 2001 From: lihui Date: Mon, 9 Dec 2019 10:25:02 +0800 Subject: [PATCH 04/17] [Resolve compile alarms] --- src/util/src/tcompression.c | 16 ++++++++-------- src/util/src/ttokenizer.c | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/util/src/tcompression.c b/src/util/src/tcompression.c index 1ac42377fb..0f0c7bed34 100644 --- a/src/util/src/tcompression.c +++ b/src/util/src/tcompression.c @@ -355,16 +355,16 @@ int tsCompressINTImp(const char *const input, const int nelements, char *const o tmp_bit = (LONG_BYTES * BITS_PER_BYTE) - BUILDIN_CLZL(zigzag_value); } - if (elems + 1 <= selector_to_elems[selector] && elems + 1 <= selector_to_elems[bit_to_selector[tmp_bit]]) { + if (elems + 1 <= selector_to_elems[(int)selector] && elems + 1 <= selector_to_elems[(int)(bit_to_selector[(int)tmp_bit])]) { // If can hold another one. - selector = selector > bit_to_selector[tmp_bit] ? selector : bit_to_selector[tmp_bit]; + selector = selector > bit_to_selector[(int)tmp_bit] ? selector : bit_to_selector[(int)tmp_bit]; elems++; - bit = bit_per_integer[selector]; + bit = bit_per_integer[(int)selector]; } else { // if cannot hold another one. - while (elems < selector_to_elems[selector]) selector++; - elems = selector_to_elems[selector]; - bit = bit_per_integer[selector]; + while (elems < selector_to_elems[(int)selector]) selector++; + elems = selector_to_elems[(int)selector]; + bit = bit_per_integer[(int)selector]; break; } prev_value_tmp = curr_value; @@ -455,8 +455,8 @@ int tsDecompressINTImp(const char *const input, const int nelements, char *const memcpy(&w, ip, LONG_BYTES); char selector = (char)(w & INT64MASK(4)); // selector = 4 - char bit = bit_per_integer[selector]; // bit = 3 - int elems = selector_to_elems[selector]; + char bit = bit_per_integer[(int)selector]; // bit = 3 + int elems = selector_to_elems[(int)selector]; for (int i = 0; i < elems; i++) { uint64_t zigzag_value; diff --git a/src/util/src/ttokenizer.c b/src/util/src/ttokenizer.c index f402963049..516f02fc20 100644 --- a/src/util/src/ttokenizer.c +++ b/src/util/src/ttokenizer.c @@ -510,7 +510,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) { if ((z[i] == 'a' || z[i] == 's' || z[i] == 'm' || z[i] == 'h' || z[i] == 'd' || z[i] == 'n' || z[i] == 'y' || z[i] == 'w' || z[i] == 'A' || z[i] == 'S' || z[i] == 'M' || z[i] == 'H' || z[i] == 'D' || z[i] == 'N' || z[i] == 'Y' || z[i] == 'W') && - (isIdChar[z[i + 1]] == 0)) { + (isIdChar[(int)(z[i + 1])] == 0)) { *tokenType = TK_VARIABLE; i += 1; return i; @@ -551,7 +551,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) { case 't': case 'F': case 'f': { - for (i = 1; ((z[i] & 0x80) == 0) && isIdChar[z[i]]; i++) { + for (i = 1; ((z[i] & 0x80) == 0) && isIdChar[(int)(z[i])]; i++) { } if ((i == 4 && strncasecmp(z, "true", 4) == 0) || (i == 5 && strncasecmp(z, "false", 5) == 0)) { @@ -560,10 +560,10 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) { } } default: { - if (((*z & 0x80) != 0) || !isIdChar[*z]) { + if (((*z & 0x80) != 0) || !isIdChar[(int)(*z)]) { break; } - for (i = 1; ((z[i] & 0x80) == 0) && isIdChar[z[i]]; i++) { + for (i = 1; ((z[i] & 0x80) == 0) && isIdChar[(int)(z[i])]; i++) { } *tokenType = tSQLKeywordCode(z, i); return i; From 4af3669836c94ed1b5cac965e0475e1ab4238955 Mon Sep 17 00:00:00 2001 From: slguan Date: Mon, 9 Dec 2019 10:26:51 +0800 Subject: [PATCH 05/17] [TBASE-1297] --- src/inc/tutil.h | 2 ++ src/system/detail/src/mgmtDb.c | 4 ++-- src/system/detail/src/mgmtDnode.c | 1 - src/system/detail/src/mgmtMeter.c | 4 ++-- src/system/detail/src/mgmtShell.c | 6 +++--- src/system/detail/src/mgmtSupertableQuery.c | 13 +++++++++++-- src/system/detail/src/mgmtUser.c | 4 ++-- src/system/detail/src/mgmtVgroup.c | 4 ++-- src/system/detail/src/vnodeFile.c | 19 +++++++++---------- src/system/detail/src/vnodeImport.c | 6 +++--- src/system/detail/src/vnodeMeter.c | 8 ++++---- src/system/detail/src/vnodeQueryImpl.c | 6 ++++-- src/util/src/tsocket.c | 4 +--- 13 files changed, 45 insertions(+), 36 deletions(-) diff --git a/src/inc/tutil.h b/src/inc/tutil.h index bdf9df63ee..2e5e915019 100644 --- a/src/inc/tutil.h +++ b/src/inc/tutil.h @@ -189,6 +189,8 @@ static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, unsigned int inLen, cha char *taosIpStr(uint32_t ipInt); +uint32_t ip2uint(const char *const ip_addr); + #define TAOS_ALLOC_MODE_DEFAULT 0 #define TAOS_ALLOC_MODE_RANDOM_FAIL 1 #define TAOS_ALLOC_MODE_DETECT_LEAK 2 diff --git a/src/system/detail/src/mgmtDb.c b/src/system/detail/src/mgmtDb.c index b571e01942..1ad41c00eb 100644 --- a/src/system/detail/src/mgmtDb.c +++ b/src/system/detail/src/mgmtDb.c @@ -54,8 +54,8 @@ void mgmtDbActionInit() { } void *mgmtDbAction(char action, void *row, char *str, int size, int *ssize) { - if (mgmtDbActionFp[action] != NULL) { - return (*(mgmtDbActionFp[action]))(row, str, size, ssize); + if (mgmtDbActionFp[(uint8_t)action] != NULL) { + return (*(mgmtDbActionFp[(uint8_t)action]))(row, str, size, ssize); } return NULL; } diff --git a/src/system/detail/src/mgmtDnode.c b/src/system/detail/src/mgmtDnode.c index 86550b46e7..753d8bdaa0 100644 --- a/src/system/detail/src/mgmtDnode.c +++ b/src/system/detail/src/mgmtDnode.c @@ -461,7 +461,6 @@ int mgmtRetrieveVnodes(SShowObj *pShow, char *data, int rows, SConnObj *pConn) { SDnodeObj *pDnode = NULL; char * pWrite; int cols = 0; - char ipstr[20]; if (0 == rows) return 0; diff --git a/src/system/detail/src/mgmtMeter.c b/src/system/detail/src/mgmtMeter.c index 4e1d62e60e..5ef9f61b0b 100644 --- a/src/system/detail/src/mgmtMeter.c +++ b/src/system/detail/src/mgmtMeter.c @@ -418,8 +418,8 @@ void *mgmtMeterActionAfterBatchUpdate(void *row, char *str, int size, int *ssize } void *mgmtMeterAction(char action, void *row, char *str, int size, int *ssize) { - if (mgmtMeterActionFp[action] != NULL) { - return (*(mgmtMeterActionFp[action]))(row, str, size, ssize); + if (mgmtMeterActionFp[(uint8_t)action] != NULL) { + return (*(mgmtMeterActionFp[(uint8_t)action]))(row, str, size, ssize); } return NULL; } diff --git a/src/system/detail/src/mgmtShell.c b/src/system/detail/src/mgmtShell.c index fe1932b24a..97e8d94fdc 100644 --- a/src/system/detail/src/mgmtShell.c +++ b/src/system/detail/src/mgmtShell.c @@ -840,11 +840,11 @@ int mgmtProcessShowMsg(char *pMsg, int msgLen, SConnObj *pConn) { pShowRsp->qhandle = (uint64_t)pShow; // qhandle; pConn->qhandle = pShowRsp->qhandle; - code = (*mgmtGetMetaFp[pShowMsg->type])(&pShowRsp->meterMeta, pShow, pConn); + code = (*mgmtGetMetaFp[(uint8_t)pShowMsg->type])(&pShowRsp->meterMeta, pShow, pConn); if (code == 0) { pMsg += sizeof(SShowRspMsg) + sizeof(SSchema) * pShow->numOfColumns; } else { - mError("pShow:%p, type:%d %s, failed to get Meta, code:%d", pShow, pShowMsg->type, taosMsg[pShowMsg->type], code); + mError("pShow:%p, type:%d %s, failed to get Meta, code:%d", pShow, pShowMsg->type, taosMsg[(uint8_t)pShowMsg->type], code); free(pShow); } } @@ -915,7 +915,7 @@ int mgmtProcessRetrieveMsg(char *pMsg, int msgLen, SConnObj *pConn) { // if free flag is set, client wants to clean the resources if ((pRetrieve->free & TSDB_QUERY_TYPE_FREE_RESOURCE) != TSDB_QUERY_TYPE_FREE_RESOURCE) - rowsRead = (*mgmtRetrieveFp[pShow->type])(pShow, pRsp->data, rowsToRead, pConn); + rowsRead = (*mgmtRetrieveFp[(uint8_t)pShow->type])(pShow, pRsp->data, rowsToRead, pConn); if (rowsRead < 0) { rowsRead = 0; diff --git a/src/system/detail/src/mgmtSupertableQuery.c b/src/system/detail/src/mgmtSupertableQuery.c index 4dc7760d89..4da5d66a6f 100644 --- a/src/system/detail/src/mgmtSupertableQuery.c +++ b/src/system/detail/src/mgmtSupertableQuery.c @@ -203,7 +203,7 @@ static bool mgmtTablenameFilterCallback(tSkipListNode* pNode, void* param) { static void mgmtRetrieveFromLikeOptr(tQueryResultset* pRes, const char* str, STabObj* pMetric) { SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER; - SMeterNameFilterSupporter supporter = {info, str}; + SMeterNameFilterSupporter supporter = {info, (char*)str}; pRes->num = tSkipListIterateList(pMetric->pSkipList, (tSkipListNode***)&pRes->pRes, mgmtTablenameFilterCallback, &supporter); @@ -230,6 +230,12 @@ static void mgmtFilterByTableNameCond(tQueryResultset* pRes, char* condStr, int3 free(str); } + +/* + *-Wunused-function" + */ + +#if 0 static bool mgmtJoinFilterCallback(tSkipListNode* pNode, void* param) { SJoinSupporter* pSupporter = (SJoinSupporter*)param; @@ -259,6 +265,7 @@ static bool mgmtJoinFilterCallback(tSkipListNode* pNode, void* param) { return false; } +#endif static void orderResult(SMetricMetaMsg* pMetricMetaMsg, tQueryResultset* pRes, int16_t colIndex, int32_t tableIndex) { SMetricMetaElemMsg* pElem = (SMetricMetaElemMsg*)((char*)pMetricMetaMsg + pMetricMetaMsg->metaElem[tableIndex]); @@ -691,7 +698,9 @@ static int32_t mgmtFilterMeterByIndex(STabObj* pMetric, tQueryResultset* pRes, c return TSDB_CODE_OPS_NOT_SUPPORT; } else { // query according to the binary expression SSyntaxTreeFilterSupporter s = {.pTagSchema = pTagSchema, .numOfTags = pMetric->numOfTags}; - SBinaryFilterSupp supp = {.fp = tSkipListNodeFilterCallback, .setupInfoFn = filterPrepare, .pExtInfo = &s}; + SBinaryFilterSupp supp = {.fp = (__result_filter_fn_t)tSkipListNodeFilterCallback, + .setupInfoFn = (__do_filter_suppl_fn_t)filterPrepare, + .pExtInfo = &s}; tSQLBinaryExprTraverse(pExpr, pMetric->pSkipList, pRes, &supp); tSQLBinaryExprDestroy(&pExpr, tSQLListTraverseDestroyInfo); diff --git a/src/system/detail/src/mgmtUser.c b/src/system/detail/src/mgmtUser.c index 1acceb1ade..89b83e3553 100644 --- a/src/system/detail/src/mgmtUser.c +++ b/src/system/detail/src/mgmtUser.c @@ -54,8 +54,8 @@ void mgmtUserActionInit() { } void *mgmtUserAction(char action, void *row, char *str, int size, int *ssize) { - if (mgmtUserActionFp[action] != NULL) { - return (*(mgmtUserActionFp[action]))(row, str, size, ssize); + if (mgmtUserActionFp[(uint8_t)action] != NULL) { + return (*(mgmtUserActionFp[(uint8_t)action]))(row, str, size, ssize); } return NULL; } diff --git a/src/system/detail/src/mgmtVgroup.c b/src/system/detail/src/mgmtVgroup.c index e3bed57b33..806c475b2a 100644 --- a/src/system/detail/src/mgmtVgroup.c +++ b/src/system/detail/src/mgmtVgroup.c @@ -55,8 +55,8 @@ void mgmtVgroupActionInit() { } void *mgmtVgroupAction(char action, void *row, char *str, int size, int *ssize) { - if (mgmtVgroupActionFp[action] != NULL) { - return (*(mgmtVgroupActionFp[action]))(row, str, size, ssize); + if (mgmtVgroupActionFp[(uint8_t)action] != NULL) { + return (*(mgmtVgroupActionFp[(uint8_t)action]))(row, str, size, ssize); } return NULL; } diff --git a/src/system/detail/src/vnodeFile.c b/src/system/detail/src/vnodeFile.c index 1cb28e8399..ed56f72134 100644 --- a/src/system/detail/src/vnodeFile.c +++ b/src/system/detail/src/vnodeFile.c @@ -187,13 +187,13 @@ int vnodeCreateNeccessaryFiles(SVnodeObj *pVnode) { if (pVnode->lastKeyOnFile == 0) { if (pCfg->daysPerFile == 0) pCfg->daysPerFile = 10; - pVnode->fileId = pVnode->firstKey / tsMsPerDay[pVnode->cfg.precision] / pCfg->daysPerFile; - pVnode->lastKeyOnFile = (int64_t)(pVnode->fileId + 1) * pCfg->daysPerFile * tsMsPerDay[pVnode->cfg.precision] - 1; + pVnode->fileId = pVnode->firstKey / tsMsPerDay[(uint8_t)pVnode->cfg.precision] / pCfg->daysPerFile; + pVnode->lastKeyOnFile = (int64_t)(pVnode->fileId + 1) * pCfg->daysPerFile * tsMsPerDay[(uint8_t)pVnode->cfg.precision] - 1; pVnode->numOfFiles = 1; if (vnodeCreateEmptyCompFile(vnode, pVnode->fileId) < 0) return -1; } - numOfFiles = (pVnode->lastKeyOnFile - pVnode->commitFirstKey) / tsMsPerDay[pVnode->cfg.precision] / pCfg->daysPerFile; + numOfFiles = (pVnode->lastKeyOnFile - pVnode->commitFirstKey) / tsMsPerDay[(uint8_t)pVnode->cfg.precision] / pCfg->daysPerFile; if (pVnode->commitFirstKey > pVnode->lastKeyOnFile) numOfFiles = -1; dTrace("vid:%d, commitFirstKey:%ld lastKeyOnFile:%ld numOfFiles:%d fileId:%d vnodeNumOfFiles:%d", pVnode->vnode, @@ -221,15 +221,15 @@ int vnodeCreateNeccessaryFiles(SVnodeObj *pVnode) { #else return -1; #endif - pVnode->lastKeyOnFile += (int64_t)tsMsPerDay[pVnode->cfg.precision] * pCfg->daysPerFile; + pVnode->lastKeyOnFile += (int64_t)tsMsPerDay[(uint8_t)pVnode->cfg.precision] * pCfg->daysPerFile; filesAdded = 1; numOfFiles = 0; // hacker way } fileId = pVnode->fileId - numOfFiles; pVnode->commitLastKey = - pVnode->lastKeyOnFile - (int64_t)numOfFiles * tsMsPerDay[pVnode->cfg.precision] * pCfg->daysPerFile; - pVnode->commitFirstKey = pVnode->commitLastKey - (int64_t)tsMsPerDay[pVnode->cfg.precision] * pCfg->daysPerFile + 1; + pVnode->lastKeyOnFile - (int64_t)numOfFiles * tsMsPerDay[(uint8_t)pVnode->cfg.precision] * pCfg->daysPerFile; + pVnode->commitFirstKey = pVnode->commitLastKey - (int64_t)tsMsPerDay[(uint8_t)pVnode->cfg.precision] * pCfg->daysPerFile + 1; pVnode->commitFileId = fileId; pVnode->numOfFiles = pVnode->numOfFiles + filesAdded; @@ -244,8 +244,7 @@ int vnodeOpenCommitFiles(SVnodeObj *pVnode, int noTempLast) { int len = 0; struct stat filestat; int vnode = pVnode->vnode; - int fileId, numOfFiles, filesAdded = 0; - SVnodeCfg * pCfg = &pVnode->cfg; + int fileId; if (vnodeCreateNeccessaryFiles(pVnode) < 0) return -1; @@ -1246,7 +1245,7 @@ int vnodeWriteBlockToFile(SMeterObj *pObj, SCompBlock *pCompBlock, SData *data[] // assert(data[i]->len == points*pObj->schema[i].bytes); if (pCfg->compression) { - cdata[i]->len = (*pCompFunc[pObj->schema[i].type])(data[i]->data, points * pObj->schema[i].bytes, points, + cdata[i]->len = (*pCompFunc[(uint8_t)pObj->schema[i].type])(data[i]->data, points * pObj->schema[i].bytes, points, cdata[i]->data, pObj->schema[i].bytes*pObj->pointsPerFileBlock+EXTRA_BYTES, pCfg->compression, buffer, bufferSize); fields[i].len = cdata[i]->len; @@ -1338,7 +1337,7 @@ int vnodeSearchPointInFile(SMeterObj *pObj, SQuery *pQuery) { if (pVnode->numOfFiles <= 0) return 0; SVnodeCfg *pCfg = &pVnode->cfg; - delta = (int64_t)pCfg->daysPerFile * tsMsPerDay[pVnode->cfg.precision]; + delta = (int64_t)pCfg->daysPerFile * tsMsPerDay[(uint8_t)pVnode->cfg.precision]; latest = pObj->lastKeyOnFile; oldest = (pVnode->fileId - pVnode->numOfFiles + 1) * delta; diff --git a/src/system/detail/src/vnodeImport.c b/src/system/detail/src/vnodeImport.c index f0019a92ee..83d40c84a6 100644 --- a/src/system/detail/src/vnodeImport.c +++ b/src/system/detail/src/vnodeImport.c @@ -146,7 +146,7 @@ int vnodeFindKeyInCache(SImportInfo *pImport, int order) { void vnodeGetValidDataRange(int vnode, TSKEY now, TSKEY *minKey, TSKEY *maxKey) { SVnodeObj *pVnode = vnodeList + vnode; - int64_t delta = pVnode->cfg.daysPerFile * tsMsPerDay[pVnode->cfg.precision]; + int64_t delta = pVnode->cfg.daysPerFile * tsMsPerDay[(uint8_t)pVnode->cfg.precision]; int fid = now / delta; *minKey = (fid - pVnode->maxFiles + 1) * delta; *maxKey = (fid + 2) * delta - 1; @@ -682,7 +682,7 @@ static int vnodeMergeDataIntoFile(SImportInfo *pImport, const char *payload, int SCacheInfo * pInfo = (SCacheInfo *)(pObj->pCache); TSKEY lastKeyImported = 0; - TSKEY delta = pVnode->cfg.daysPerFile * tsMsPerDay[pVnode->cfg.precision]; + TSKEY delta = pVnode->cfg.daysPerFile * tsMsPerDay[(uint8_t)pVnode->cfg.precision]; TSKEY minFileKey = fid * delta; TSKEY maxFileKey = minFileKey + delta - 1; TSKEY firstKey = KEY_AT_INDEX(payload, pObj->bytesPerPoint, 0); @@ -1499,7 +1499,7 @@ int vnodeImportDataToFiles(SImportInfo *pImport, char *payload, const int rows) SMeterObj *pObj = (SMeterObj *)(pImport->pObj); SVnodeObj *pVnode = vnodeList + pObj->vnode; - int64_t delta = pVnode->cfg.daysPerFile * tsMsPerDay[pVnode->cfg.precision]; + int64_t delta = pVnode->cfg.daysPerFile * tsMsPerDay[(uint8_t)pVnode->cfg.precision]; int sfid = KEY_AT_INDEX(payload, pObj->bytesPerPoint, 0) / delta; int efid = KEY_AT_INDEX(payload, pObj->bytesPerPoint, rows - 1) / delta; diff --git a/src/system/detail/src/vnodeMeter.c b/src/system/detail/src/vnodeMeter.c index 77bafd50d4..83897ed7f9 100644 --- a/src/system/detail/src/vnodeMeter.c +++ b/src/system/detail/src/vnodeMeter.c @@ -604,10 +604,10 @@ int vnodeInsertPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi TSKEY firstKey = *((TSKEY *)pData); TSKEY lastKey = *((TSKEY *)(pData + pObj->bytesPerPoint * (numOfPoints - 1))); - int cfid = now/pVnode->cfg.daysPerFile/tsMsPerDay[pVnode->cfg.precision]; + int cfid = now/pVnode->cfg.daysPerFile/tsMsPerDay[(uint8_t)pVnode->cfg.precision]; - TSKEY minAllowedKey = (cfid - pVnode->maxFiles + 1)*pVnode->cfg.daysPerFile*tsMsPerDay[pVnode->cfg.precision]; - TSKEY maxAllowedKey = (cfid + 2)*pVnode->cfg.daysPerFile*tsMsPerDay[pVnode->cfg.precision] - 2; + TSKEY minAllowedKey = (cfid - pVnode->maxFiles + 1)*pVnode->cfg.daysPerFile*tsMsPerDay[(uint8_t)pVnode->cfg.precision]; + TSKEY maxAllowedKey = (cfid + 2)*pVnode->cfg.daysPerFile*tsMsPerDay[(uint8_t)pVnode->cfg.precision] - 2; if (firstKey < minAllowedKey || firstKey > maxAllowedKey || lastKey < minAllowedKey || lastKey > maxAllowedKey) { dError("vid:%d sid:%d id:%s, vnode lastKeyOnFile:%lld, data is out of range, numOfPoints:%d firstKey:%lld lastKey:%lld minAllowedKey:%lld maxAllowedKey:%lld", pObj->vnode, pObj->sid, pObj->meterId, pVnode->lastKeyOnFile, numOfPoints,firstKey, lastKey, minAllowedKey, maxAllowedKey); @@ -634,7 +634,7 @@ int vnodeInsertPoints(SMeterObj *pObj, char *cont, int contLen, char source, voi continue; } - if (!VALID_TIMESTAMP(*((TSKEY *)pData), tsKey, pVnode->cfg.precision)) { + if (!VALID_TIMESTAMP(*((TSKEY *)pData), tsKey, (uint8_t)pVnode->cfg.precision)) { code = TSDB_CODE_TIMESTAMP_OUT_OF_RANGE; break; } diff --git a/src/system/detail/src/vnodeQueryImpl.c b/src/system/detail/src/vnodeQueryImpl.c index 5174753d82..219e903a43 100644 --- a/src/system/detail/src/vnodeQueryImpl.c +++ b/src/system/detail/src/vnodeQueryImpl.c @@ -1055,7 +1055,7 @@ static void *getGenericDataBlock(SMeterObj *pMeterObj, SQuery *pQuery, int32_t s static int32_t getFileIdFromKey(int32_t vid, TSKEY key) { SVnodeObj *pVnode = &vnodeList[vid]; - int64_t delta = (int64_t)pVnode->cfg.daysPerFile * tsMsPerDay[pVnode->cfg.precision]; + int64_t delta = (int64_t)pVnode->cfg.daysPerFile * tsMsPerDay[(uint8_t)pVnode->cfg.precision]; return (int32_t)(key / delta); // set the starting fileId } @@ -2227,7 +2227,7 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) { // get maximum time interval in each file static int64_t getOldestKey(int32_t numOfFiles, int64_t fileId, SVnodeCfg *pCfg) { - int64_t duration = pCfg->daysPerFile * tsMsPerDay[pCfg->precision]; + int64_t duration = pCfg->daysPerFile * tsMsPerDay[(uint8_t)pCfg->precision]; return (fileId - numOfFiles + 1) * duration; } @@ -6332,6 +6332,8 @@ int32_t setIntervalQueryExecutionContext(SMeterQuerySupportObj *pSupporter, int3 tsBufSetCursor(pSupporter->runtimeEnv.pTSBuf, &pMeterQueryInfo->cur); } } + + return 0; } static void doApplyIntervalQueryOnBlock(SMeterQuerySupportObj *pSupporter, SMeterQueryInfo *pInfo, diff --git a/src/util/src/tsocket.c b/src/util/src/tsocket.c index 6e8379c0a4..0ebee5a8f4 100644 --- a/src/util/src/tsocket.c +++ b/src/util/src/tsocket.c @@ -19,8 +19,6 @@ #include "tsocket.h" #include "tutil.h" -unsigned int ip2uint(const char *const ip_addr); - /* * Function to get the public ip address of current machine. If get IP * successfully, return 0, else, return -1. The return values is ip. @@ -105,7 +103,7 @@ int taosGetPublicIp(char *const ip) { } // Function converting an IP address string to an unsigned int. -unsigned int ip2uint(const char *const ip_addr) { +uint32_t ip2uint(const char *const ip_addr) { char ip_addr_cpy[20]; char ip[5]; From 5ff6e6337c19567852785fb934216f1746a30629 Mon Sep 17 00:00:00 2001 From: slguan Date: Mon, 9 Dec 2019 11:17:34 +0800 Subject: [PATCH 06/17] [TBASE-1299] --- src/inc/tutil.h | 4 ++-- src/kit/taosdemo/taosdemo.c | 2 -- src/rpc/src/trpc.c | 8 ++------ src/system/detail/src/dnodeSystem.c | 5 ----- src/system/detail/src/mgmtShell.c | 15 +++++---------- src/system/detail/src/vnodeMeter.c | 2 -- src/system/detail/src/vnodeRead.c | 12 +++++------- src/system/detail/src/vnodeShell.c | 5 ++--- src/system/detail/src/vnodeStore.c | 6 ------ src/system/detail/src/vnodeUtil.c | 2 -- 10 files changed, 16 insertions(+), 45 deletions(-) diff --git a/src/inc/tutil.h b/src/inc/tutil.h index 2e5e915019..0fd9d7e6c4 100644 --- a/src/inc/tutil.h +++ b/src/inc/tutil.h @@ -37,8 +37,8 @@ extern "C" { #define tfree(x) \ { \ if (x) { \ - free(x); \ - x = NULL; \ + free((void*)(x)); \ + x = 0; \ } \ } diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 37530e1e8c..22aa71bf6c 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -33,8 +33,6 @@ extern char configDir[]; -#pragma GCC diagnostic ignored "-Wmissing-braces" - #define BUFFER_SIZE 65536 #define MAX_DB_NAME_SIZE 64 #define MAX_TB_NAME_SIZE 64 diff --git a/src/rpc/src/trpc.c b/src/rpc/src/trpc.c index 4aa3e12cf1..04ef809b8e 100755 --- a/src/rpc/src/trpc.c +++ b/src/rpc/src/trpc.c @@ -246,9 +246,7 @@ char *taosBuildReqHeader(void *param, char type, char *msg) { pHeader->destId = pConn->peerId; pHeader->port = 0; -#pragma GCC diagnostic ignored "-Wpointer-to-int-cast" - pHeader->uid = (uint32_t)pConn + (uint32_t)getpid(); -#pragma GCC diagnostic warning "-Wpointer-to-int-cast" + pHeader->uid = (uint32_t)((int64_t)pConn + (int64_t)getpid()); memcpy(pHeader->meterId, pConn->meterId, tListLen(pHeader->meterId)); @@ -280,9 +278,7 @@ char *taosBuildReqMsgWithSize(void *param, char type, int size) { pHeader->sourceId = pConn->ownId; pHeader->destId = pConn->peerId; -#pragma GCC diagnostic ignored "-Wpointer-to-int-cast" - pHeader->uid = (uint32_t)pConn + (uint32_t)getpid(); -#pragma GCC diagnostic warning "-Wpointer-to-int-cast" + pHeader->uid = (uint32_t)((int64_t)pConn + (int64_t)getpid()); memcpy(pHeader->meterId, pConn->meterId, tListLen(pHeader->meterId)); diff --git a/src/system/detail/src/dnodeSystem.c b/src/system/detail/src/dnodeSystem.c index 05a7bef486..1ebeeec061 100644 --- a/src/system/detail/src/dnodeSystem.c +++ b/src/system/detail/src/dnodeSystem.c @@ -26,9 +26,6 @@ #include "tglobalcfg.h" #include "vnode.h" -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Woverflow" - SModule tsModule[TSDB_MOD_MAX] = {0}; uint32_t tsModuleStatus = 0; pthread_mutex_t dmutex; @@ -219,5 +216,3 @@ void dnodeCountRequest(SCountInfo *info) { info->selectReqNum = atomic_exchange_32(&vnodeSelectReqNum, 0); info->insertReqNum = atomic_exchange_32(&vnodeInsertReqNum, 0); } - -#pragma GCC diagnostic pop \ No newline at end of file diff --git a/src/system/detail/src/mgmtShell.c b/src/system/detail/src/mgmtShell.c index 97e8d94fdc..d00f4eaf06 100644 --- a/src/system/detail/src/mgmtShell.c +++ b/src/system/detail/src/mgmtShell.c @@ -23,12 +23,6 @@ #include "tlog.h" #include "tstatus.h" -#pragma GCC diagnostic push - -#pragma GCC diagnostic ignored "-Woverflow" -#pragma GCC diagnostic ignored "-Wpointer-sign" -#pragma GCC diagnostic ignored "-Wint-conversion" - #define MAX_LEN_OF_METER_META (sizeof(SMultiMeterMeta) + sizeof(SSchema) * TSDB_MAX_COLUMNS + sizeof(SSchema) * TSDB_MAX_TAGS + TSDB_MAX_TAGS_LEN) void * pShellConn = NULL; @@ -695,7 +689,7 @@ int mgmtProcessAlterUserMsg(char *pMsg, int msgLen, SConnObj *pConn) { (strcmp(pConn->pUser->user, "root") == 0)) { if ((pAlter->flag & TSDB_ALTER_USER_PASSWD) != 0) { memset(pUser->pass, 0, sizeof(pUser->pass)); - taosEncryptPass(pAlter->pass, strlen(pAlter->pass), pUser->pass); + taosEncryptPass((uint8_t *)pAlter->pass, strlen(pAlter->pass), pUser->pass); } if ((pAlter->flag & TSDB_ALTER_USER_PRIVILEGES) != 0) { if (pAlter->privilege == 1) { // super @@ -931,7 +925,7 @@ int mgmtProcessRetrieveMsg(char *pMsg, int msgLen, SConnObj *pConn) { taosSendMsgToPeer(pConn->thandle, pStart, msgLen); if (rowsToRead == 0) { - uintptr_t oldSign = atomic_val_compare_exchange_ptr(&pShow->signature, pShow, 0); + uintptr_t oldSign = (uintptr_t)atomic_val_compare_exchange_ptr(&pShow->signature, pShow, 0); if (oldSign != (uintptr_t)pShow) { return msgLen; } @@ -1139,8 +1133,9 @@ void mgmtEstablishConn(SConnObj *pConn) { } } - uint32_t temp; - taosGetRpcConnInfo(pConn->thandle, &temp, &pConn->ip, &pConn->port, &temp, &temp); + int32_t tempint32; + uint32_t tempuint32; + taosGetRpcConnInfo(pConn->thandle, &tempuint32, &pConn->ip, &pConn->port, &tempint32, &tempint32); mgmtAddConnIntoAcct(pConn); } diff --git a/src/system/detail/src/vnodeMeter.c b/src/system/detail/src/vnodeMeter.c index 83897ed7f9..7860a886c5 100644 --- a/src/system/detail/src/vnodeMeter.c +++ b/src/system/detail/src/vnodeMeter.c @@ -26,8 +26,6 @@ #include "vnodeUtil.h" #include "tstatus.h" -#pragma GCC diagnostic ignored "-Wpointer-sign" - #define VALID_TIMESTAMP(key, curKey, prec) (((key) >= 0) && ((key) <= ((curKey) + 36500 * tsMsPerDay[prec]))) int tsMeterSizeOnFile; diff --git a/src/system/detail/src/vnodeRead.c b/src/system/detail/src/vnodeRead.c index d6f0796121..21e83c5198 100644 --- a/src/system/detail/src/vnodeRead.c +++ b/src/system/detail/src/vnodeRead.c @@ -26,8 +26,6 @@ #include "vnodeRead.h" #include "vnodeUtil.h" -#pragma GCC diagnostic ignored "-Wint-conversion" - int (*pQueryFunc[])(SMeterObj *, SQuery *) = {vnodeQueryFromCache, vnodeQueryFromFile}; int vnodeInterpolationSearchKey(char *pValue, int num, TSKEY key, int order) { @@ -1003,8 +1001,9 @@ int32_t vnodeConvertQueryMeterMsg(SQueryMeterMsg *pQueryMsg) { if (pDestFilterInfo->filterOnBinary) { pDestFilterInfo->len = htobe64(pFilterInfo->len); - pDestFilterInfo->pz = calloc(1, pDestFilterInfo->len + 1); - memcpy(pDestFilterInfo->pz, pMsg, pDestFilterInfo->len + 1); + + pDestFilterInfo->pz = (int64_t)calloc(1, pDestFilterInfo->len + 1); + memcpy((void*)pDestFilterInfo->pz, pMsg, pDestFilterInfo->len + 1); pMsg += (pDestFilterInfo->len + 1); } else { pDestFilterInfo->lowerBndi = htobe64(pFilterInfo->lowerBndi); @@ -1022,8 +1021,7 @@ int32_t vnodeConvertQueryMeterMsg(SQueryMeterMsg *pQueryMsg) { * 1. simple projection query on meters, we only record the pSqlFuncExprs[i].colIdx value * 2. for complex queries, whole SqlExprs object is required. */ - pQueryMsg->pSqlFuncExprs = malloc(POINTER_BYTES * pQueryMsg->numOfOutputCols); - + pQueryMsg->pSqlFuncExprs = (int64_t)malloc(POINTER_BYTES * pQueryMsg->numOfOutputCols); SSqlFuncExprMsg *pExprMsg = (SSqlFuncExprMsg *)pMsg; for (int32_t i = 0; i < pQueryMsg->numOfOutputCols; ++i) { @@ -1070,7 +1068,7 @@ int32_t vnodeConvertQueryMeterMsg(SQueryMeterMsg *pQueryMsg) { pQueryMsg->colNameLen = htonl(pQueryMsg->colNameLen); if (hasArithmeticFunction) { // column name array assert(pQueryMsg->colNameLen > 0); - pQueryMsg->colNameList = pMsg; + pQueryMsg->colNameList = (int64_t)pMsg; pMsg += pQueryMsg->colNameLen; } diff --git a/src/system/detail/src/vnodeShell.c b/src/system/detail/src/vnodeShell.c index 512f675da4..2bac2eed2c 100644 --- a/src/system/detail/src/vnodeShell.c +++ b/src/system/detail/src/vnodeShell.c @@ -30,7 +30,6 @@ #include "vnodeStore.h" #include "tstatus.h" -#pragma GCC diagnostic ignored "-Wint-conversion" extern int tsMaxQueues; void * pShellServer = NULL; @@ -390,7 +389,7 @@ _query_over: tfree(pMeterObjList); ret = vnodeSendQueryRspMsg(pObj, code, pObj->qhandle); - free(pQueryMsg->pSidExtInfo); + tfree(pQueryMsg->pSidExtInfo); for(int32_t i = 0; i < pQueryMsg->numOfCols; ++i) { vnodeFreeColumnInfo(&pQueryMsg->colList[i]); } @@ -455,7 +454,7 @@ void vnodeExecuteRetrieveReq(SSchedMsg *pSched) { pRsp->precision = htons(timePrec); if (code == TSDB_CODE_SUCCESS) { - pRsp->offset = htobe64(vnodeGetOffsetVal(pRetrieve->qhandle)); + pRsp->offset = htobe64(vnodeGetOffsetVal((void*)pRetrieve->qhandle)); pRsp->useconds = htobe64(((SQInfo *)(pRetrieve->qhandle))->useconds); } else { pRsp->offset = 0; diff --git a/src/system/detail/src/vnodeStore.c b/src/system/detail/src/vnodeStore.c index f2617f09b6..13f64ecf68 100644 --- a/src/system/detail/src/vnodeStore.c +++ b/src/system/detail/src/vnodeStore.c @@ -24,9 +24,6 @@ #include "vnodeUtil.h" #include "tstatus.h" -#pragma GCC diagnostic push -#pragma GCC diagnostic warning "-Woverflow" - int tsMaxVnode = -1; int tsOpenVnodes = 0; SVnodeObj *vnodeList = NULL; @@ -386,6 +383,3 @@ void vnodeCalcOpenVnodes() { void vnodeUpdateHeadFile(int vnode, int oldTables, int newTables) { //todo rewrite the head file with newTables } - -#pragma GCC diagnostic pop - diff --git a/src/system/detail/src/vnodeUtil.c b/src/system/detail/src/vnodeUtil.c index 68e1e428c0..f8a4d3efb0 100644 --- a/src/system/detail/src/vnodeUtil.c +++ b/src/system/detail/src/vnodeUtil.c @@ -23,8 +23,6 @@ #include "vnodeDataFilterFunc.h" #include "vnodeUtil.h" -#pragma GCC diagnostic ignored "-Wint-conversion" - int vnodeCheckFileIntegrity(FILE* fp) { /* int savedSessions, savedMeterSize; From 5ef542368eefa8ec6b167e47761ad30d389656e5 Mon Sep 17 00:00:00 2001 From: slguan Date: Mon, 9 Dec 2019 11:43:25 +0800 Subject: [PATCH 07/17] [TBASE-1299] --- src/client/src/tscFunctionImpl.c | 2 -- src/client/src/tscParseInsert.c | 3 --- src/client/src/tscSQLParser.c | 2 -- src/system/detail/inc/mgmt.h | 2 +- src/system/detail/src/mgmtShell.c | 2 -- src/system/lite/src/dnodeMgmt.spec.c | 4 ++-- src/system/lite/src/mgmtBalance.spec.c | 2 +- src/system/lite/src/mgmtDnodeInt.spec.c | 4 ++-- src/system/lite/src/vnodeFile.spec.c | 2 +- src/util/src/tcompression.c | 16 ++++++++-------- src/util/src/tcrc32c.c | 2 -- src/util/src/textbuffer.c | 2 -- src/util/src/ttokenizer.c | 8 ++++---- 13 files changed, 19 insertions(+), 32 deletions(-) diff --git a/src/client/src/tscFunctionImpl.c b/src/client/src/tscFunctionImpl.c index 2d913b2f20..de7716db4d 100644 --- a/src/client/src/tscFunctionImpl.c +++ b/src/client/src/tscFunctionImpl.c @@ -13,8 +13,6 @@ * along with this program. If not, see . */ -#pragma GCC diagnostic ignored "-Wincompatible-pointer-types" - #include "os.h" #include "taosmsg.h" #include "tast.h" diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 6317decbe0..bf2b88c995 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -18,9 +18,6 @@ #define _XOPEN_SOURCE -#pragma GCC diagnostic ignored "-Woverflow" -#pragma GCC diagnostic ignored "-Wunused-variable" - #include "os.h" #include "ihash.h" #include "tscSecondaryMerge.h" diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 752c5d123f..1bd710f2fb 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -28,8 +28,6 @@ #include "tsclient.h" #include "tscSQLParser.h" -#pragma GCC diagnostic ignored "-Wunused-variable" - #define DEFAULT_PRIMARY_TIMESTAMP_COL_NAME "_c0" // -1 is tbname column index, so here use the -2 as the initial value diff --git a/src/system/detail/inc/mgmt.h b/src/system/detail/inc/mgmt.h index 75ec841076..c75422e23e 100644 --- a/src/system/detail/inc/mgmt.h +++ b/src/system/detail/inc/mgmt.h @@ -419,7 +419,7 @@ void mgmtCleanupBalance(); int mgmtAllocVnodes(SVgObj *pVgroup); void mgmtSetDnodeShellRemoving(SDnodeObj *pDnode); void mgmtSetDnodeUnRemove(SDnodeObj *pDnode); -void mgmtStartBalanceTimer(int mseconds); +void mgmtStartBalanceTimer(int64_t mseconds); void mgmtSetDnodeOfflineOnSdbChanged(); void mgmtUpdateVgroupState(SVgObj *pVgroup, int lbStatus, int srcIp); bool mgmtAddVnode(SVgObj *pVgroup, SDnodeObj *pSrcDnode, SDnodeObj *pDestDnode); diff --git a/src/system/detail/src/mgmtShell.c b/src/system/detail/src/mgmtShell.c index d00f4eaf06..f6b2d7ba9b 100644 --- a/src/system/detail/src/mgmtShell.c +++ b/src/system/detail/src/mgmtShell.c @@ -1363,5 +1363,3 @@ void mgmtInitProcessShellMsg() { mgmtProcessShellMsg[TSDB_MSG_TYPE_KILL_STREAM] = mgmtProcessKillStreamMsg; mgmtProcessShellMsg[TSDB_MSG_TYPE_KILL_CONNECTION] = mgmtProcessKillConnectionMsg; } - -#pragma GCC diagnostic pop diff --git a/src/system/lite/src/dnodeMgmt.spec.c b/src/system/lite/src/dnodeMgmt.spec.c index e40b21ab83..576dbcb337 100644 --- a/src/system/lite/src/dnodeMgmt.spec.c +++ b/src/system/lite/src/dnodeMgmt.spec.c @@ -50,7 +50,7 @@ char *taosBuildReqMsgToMnode(SMgmtObj *pObj, char type) { } int taosSendMsgToMnode(SMgmtObj *pObj, char *msg, int msgLen) { - dTrace("msg:%s is sent to mnode", taosMsg[*(msg-1)]); + dTrace("msg:%s is sent to mnode", taosMsg[(uint8_t)(*(msg-1))]); /* * Lite version has no message header, so minus one @@ -81,7 +81,7 @@ void vnodeProcessMsgFromMgmtSpec(SSchedMsg *sched) { char msgType = *sched->msg; char *content = sched->msg + 1; - dTrace("msg:%s is received from mgmt", taosMsg[msgType]); + dTrace("msg:%s is received from mgmt", taosMsg[(uint8_t)msgType]); vnodeProcessMsgFromMgmt(content, 0, msgType, 0); diff --git a/src/system/lite/src/mgmtBalance.spec.c b/src/system/lite/src/mgmtBalance.spec.c index 3d2f10dcbb..109f36af18 100644 --- a/src/system/lite/src/mgmtBalance.spec.c +++ b/src/system/lite/src/mgmtBalance.spec.c @@ -17,7 +17,7 @@ #include "mgmtBalance.h" #include "tstatus.h" -void mgmtStartBalanceTimer(int mseconds) {} +void mgmtStartBalanceTimer(int64_t mseconds) {} int mgmtInitBalance() { return 0; } diff --git a/src/system/lite/src/mgmtDnodeInt.spec.c b/src/system/lite/src/mgmtDnodeInt.spec.c index b99815844d..a914d630c2 100644 --- a/src/system/lite/src/mgmtDnodeInt.spec.c +++ b/src/system/lite/src/mgmtDnodeInt.spec.c @@ -61,7 +61,7 @@ char *taosBuildReqMsgToDnode(SDnodeObj *pObj, char type) { int taosSendSimpleRspToDnode(SDnodeObj *pObj, char rsptype, char code) { return 0; } int taosSendMsgToDnode(SDnodeObj *pObj, char *msg, int msgLen) { - mTrace("msg:%s is sent to dnode", taosMsg[*(msg-1)]); + mTrace("msg:%s is sent to dnode", taosMsg[(uint8_t)(*(msg-1))]); /* * Lite version has no message header, so minus one @@ -142,7 +142,7 @@ void mgmtProcessDnodeStatus(void *handle, void *tmrId) { void mgmtProcessMsgFromDnodeSpec(SSchedMsg *sched) { char msgType = *sched->msg; char *content = sched->msg + 1; - mTrace("msg:%s is received from dnode", taosMsg[msgType]); + mTrace("msg:%s is received from dnode", taosMsg[(uint8_t)msgType]); mgmtProcessMsgFromDnode(content, 0, msgType, mgmtGetDnode(0)); free(sched->msg); diff --git a/src/system/lite/src/vnodeFile.spec.c b/src/system/lite/src/vnodeFile.spec.c index 7b26ed6c9f..4ad624d2ad 100644 --- a/src/system/lite/src/vnodeFile.spec.c +++ b/src/system/lite/src/vnodeFile.spec.c @@ -24,7 +24,7 @@ char* vnodeGetDataDir(int vnode, int fileId) { return dataDir; } void vnodeAdustVnodeFile(SVnodeObj *pVnode) { // Retention policy here int fileId = pVnode->fileId - pVnode->numOfFiles + 1; - int cfile = taosGetTimestamp(pVnode->cfg.precision)/pVnode->cfg.daysPerFile/tsMsPerDay[pVnode->cfg.precision]; + int cfile = taosGetTimestamp(pVnode->cfg.precision)/pVnode->cfg.daysPerFile/tsMsPerDay[(uint8_t)pVnode->cfg.precision]; while (fileId <= cfile - pVnode->maxFiles) { vnodeRemoveFile(pVnode->vnode, fileId); pVnode->numOfFiles--; diff --git a/src/util/src/tcompression.c b/src/util/src/tcompression.c index 1ac42377fb..2425bc4d24 100644 --- a/src/util/src/tcompression.c +++ b/src/util/src/tcompression.c @@ -355,16 +355,16 @@ int tsCompressINTImp(const char *const input, const int nelements, char *const o tmp_bit = (LONG_BYTES * BITS_PER_BYTE) - BUILDIN_CLZL(zigzag_value); } - if (elems + 1 <= selector_to_elems[selector] && elems + 1 <= selector_to_elems[bit_to_selector[tmp_bit]]) { + if (elems + 1 <= selector_to_elems[(uint8_t)selector] && elems + 1 <= selector_to_elems[(uint8_t)bit_to_selector[(uint8_t)tmp_bit]]) { // If can hold another one. - selector = selector > bit_to_selector[tmp_bit] ? selector : bit_to_selector[tmp_bit]; + selector = selector > bit_to_selector[(uint8_t)tmp_bit] ? selector : bit_to_selector[(uint8_t)tmp_bit]; elems++; - bit = bit_per_integer[selector]; + bit = bit_per_integer[(uint8_t)selector]; } else { // if cannot hold another one. - while (elems < selector_to_elems[selector]) selector++; - elems = selector_to_elems[selector]; - bit = bit_per_integer[selector]; + while (elems < selector_to_elems[(uint8_t)selector]) selector++; + elems = selector_to_elems[(uint8_t)selector]; + bit = bit_per_integer[(uint8_t)selector]; break; } prev_value_tmp = curr_value; @@ -455,8 +455,8 @@ int tsDecompressINTImp(const char *const input, const int nelements, char *const memcpy(&w, ip, LONG_BYTES); char selector = (char)(w & INT64MASK(4)); // selector = 4 - char bit = bit_per_integer[selector]; // bit = 3 - int elems = selector_to_elems[selector]; + char bit = bit_per_integer[(uint8_t)selector]; // bit = 3 + int elems = selector_to_elems[(uint8_t)selector]; for (int i = 0; i < elems; i++) { uint64_t zigzag_value; diff --git a/src/util/src/tcrc32c.c b/src/util/src/tcrc32c.c index c67773f1ca..546693c4bb 100644 --- a/src/util/src/tcrc32c.c +++ b/src/util/src/tcrc32c.c @@ -25,8 +25,6 @@ #include #include "tcrc32c.h" -//todo : use the original source code -//#pragma GCC diagnostic ignored "-Wunused-function" #define POLY 0x82f63b78 #define LONG_SHIFT 8192 diff --git a/src/util/src/textbuffer.c b/src/util/src/textbuffer.c index 42c2cc1ed0..984164bfd2 100644 --- a/src/util/src/textbuffer.c +++ b/src/util/src/textbuffer.c @@ -23,8 +23,6 @@ #include "ttypes.h" #include "tutil.h" -//#pragma GCC diagnostic ignored "-Wformat" - #define COLMODEL_GET_VAL(data, schema, allrow, rowId, colId) \ (data + (schema)->colOffset[colId] * (allrow) + (rowId) * (schema)->pFields[colId].bytes) diff --git a/src/util/src/ttokenizer.c b/src/util/src/ttokenizer.c index f402963049..d23b0ab27c 100644 --- a/src/util/src/ttokenizer.c +++ b/src/util/src/ttokenizer.c @@ -510,7 +510,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) { if ((z[i] == 'a' || z[i] == 's' || z[i] == 'm' || z[i] == 'h' || z[i] == 'd' || z[i] == 'n' || z[i] == 'y' || z[i] == 'w' || z[i] == 'A' || z[i] == 'S' || z[i] == 'M' || z[i] == 'H' || z[i] == 'D' || z[i] == 'N' || z[i] == 'Y' || z[i] == 'W') && - (isIdChar[z[i + 1]] == 0)) { + (isIdChar[(uint8_t)z[i + 1]] == 0)) { *tokenType = TK_VARIABLE; i += 1; return i; @@ -551,7 +551,7 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) { case 't': case 'F': case 'f': { - for (i = 1; ((z[i] & 0x80) == 0) && isIdChar[z[i]]; i++) { + for (i = 1; ((z[i] & 0x80) == 0) && isIdChar[(uint8_t)z[i]]; i++) { } if ((i == 4 && strncasecmp(z, "true", 4) == 0) || (i == 5 && strncasecmp(z, "false", 5) == 0)) { @@ -560,10 +560,10 @@ uint32_t tSQLGetToken(char* z, uint32_t* tokenType) { } } default: { - if (((*z & 0x80) != 0) || !isIdChar[*z]) { + if (((*z & 0x80) != 0) || !isIdChar[(uint8_t)(*z)]) { break; } - for (i = 1; ((z[i] & 0x80) == 0) && isIdChar[z[i]]; i++) { + for (i = 1; ((z[i] & 0x80) == 0) && isIdChar[(uint8_t)z[i]]; i++) { } *tokenType = tSQLKeywordCode(z, i); return i; From 2e2e8beacb0c66c7f9f11af00e4df1c936f1ca75 Mon Sep 17 00:00:00 2001 From: fang Date: Mon, 9 Dec 2019 11:49:03 +0800 Subject: [PATCH 08/17] solve static check questions --- src/client/src/tscSecondaryMerge.c | 6 ++++-- src/client/src/tscServer.c | 1 + src/client/src/tscSystem.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/client/src/tscSecondaryMerge.c b/src/client/src/tscSecondaryMerge.c index 5eebddca73..737c1342d8 100644 --- a/src/client/src/tscSecondaryMerge.c +++ b/src/client/src/tscSecondaryMerge.c @@ -1314,8 +1314,10 @@ int32_t tscLocalDoReduce(SSqlObj *pSql) { tscTrace("%s call the drop local reducer", __FUNCTION__); tscDestroyLocalReducer(pSql); - pRes->numOfRows = 0; - pRes->row = 0; + if (pRes) { + pRes->numOfRows = 0; + pRes->row = 0; + } return 0; } diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 1805eac38d..ed21a82be1 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -2312,6 +2312,7 @@ int tscBuildCreateTableMsg(SSqlObj *pSql) { size = tscEstimateCreateTableMsgLength(pSql); if (TSDB_CODE_SUCCESS != tscAllocPayload(pCmd, size)) { tscError("%p failed to malloc for create table msg", pSql); + free(tmpData); return -1; } diff --git a/src/client/src/tscSystem.c b/src/client/src/tscSystem.c index 60b90ac328..2ebd1cfc51 100644 --- a/src/client/src/tscSystem.c +++ b/src/client/src/tscSystem.c @@ -230,7 +230,7 @@ static int taos_options_imp(TSDB_OPTION option, const char *pStr) { return -1; } - if (cfg && cfg && cfg->cfgStatus <= TSDB_CFG_CSTATUS_OPTION) { + if (cfg && cfg->cfgStatus <= TSDB_CFG_CSTATUS_OPTION) { char sep = '.'; if (strlen(tsLocale) == 0) { // locale does not set yet From cf014abd96d123a2ce243b9663ab22c1b22c330e Mon Sep 17 00:00:00 2001 From: fang Date: Mon, 9 Dec 2019 13:09:32 +0800 Subject: [PATCH 09/17] solve some static check questions for shell/src/ --- src/kit/shell/src/shellEngine.c | 3 +++ src/kit/shell/src/shellLinux.c | 11 ++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index c66f6f4be7..ed3b71bfcd 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -780,6 +780,7 @@ void source_file(TAOS *con, char *fptr) { if (wordexp(fptr, &full_path, 0) != 0) { fprintf(stderr, "ERROR: illegal file name\n"); + free(cmd); return; } @@ -788,6 +789,7 @@ void source_file(TAOS *con, char *fptr) { if (access(fname, R_OK) == -1) { fprintf(stderr, "ERROR: file %s is not readable\n", fptr); wordfree(&full_path); + free(cmd); return; } @@ -795,6 +797,7 @@ void source_file(TAOS *con, char *fptr) { if (f == NULL) { fprintf(stderr, "ERROR: failed to open file %s\n", fname); wordfree(&full_path); + free(cmd); return; } diff --git a/src/kit/shell/src/shellLinux.c b/src/kit/shell/src/shellLinux.c index ad8bf6c5c3..2e2c44af1a 100644 --- a/src/kit/shell/src/shellLinux.c +++ b/src/kit/shell/src/shellLinux.c @@ -277,7 +277,10 @@ void *shellLoopQuery(void *arg) { pthread_cleanup_push(cleanup_handler, NULL); char *command = malloc(MAX_COMMAND_SIZE); - + if (command == NULL){ + tscError("failed to malloc command"); + return NULL; + } while (1) { // Read command from shell. @@ -286,10 +289,8 @@ void *shellLoopQuery(void *arg) { shellReadCommand(con, command); reset_terminal_mode(); - if (command != NULL) { - // Run the command - shellRunCommand(con, command); - } + // Run the command + shellRunCommand(con, command); } pthread_cleanup_pop(1); From 966623a69275fac4524edb379752b8032379300f Mon Sep 17 00:00:00 2001 From: fang Date: Mon, 9 Dec 2019 13:29:34 +0800 Subject: [PATCH 10/17] slove some static check questions for http modules --- src/modules/http/src/gcJson.c | 2 +- src/modules/http/src/restJson.c | 2 +- src/modules/http/src/tgHandle.c | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/http/src/gcJson.c b/src/modules/http/src/gcJson.c index 0cb20ec7e1..ecd9235644 100644 --- a/src/modules/http/src/gcJson.c +++ b/src/modules/http/src/gcJson.c @@ -119,7 +119,7 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, cmd->numOfRows += numOfRows; } - for (int i = 0; i < numOfRows; ++i) { + for (int k = 0; k < numOfRows; ++k) { TAOS_ROW row = taos_fetch_row(result); // for group by diff --git a/src/modules/http/src/restJson.c b/src/modules/http/src/restJson.c index 8aa0ac5069..6c04d39f45 100644 --- a/src/modules/http/src/restJson.c +++ b/src/modules/http/src/restJson.c @@ -94,7 +94,7 @@ bool restBuildSqlJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, int num_fields = taos_num_fields(result); TAOS_FIELD *fields = taos_fetch_fields(result); - for (int i = 0; i < numOfRows; ++i) { + for (int k = 0; k < numOfRows; ++k) { TAOS_ROW row = taos_fetch_row(result); // data row array begin diff --git a/src/modules/http/src/tgHandle.c b/src/modules/http/src/tgHandle.c index ac17d6da09..80a178c776 100644 --- a/src/modules/http/src/tgHandle.c +++ b/src/modules/http/src/tgHandle.c @@ -262,6 +262,8 @@ int tgReadSchema(const char *fileName) { size_t result = fread(content, 1, contentSize, fp); if (result != contentSize) { httpError("failed to read telegraf schema file:%s", fileName); + fclose(fp); + free(content); return -1; } From 2e0929f163655c2aa3071a0ed5b885cde55e9972 Mon Sep 17 00:00:00 2001 From: fang Date: Mon, 9 Dec 2019 13:57:25 +0800 Subject: [PATCH 11/17] solve some static check questions for os/linux/src --- src/os/linux/src/tsystem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/os/linux/src/tsystem.c b/src/os/linux/src/tsystem.c index 03192bb9cc..0a9d97b3cf 100644 --- a/src/os/linux/src/tsystem.c +++ b/src/os/linux/src/tsystem.c @@ -124,7 +124,7 @@ bool taosGetSysCpuInfo(SysCpuInfo *cpuInfo) { } char cpu[10] = {0}; - sscanf(line, "%s %ld %ld %ld %ld", cpu, &cpuInfo->user, &cpuInfo->nice, &cpuInfo->system, &cpuInfo->idle); + sscanf(line, "%s %lu %lu %lu %lu", cpu, &cpuInfo->user, &cpuInfo->nice, &cpuInfo->system, &cpuInfo->idle); tfree(line); fclose(fp); @@ -150,7 +150,7 @@ bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) { for (int i = 0, blank = 0; line[i] != 0; ++i) { if (line[i] == ' ') blank++; if (blank == PROCESS_ITEM) { - sscanf(line + i + 1, "%ld %ld %ld %ld", &cpuInfo->utime, &cpuInfo->stime, &cpuInfo->cutime, &cpuInfo->cstime); + sscanf(line + i + 1, "%lu %lu %lu %lu", &cpuInfo->utime, &cpuInfo->stime, &cpuInfo->cutime, &cpuInfo->cstime); break; } } From 6e473f1ef1da25b61439a6397dcccc30df0295ee Mon Sep 17 00:00:00 2001 From: fang Date: Mon, 9 Dec 2019 15:12:48 +0800 Subject: [PATCH 12/17] solve some static check questions --- src/system/detail/src/mgmtVgroup.c | 1 + src/system/detail/src/vnodeQueryImpl.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/system/detail/src/mgmtVgroup.c b/src/system/detail/src/mgmtVgroup.c index e3bed57b33..2bc1801a68 100644 --- a/src/system/detail/src/mgmtVgroup.c +++ b/src/system/detail/src/mgmtVgroup.c @@ -289,6 +289,7 @@ int mgmtRetrieveVgroups(SShowObj *pShow, char *data, int rows, SConnObj *pConn) SDbObj *pDb = NULL; if (pConn->pDb != NULL) pDb = mgmtGetDb(pConn->pDb->name); + assert(pDb != NULL); pVgroup = pDb->pHead; while (pVgroup != NULL) { diff --git a/src/system/detail/src/vnodeQueryImpl.c b/src/system/detail/src/vnodeQueryImpl.c index 5174753d82..d5809d1b72 100644 --- a/src/system/detail/src/vnodeQueryImpl.c +++ b/src/system/detail/src/vnodeQueryImpl.c @@ -4555,8 +4555,7 @@ static void doMerge(SQueryRuntimeEnv *pRuntimeEnv, int64_t timestamp, tFilePage } static void printBinaryData(int32_t functionId, char *data, int32_t srcDataType) { - if (functionId == TSDB_FUNC_FIRST_DST || functionId == TSDB_FUNC_LAST_DST || functionId == TSDB_FUNC_FIRST_DST || - functionId == TSDB_FUNC_LAST_DST) { + if (functionId == TSDB_FUNC_FIRST_DST || functionId == TSDB_FUNC_LAST_DST) { switch (srcDataType) { case TSDB_DATA_TYPE_BINARY: printf("%ld,%s\t", *(TSKEY *)data, (data + TSDB_KEYSIZE + 1)); From 29356bae617a157666a124720ffc75d0a485f421 Mon Sep 17 00:00:00 2001 From: lihui Date: Mon, 9 Dec 2019 17:45:16 +0800 Subject: [PATCH 13/17] [TBASE-1319] --- packaging/release.sh | 1 + src/inc/tglobalcfg.h | 1 + src/system/detail/src/dnodeService.c | 1 + src/util/src/tglobalcfg.c | 3 +++ src/util/src/version.c | 5 +++-- 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packaging/release.sh b/packaging/release.sh index 0c806a159f..70f7af652f 100755 --- a/packaging/release.sh +++ b/packaging/release.sh @@ -109,6 +109,7 @@ build_time=$(date +"%F %R") echo "char version[64] = \"${version}\";" > ${versioninfo} echo "char compatible_version[64] = \"${compatible_version}\";" >> ${versioninfo} echo "char gitinfo[128] = \"$(git rev-parse --verify HEAD)\";" >> ${versioninfo} +echo "char gitinfoOfInternal[128] = \"\";" >> ${versioninfo} echo "char buildinfo[512] = \"Built by ${USER} at ${build_time}\";" >> ${versioninfo} # 2. cmake executable file diff --git a/src/inc/tglobalcfg.h b/src/inc/tglobalcfg.h index ed91964d61..def7fb9a67 100644 --- a/src/inc/tglobalcfg.h +++ b/src/inc/tglobalcfg.h @@ -179,6 +179,7 @@ extern int tsUdpDelay; extern char version[]; extern char compatible_version[]; extern char gitinfo[]; +extern char gitinfoOfInternal[]; extern char buildinfo[]; extern char tsTimezone[64]; diff --git a/src/system/detail/src/dnodeService.c b/src/system/detail/src/dnodeService.c index f03bd5f3bb..2de60bda91 100644 --- a/src/system/detail/src/dnodeService.c +++ b/src/system/detail/src/dnodeService.c @@ -62,6 +62,7 @@ int main(int argc, char *argv[]) { #endif printf("gitinfo: %s\n", gitinfo); + printf("gitinfoI: %s\n", gitinfoOfInternal); printf("buildinfo: %s\n", buildinfo); return 0; } else if (strcmp(argv[i], "-k") == 0) { diff --git a/src/util/src/tglobalcfg.c b/src/util/src/tglobalcfg.c index 80f76a3d25..a3b2ba151d 100644 --- a/src/util/src/tglobalcfg.c +++ b/src/util/src/tglobalcfg.c @@ -788,6 +788,9 @@ static void doInitGlobalConfig() { tsInitConfigOption(cfg++, "gitinfo", gitinfo, TSDB_CFG_VTYPE_STRING, TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT, 0, 0, 0, TSDB_CFG_UTYPE_NONE); + tsInitConfigOption(cfg++, "gitinfoOfInternal", gitinfoOfInternal, TSDB_CFG_VTYPE_STRING, + TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT, + 0, 0, 0, TSDB_CFG_UTYPE_NONE); tsInitConfigOption(cfg++, "buildinfo", buildinfo, TSDB_CFG_VTYPE_STRING, TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT, 0, 0, 0, TSDB_CFG_UTYPE_NONE); diff --git a/src/util/src/version.c b/src/util/src/version.c index 4eab3fb7e2..919c8b0c88 100644 --- a/src/util/src/version.c +++ b/src/util/src/version.c @@ -1,4 +1,5 @@ char version[64] = "1.6.4.1"; char compatible_version[64] = "1.6.1.0"; -char gitinfo[128] = "893fac9da79ef9b88355fcd18d29057adf909bbd"; -char buildinfo[512] = "Built by ubuntu at 2019-12-02 22:21"; +char gitinfo[128] = "27f51a5cea1bdcb0e7b2ef0df5649e59e6ae38ed"; +char gitinfoOfInternal[128] = "afd592a8d3aedfd7e90d5510840ba3fc73e36160"; +char buildinfo[512] = "Built by root at 2019-12-09 17:39"; From 72aef9078daf158e26be7328573040ced260a078 Mon Sep 17 00:00:00 2001 From: ATR Date: Mon, 9 Dec 2019 19:14:46 +0800 Subject: [PATCH 14/17] Update index.html create table t (ts timestamp, speed int); // fix 'cdata' to 'speed' --- documentation/tdenginedocs-en/getting-started/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/tdenginedocs-en/getting-started/index.html b/documentation/tdenginedocs-en/getting-started/index.html index 039128e964..8968441b55 100644 --- a/documentation/tdenginedocs-en/getting-started/index.html +++ b/documentation/tdenginedocs-en/getting-started/index.html @@ -28,7 +28,7 @@

In the TDengine shell, you can create databases, create tables and insert/query data with SQL. Each query command ends with a semicolon. It works like MySQL, for example:

create database db;
 use db;
-create table t (ts timestamp, cdata int);
+create table t (ts timestamp, speed int);
 insert into t values ('2019-07-15 10:00:00', 10);
 insert into t values ('2019-07-15 10:01:05', 20);
 select * from t;
@@ -85,4 +85,4 @@ Query OK, 2 row(s) in set (0.001700s)

TDengine is specially designed and optimized for time-series data processing in IoT, connected cars, Industrial IoT, IT infrastructure and application monitoring, and other scenarios. Compared with other solutions, it is 10x faster on insert/query speed. With a single-core machine, over 20K requestes can be processed, millions data points can be ingested, and over 10 million data points can be retrieved in a second. Via column-based storage and tuned compression algorithm for different data types, less than 1/10 storage space is required.

Explore More on TDengine

-

Please read through the whole documentation to learn more about TDengine.

Back \ No newline at end of file +

Please read through the whole documentation to learn more about TDengine.

Back From 327eebb51ba0b76f343cb03356237f5871ba195f Mon Sep 17 00:00:00 2001 From: ATR Date: Mon, 9 Dec 2019 19:18:21 +0800 Subject: [PATCH 15/17] Update index.html create table t (ts timestamp, speed int); // fix 'cdata' to 'speed' --- documentation/tdenginedocs-cn/getting-started/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/tdenginedocs-cn/getting-started/index.html b/documentation/tdenginedocs-cn/getting-started/index.html index 65ef667d00..d7d5d8540c 100644 --- a/documentation/tdenginedocs-cn/getting-started/index.html +++ b/documentation/tdenginedocs-cn/getting-started/index.html @@ -28,7 +28,7 @@

在TDengine终端中,用户可以通过SQL命令来创建/删除数据库、表等,并进行插入查询操作。在终端中运行的SQL语句需要以分号结束来运行。示例:

create database db;
 use db;
-create table t (ts timestamp, cdata int);
+create table t (ts timestamp, speed int);
 insert into t values ('2019-07-15 00:00:00', 10);
 insert into t values ('2019-07-15 01:00:00', 20);
 select * from t;
@@ -85,4 +85,4 @@ Query OK, 2 row(s) in set (0.001700s)

TDengine是专为物联网、车联网、工业互联网、运维监测等场景优化设计的时序数据处理引擎。与其他方案相比,它的插入查询速度都快10倍以上。单核一秒钟就能插入100万数据点,读出1000万数据点。由于采用列式存储和优化的压缩算法,存储空间不及普通数据库的1/10.

深入了解TDengine

-

请继续阅读文档来深入了解TDengine。

回去 \ No newline at end of file +

请继续阅读文档来深入了解TDengine。

回去 From 4c7a815fdd29e1e8763231c924aeb7df667f6d72 Mon Sep 17 00:00:00 2001 From: lihui Date: Mon, 9 Dec 2019 19:19:13 +0800 Subject: [PATCH 16/17] [NONE] --- src/client/src/tscParseInsert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 6317decbe0..0aa04f518c 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -444,7 +444,7 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[ } } - tmpTokenBuf[j] = sToken.z[i]; + tmpTokenBuf[j] = sToken.z[k]; j++; } tmpTokenBuf[j] = 0; From c2a2c575a114378a2cc8f6f992b778dbef1215ef Mon Sep 17 00:00:00 2001 From: fang Date: Tue, 10 Dec 2019 08:46:01 +0800 Subject: [PATCH 17/17] solve some statich check questions --- src/client/src/tscPrepare.c | 1 - src/client/src/tscSQLParser.c | 1 - 2 files changed, 2 deletions(-) diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index 2f1db58117..ef8ddfd211 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -65,7 +65,6 @@ static int normalStmtAddPart(SNormalStmt* stmt, bool isParam, char* str, uint32_ } stmt->sizeParts = size; stmt->parts = (SNormalStmtPart*)tmp; - free(tmp); } stmt->parts[stmt->numParts].isParam = isParam; diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index cb73a6e9bd..ac2b958be7 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -2927,7 +2927,6 @@ static SColumnFilterInfo* addColumnFilterInfo(SColumnBase* pColumn) { char* tmp = realloc(pColumn->filterInfo, sizeof(SColumnFilterInfo) * (size)); if (tmp != NULL) { pColumn->filterInfo = (SColumnFilterInfo*)tmp; - free(tmp); } pColumn->numOfFilters++;