diff --git a/src/dnode/src/dnodeModule.c b/src/dnode/src/dnodeModule.c index 0a5b9b550cab09a4bdd5abb25c28aa5c202d8f90..18a293d41588033a27c4f1bf88e3af0d1d527eec 100644 --- a/src/dnode/src/dnodeModule.c +++ b/src/dnode/src/dnodeModule.c @@ -147,13 +147,13 @@ void dnodeProcessModuleStatus(uint32_t moduleStatus) { } bool dnodeCheckMnodeStarting() { - if (tsModuleStatus & TSDB_MOD_MNODE) return false; + if (tsModuleStatus & (1 << TSDB_MOD_MNODE)) return false; SDMMnodeInfos *mnodes = dnodeGetMnodeInfos(); for (int32_t i = 0; i < mnodes->nodeNum; ++i) { SDMMnodeInfo *node = &mnodes->nodeInfos[i]; if (node->nodeId == dnodeGetDnodeId()) { - uint32_t moduleStatus = tsModuleStatus | (1 << TSDB_MOD_MNODE);; + uint32_t moduleStatus = tsModuleStatus | (1 << TSDB_MOD_MNODE); dInfo("start mnode module, module status:%d, new status:%d", tsModuleStatus, moduleStatus); dnodeProcessModuleStatus(moduleStatus); return true; diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index 43b80f65c8808bab8f8f452148b1e16d957ef9f9..1bc328800e1924879d5af18ab4f6c876238e0ae0 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -2093,11 +2093,11 @@ static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) { pMeta->precision = pDb->cfg.precision; pMeta->tableType = pTable->info.type; tstrncpy(pMeta->tableId, pTable->info.tableId, TSDB_TABLE_FNAME_LEN); - if (pTable->superTable) { + if (pTable->superTable != NULL) { tstrncpy(pMeta->sTableId, pTable->superTable->info.tableId, TSDB_TABLE_FNAME_LEN); } - if (pTable->info.type == TSDB_CHILD_TABLE) { + if (pTable->info.type == TSDB_CHILD_TABLE && pTable->superTable != NULL) { pMeta->sversion = htons(pTable->superTable->sversion); pMeta->tversion = htons(pTable->superTable->tversion); pMeta->numOfTags = (int8_t)pTable->superTable->numOfTags; diff --git a/src/os/src/detail/osDir.c b/src/os/src/detail/osDir.c index 30fd05ffc7c040d4abf5bf3a0a9b6dcf28eb3ebb..d3f0fda1a5c8535226eedbac6d5d88a1352e3c6e 100644 --- a/src/os/src/detail/osDir.c +++ b/src/os/src/detail/osDir.c @@ -126,12 +126,13 @@ int32_t taosCompressFile(char *srcFileName, char *destFileName) { dstFp = gzdopen(fd, "wb6f"); if (dstFp == NULL) { ret = -3; + close(fd); goto cmp_end; } while (!feof(srcFp)) { len = (int32_t)fread(data, 1, COMPRESS_STEP_SIZE, srcFp); - gzwrite(dstFp, data, len); + (void)gzwrite(dstFp, data, len); } cmp_end: diff --git a/src/plugins/http/src/httpParser.c b/src/plugins/http/src/httpParser.c index 0c3204687a3fa92fb71d8da2551bb4c10a7a4097..b84483453736aac7693c9ec671ec5a27c4178072 100644 --- a/src/plugins/http/src/httpParser.c +++ b/src/plugins/http/src/httpParser.c @@ -153,10 +153,10 @@ static int32_t httpOnRequestLine(HttpParser *pParser, char *method, char *target for (int32_t i = 0; i < HTTP_MAX_URL; i++) { char *pSeek = strchr(pStart, '/'); if (pSeek == NULL) { - httpAppendString(pParser->path + i, pStart, strlen(pStart)); + (void)httpAppendString(pParser->path + i, pStart, strlen(pStart)); break; } else { - httpAppendString(pParser->path + i, pStart, (int32_t)(pSeek - pStart)); + (void)httpAppendString(pParser->path + i, pStart, (int32_t)(pSeek - pStart)); } pStart = pSeek + 1; } @@ -485,11 +485,11 @@ void httpClearParser(HttpParser *parser) { } void httpDestroyParser(HttpParser *parser) { + if (!parser) return; + HttpContext *pContext = parser->pContext; httpTrace("context:%p, fd:%d, destroy parser", pContext, pContext->fd); - if (!parser) return; - free(parser->method); parser->method = NULL; free(parser->target); parser->target = NULL; free(parser->version); parser->version = NULL; @@ -684,23 +684,28 @@ static int32_t httpParserOnVersion(HttpParser *parser, HTTP_PARSER_STATE state, break; } - if (c!='0' && c!='1') { + if (c != '0' && c != '1' && c != '2') { httpError("context:%p, fd:%d, parser state:%d, unexpected char:[%c]%02x", pContext, pContext->fd, state, c, c); ok = -1; httpOnError(parser, 400, TSDB_CODE_HTTP_PARSE_VERSION_FAILED); break; } + if (httpAppendString(&parser->str, &c, 1)) { httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); ok = -1; httpOnError(parser, 507, TSDB_CODE_HTTP_PARSE_VERSION_FAILED); break; } - - if (c == '0') parser->httpVersion = HTTP_VERSION_10; - else if (c == '1') parser->httpVersion = HTTP_VERSION_11; - else if (c == '2') parser->httpVersion = HTTP_VERSION_12; - else parser->httpVersion = HTTP_INVALID_VERSION; + + if (c == '0') + parser->httpVersion = HTTP_VERSION_10; + else if (c == '1') + parser->httpVersion = HTTP_VERSION_11; + else if (c == '2') + parser->httpVersion = HTTP_VERSION_12; + else { + } parser->version = strdup(parser->str.str); if (!parser->version) {