From 6a18a238738d002fb8870660d5919953ec2055fb Mon Sep 17 00:00:00 2001 From: fang Date: Sat, 7 Dec 2019 18:00:10 +0800 Subject: [PATCH 1/5] resolve static check warnings --- src/client/src/tscAst.c | 2 +- src/client/src/tscJoinProcess.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscAst.c b/src/client/src/tscAst.c index 6e72fa8438..78948cabdc 100644 --- a/src/client/src/tscAst.c +++ b/src/client/src/tscAst.c @@ -326,8 +326,8 @@ static tSQLSyntaxNode *createSyntaxTree(SSchema *pSchema, int32_t numOfCols, cha uint8_t localOptr = getBinaryExprOptr(&t0); if (localOptr == 0) { pError("not support binary operator:%d", t0.type); - return NULL; free(pBinExpr) + return NULL; } return parseRemainStr(str, pBinExpr, pSchema, localOptr, numOfCols, i); diff --git a/src/client/src/tscJoinProcess.c b/src/client/src/tscJoinProcess.c index ed44d54066..e2c5bdbcab 100644 --- a/src/client/src/tscJoinProcess.c +++ b/src/client/src/tscJoinProcess.c @@ -733,6 +733,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) { pTSBuf->f = fopen(pTSBuf->path, "r"); if (pTSBuf->f == NULL) { + free(pTSBuf); return NULL; } @@ -774,7 +775,7 @@ STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete) { size_t infoSize = sizeof(STSVnodeBlockInfo) * pTSBuf->numOfVnodes; STSVnodeBlockInfo* buf = (STSVnodeBlockInfo*)calloc(1, infoSize); - int64_t pos = ftell(pTSBuf->f); + //int64_t pos = ftell(pTSBuf->f); //pos not used fread(buf, infoSize, 1, pTSBuf->f); // the length value for each vnode is not kept in file, so does not set the length value @@ -1250,6 +1251,10 @@ bool tsBufNextPos(STSBuf* pTSBuf) { pCur->vnodeIndex = -1; return false; } + + if (pBlockInfo == NULL) { + return false; + } int32_t blockIndex = pCur->order == TSQL_SO_ASC ? 0 : pBlockInfo->numOfBlocks - 1; tsBufGetBlock(pTSBuf, pCur->vnodeIndex + step, blockIndex); From 964b643bc87b76782a6fe2cce4b89102939de186 Mon Sep 17 00:00:00 2001 From: slguan Date: Sat, 7 Dec 2019 18:04:36 +0800 Subject: [PATCH 2/5] [TBASE-1296] --- src/inc/sdb.h | 2 +- src/inc/taosmsg.h | 2 +- src/sdb/inc/sdbint.h | 2 +- src/sdb/src/sdbEngine.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/inc/sdb.h b/src/inc/sdb.h index 389aecfb7b..a0e0a1b2f2 100644 --- a/src/inc/sdb.h +++ b/src/inc/sdb.h @@ -105,7 +105,7 @@ extern SSdbPeer *sdbPeer[]; #endif -void *sdbOpenTable(int maxRows, int32_t maxRowSize, char *name, char keyType, char *directory, +void *sdbOpenTable(int maxRows, int32_t maxRowSize, char *name, uint8_t keyType, char *directory, void *(*appTool)(char, void *, char *, int, int *)); void *sdbGetRow(void *handle, void *key); diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index c1820a5b9c..d3634219aa 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -664,7 +664,7 @@ typedef struct { uint32_t destId; char meterId[TSDB_UNI_LEN]; char empty[3]; - char msgType; + uint8_t msgType; int32_t msgLen; uint8_t content[0]; } SIntMsg; diff --git a/src/sdb/inc/sdbint.h b/src/sdb/inc/sdbint.h index 3327c1f731..c5b4f4e4ae 100644 --- a/src/sdb/inc/sdbint.h +++ b/src/sdb/inc/sdbint.h @@ -127,7 +127,7 @@ typedef struct { } SMnodeStatus; typedef struct { - char dbId; + uint8_t dbId; char type; uint64_t version; short dataLen; diff --git a/src/sdb/src/sdbEngine.c b/src/sdb/src/sdbEngine.c index c115f3c3c0..0efa81866f 100644 --- a/src/sdb/src/sdbEngine.c +++ b/src/sdb/src/sdbEngine.c @@ -287,7 +287,7 @@ sdb_exit1: return -1; } -void *sdbOpenTable(int maxRows, int32_t maxRowSize, char *name, char keyType, char *directory, +void *sdbOpenTable(int maxRows, int32_t maxRowSize, char *name, uint8_t keyType, char *directory, void *(*appTool)(char, void *, char *, int, int *)) { SSdbTable *pTable = (SSdbTable *)malloc(sizeof(SSdbTable)); if (pTable == NULL) return NULL; From b6fabc595ceaab546abbd3d5211aaac371f222fa Mon Sep 17 00:00:00 2001 From: slguan Date: Sat, 7 Dec 2019 18:14:26 +0800 Subject: [PATCH 3/5] [TBASE-1315] --- src/rpc/src/trpc.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/rpc/src/trpc.c b/src/rpc/src/trpc.c index 9f006ab05a..4aa3e12cf1 100755 --- a/src/rpc/src/trpc.c +++ b/src/rpc/src/trpc.c @@ -31,8 +31,6 @@ #include "tutil.h" #include "lz4.h" -#pragma GCC diagnostic ignored "-Wpointer-to-int-cast" - typedef struct _msg_node { struct _msg_node *next; void * ahandle; @@ -58,7 +56,7 @@ typedef struct { uint16_t tranId; // outgoing transcation ID, for build message uint16_t outTranId; // outgoing transcation ID uint16_t inTranId; - char outType; + uint8_t outType; char inType; char closing; char rspReceived; @@ -203,7 +201,7 @@ static STaosHeader* taosDecompressRpcMsg(STaosHeader* pHeader, SSchedMsg* pSched //tDump(pHeader->content, msgLen); if (buf) { - int32_t originalLen = LZ4_decompress_safe(pHeader->content + overhead, buf + sizeof(STaosHeader), + int32_t originalLen = LZ4_decompress_safe((const char*)(pHeader->content + overhead), buf + sizeof(STaosHeader), msgLen - overhead, contLen); memcpy(buf, pHeader, sizeof(STaosHeader)); @@ -220,6 +218,8 @@ static STaosHeader* taosDecompressRpcMsg(STaosHeader* pHeader, SSchedMsg* pSched tError("failed to allocate memory to decompress msg, contLen:%d, reason:%s", contLen, strerror(errno)); pSchedMsg->msg = NULL; } + + return NULL; } char *taosBuildReqHeader(void *param, char type, char *msg) { @@ -245,7 +245,10 @@ char *taosBuildReqHeader(void *param, char type, char *msg) { pHeader->sourceId = pConn->ownId; 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" memcpy(pHeader->meterId, pConn->meterId, tListLen(pHeader->meterId)); @@ -276,7 +279,11 @@ 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" + memcpy(pHeader->meterId, pConn->meterId, tListLen(pHeader->meterId)); return (char *)pHeader->content; From cafdde229ca13b4be240f0fb08469b87733a9d4d Mon Sep 17 00:00:00 2001 From: fangpanpan <53251079+fangpanpan@users.noreply.github.com> Date: Sat, 7 Dec 2019 18:28:49 +0800 Subject: [PATCH 4/5] Update tscAst.c --- src/client/src/tscAst.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscAst.c b/src/client/src/tscAst.c index 78948cabdc..ef360ab5ef 100644 --- a/src/client/src/tscAst.c +++ b/src/client/src/tscAst.c @@ -326,7 +326,7 @@ static tSQLSyntaxNode *createSyntaxTree(SSchema *pSchema, int32_t numOfCols, cha uint8_t localOptr = getBinaryExprOptr(&t0); if (localOptr == 0) { pError("not support binary operator:%d", t0.type); - free(pBinExpr) + free(pBinExpr); return NULL; } @@ -936,4 +936,4 @@ void tQueryResultClean(tQueryResultset *pRes) { tfree(pRes->pRes); pRes->num = 0; -} \ No newline at end of file +} From bac9efd0d15f9ae4a5f791b3164c7dee24c32ac5 Mon Sep 17 00:00:00 2001 From: fang Date: Sat, 7 Dec 2019 18:37:21 +0800 Subject: [PATCH 5/5] solve statich check question --- src/client/src/tscParseInsert.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 48423417e7..85807cfc4a 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -74,8 +74,8 @@ static int32_t tscToDouble(SSQLToken *pToken, double *value, char **endPtr) { } int tsParseTime(SSQLToken *pToken, int64_t *time, char **next, char *error, int16_t timePrec) { - char * token; - int tokenlen; + //char * token; //fang not used + //int tokenlen; //fang not used int32_t index = 0; SSQLToken sToken; int64_t interval; @@ -394,7 +394,7 @@ static int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[], SParsedDataColInfo *spd, char *error, int16_t timePrec, int32_t *code, char* tmpTokenBuf) { int32_t index = 0; - bool isPrevOptr; + //bool isPrevOptr; //fang, never used SSQLToken sToken = {0}; char * payload = pDataBlocks->pData + pDataBlocks->size; @@ -436,9 +436,9 @@ int tsParseOneRowData(char **str, STableDataBlocks *pDataBlocks, SSchema schema[ char delim = sToken.z[0]; int32_t cnt = 0; int32_t j = 0; - for (int32_t i = 1; i < sToken.n - 1; ++i) { - if (sToken.z[i] == delim || sToken.z[i] == '\\') { - if (sToken.z[i + 1] == delim) { + for (int32_t k = 1; k < sToken.n - 1; ++k) { + if (sToken.z[k] == delim || sToken.z[k] == '\\') { + if (sToken.z[k + 1] == delim) { cnt++; continue; } @@ -1236,7 +1236,7 @@ static int tscInsertDataFromFile(SSqlObj *pSql, FILE *fp, char *tmpTokenBuf) { while ((readLen = getline(&line, &n, fp)) != -1) { // line[--readLen] = '\0'; if (('\r' == line[readLen - 1]) || ('\n' == line[readLen - 1])) line[--readLen] = 0; - if (readLen <= 0) continue; + if (readLen == 0) continue; //fang, <= to == char *lineptr = line; strtolower(line, line);