From 1241cffcf287e0fc4603ca4155245cd5ea25e551 Mon Sep 17 00:00:00 2001 From: Shungang Li Date: Thu, 25 Jul 2024 15:15:50 +0800 Subject: [PATCH] enh: add more code check --- source/common/src/ttime.c | 23 ++-- source/common/src/ttypes.c | 2 +- source/common/src/tvariant.c | 8 +- source/libs/geometry/src/geosWrapper.c | 6 +- source/util/src/tconfig.c | 167 ++++++++++++------------- 5 files changed, 102 insertions(+), 104 deletions(-) diff --git a/source/common/src/ttime.c b/source/common/src/ttime.c index d3207a1912..efabe5cf07 100644 --- a/source/common/src/ttime.c +++ b/source/common/src/ttime.c @@ -1252,13 +1252,13 @@ static bool isSeperatorChar(char c) { return (c > 0x20 && c < 0x7F && !(c >= 'A' && c <= 'Z') && !(c >= 'a' && c <= 'z') && !(c >= '0' && c <= '9')); } -static void parseTsFormat(const char* formatStr, SArray* formats) { +static int32_t parseTsFormat(const char* formatStr, SArray* formats) { TSFormatNode* lastOtherFormat = NULL; while (*formatStr) { const TSFormatKeyWord* key = keywordSearch(formatStr); if (key) { TSFormatNode format = {.key = key, .type = TS_FORMAT_NODE_TYPE_KEYWORD}; - taosArrayPush(formats, &format); + if (NULL == taosArrayPush(formats, &format)) TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY); formatStr += key->len; lastOtherFormat = NULL; } else { @@ -1286,7 +1286,7 @@ static void parseTsFormat(const char* formatStr, SArray* formats) { TSFormatNode format = {.type = TS_FORMAT_NODE_TYPE_CHAR, .key = NULL}; format.c = formatStr; format.len = 1; - taosArrayPush(formats, &format); + if (NULL == taosArrayPush(formats, &format)) TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY); formatStr++; last = taosArrayGetLast(formats); } @@ -1314,13 +1314,14 @@ static void parseTsFormat(const char* formatStr, SArray* formats) { .key = NULL}; format.c = formatStr; format.len = 1; - taosArrayPush(formats, &format); + if (NULL == taosArrayPush(formats, &format)) TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY); formatStr++; if (format.type == TS_FORMAT_NODE_TYPE_CHAR) lastOtherFormat = taosArrayGetLast(formats); } } } } + TAOS_RETURN(TSDB_CODE_SUCCESS); } static int32_t tm2char(const SArray* formats, const struct STm* tm, char* s, int32_t outLen) { @@ -1488,7 +1489,7 @@ static int32_t tm2char(const SArray* formats, const struct STm* tm, char* s, int s += 6; break; case TSFKW_NS: - sprintf(s, "%09" PRId64, tm->fsec); + (void)sprintf(s, "%09" PRId64, tm->fsec); s += 9; break; case TSFKW_TZH: @@ -1925,7 +1926,7 @@ int32_t taosTs2Char(const char* format, SArray** formats, int64_t ts, int32_t pr if (!*formats){ TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY); } - parseTsFormat(format, *formats); + TAOS_CHECK_RETURN(parseTsFormat(format, *formats)); } struct STm tm; TAOS_CHECK_RETURN(taosTs2Tm(ts, precision, &tm)); @@ -1941,7 +1942,7 @@ int32_t taosChar2Ts(const char* format, SArray** formats, const char* tsStr, int if (!*formats) { TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY); } - parseTsFormat(format, *formats); + TAOS_CHECK_RETURN(parseTsFormat(format, *formats)); } int32_t code = char2ts(tsStr, *formats, ts, precision, &sErrPos, &fErrIdx); if (code == -1) { @@ -1966,7 +1967,7 @@ int32_t TEST_ts2char(const char* format, int64_t ts, int32_t precision, char* ou if (!formats) { TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY); } - parseTsFormat(format, formats); + TAOS_CHECK_RETURN(parseTsFormat(format, formats)); struct STm tm; TAOS_CHECK_GOTO(taosTs2Tm(ts, precision, &tm), NULL, _exit); TAOS_CHECK_GOTO(tm2char(formats, &tm, out, outLen), NULL, _exit); @@ -1980,11 +1981,11 @@ int32_t TEST_char2ts(const char* format, int64_t* ts, int32_t precision, const c const char* sErrPos; int32_t fErrIdx; SArray* formats = taosArrayInit(4, sizeof(TSFormatNode)); - parseTsFormat(format, formats); + TAOS_CHECK_RETURN(parseTsFormat(format, formats)); int32_t code = char2ts(tsStr, formats, ts, precision, &sErrPos, &fErrIdx); if (code == -1) { - printf("failed position: %s\n", sErrPos); - printf("failed format: %s\n", ((TSFormatNode*)taosArrayGet(formats, fErrIdx))->key->name); + (void)printf("failed position: %s\n", sErrPos); + (void)printf("failed format: %s\n", ((TSFormatNode*)taosArrayGet(formats, fErrIdx))->key->name); } taosArrayDestroy(formats); return code; diff --git a/source/common/src/ttypes.c b/source/common/src/ttypes.c index f37c5f1fc3..766e91f54e 100644 --- a/source/common/src/ttypes.c +++ b/source/common/src/ttypes.c @@ -175,7 +175,7 @@ void assignVal(char *val, const char *src, int32_t len, int32_t type) { break; default: { if (len > 0) { - memcpy(val, src, len); + (void)memcpy(val, src, len); } break; diff --git a/source/common/src/tvariant.c b/source/common/src/tvariant.c index d8e7b83c37..cd238fef25 100644 --- a/source/common/src/tvariant.c +++ b/source/common/src/tvariant.c @@ -426,7 +426,7 @@ void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uin size_t lenInwchar = len / TSDB_NCHAR_SIZE; pVar->ucs4 = taosMemoryCalloc(1, (lenInwchar + 1) * TSDB_NCHAR_SIZE); - memcpy(pVar->ucs4, pz, lenInwchar * TSDB_NCHAR_SIZE); + (void)memcpy(pVar->ucs4, pz, lenInwchar * TSDB_NCHAR_SIZE); pVar->nLen = (int32_t)len; break; @@ -435,7 +435,7 @@ void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uin case TSDB_DATA_TYPE_VARBINARY: case TSDB_DATA_TYPE_GEOMETRY: { // todo refactor, extract a method pVar->pz = taosMemoryCalloc(len + 1, sizeof(char)); - memcpy(pVar->pz, pz, len); + (void)memcpy(pVar->pz, pz, len); pVar->nLen = (int32_t)len; break; } @@ -470,10 +470,10 @@ void taosVariantAssign(SVariant *pDst, const SVariant *pSrc) { char *p = taosMemoryRealloc(pDst->pz, len); ASSERT(p); - memset(p, 0, len); + (void)memset(p, 0, len); pDst->pz = p; - memcpy(pDst->pz, pSrc->pz, pSrc->nLen); + (void)memcpy(pDst->pz, pSrc->pz, pSrc->nLen); pDst->nLen = pSrc->nLen; return; } diff --git a/source/libs/geometry/src/geosWrapper.c b/source/libs/geometry/src/geosWrapper.c index 2142b3d62d..6ca8a39bb5 100644 --- a/source/libs/geometry/src/geosWrapper.c +++ b/source/libs/geometry/src/geosWrapper.c @@ -29,7 +29,7 @@ void geosFreeBuffer(void *buffer) { void geosErrMsgeHandler(const char *errMsg, void *userData) { char *targetErrMsg = userData; - snprintf(targetErrMsg, 512, "%s", errMsg); + (void)snprintf(targetErrMsg, 512, "%s", errMsg); } int32_t initCtxMakePoint() { @@ -94,7 +94,7 @@ static int32_t initWktRegex(pcre2_code **ppRegex, pcre2_match_data **ppMatchData return TSDB_CODE_OUT_OF_MEMORY; } - sprintf( + (void)sprintf( wktPatternWithSpace, "^( *)point( *)z?m?( *)((empty)|(\\(( *)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( " "*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}( *)\\)))|linestring( *)z?m?( " @@ -264,7 +264,7 @@ int32_t doAsText(const unsigned char *inputGeom, size_t size, char **outputWKT) SGeosContext *geosCtx = getThreadLocalGeosCtx(); GEOSGeometry *geom = NULL; - unsigned char *wkt = NULL; + char *wkt = NULL; geom = GEOSWKBReader_read_r(geosCtx->handle, geosCtx->WKBReader, inputGeom, size); if (geom == NULL) { diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index 66723cfc3c..e2e4d90849 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -42,7 +42,7 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url); extern char **environ; -int32_t cfgInit(SConfig ** ppCfg) { +int32_t cfgInit(SConfig **ppCfg) { SConfig *pCfg = taosMemoryCalloc(1, sizeof(SConfig)); if (pCfg == NULL) { TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY); @@ -54,7 +54,7 @@ int32_t cfgInit(SConfig ** ppCfg) { TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY); } - taosThreadMutexInit(&pCfg->lock, NULL); + TAOS_CHECK_RETURN(taosThreadMutexInit(&pCfg->lock, NULL)); *ppCfg = pCfg; TAOS_RETURN(TSDB_CODE_SUCCESS); } @@ -113,7 +113,7 @@ void cfgCleanup(SConfig *pCfg) { } taosArrayDestroy(pCfg->array); - taosThreadMutexDestroy(&pCfg->lock); + (void)taosThreadMutexDestroy(&pCfg->lock); taosMemoryFree(pCfg); } @@ -244,17 +244,17 @@ static int32_t doSetConf(SConfigItem *pItem, const char *value, ECfgSrcType styp static int32_t cfgSetTimezone(SConfigItem *pItem, const char *value, ECfgSrcType stype) { TAOS_CHECK_RETURN(doSetConf(pItem, value, stype)); - osSetTimezone(value); + TAOS_CHECK_RETURN(osSetTimezone(value)); TAOS_RETURN(TSDB_CODE_SUCCESS); } static int32_t cfgSetTfsItem(SConfig *pCfg, const char *name, const char *value, const char *level, const char *primary, const char *disable, ECfgSrcType stype) { - taosThreadMutexLock(&pCfg->lock); + (void)taosThreadMutexLock(&pCfg->lock); SConfigItem *pItem = cfgGetItem(pCfg, name); if (pItem == NULL) { - taosThreadMutexUnlock(&pCfg->lock); + (void)taosThreadMutexUnlock(&pCfg->lock); TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND); } @@ -262,7 +262,7 @@ static int32_t cfgSetTfsItem(SConfig *pCfg, const char *name, const char *value, if (pItem->array == NULL) { pItem->array = taosArrayInit(16, sizeof(SDiskCfg)); if (pItem->array == NULL) { - taosThreadMutexUnlock(&pCfg->lock); + (void)taosThreadMutexUnlock(&pCfg->lock); TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY); } @@ -275,13 +275,13 @@ static int32_t cfgSetTfsItem(SConfig *pCfg, const char *name, const char *value, cfg.disable = disable ? atoi(disable) : 0; void *ret = taosArrayPush(pItem->array, &cfg); if (ret == NULL) { - taosThreadMutexUnlock(&pCfg->lock); + (void)taosThreadMutexUnlock(&pCfg->lock); TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY); } pItem->stype = stype; - taosThreadMutexUnlock(&pCfg->lock); + (void)taosThreadMutexUnlock(&pCfg->lock); TAOS_RETURN(TSDB_CODE_SUCCESS); } @@ -307,7 +307,7 @@ static int32_t cfgUpdateDebugFlagItem(SConfig *pCfg, const char *name, bool rese if (pDebugFlagItem == NULL) return -1; if (pDebugFlagItem->array != NULL) { SLogVar logVar = {0}; - strncpy(logVar.name, name, TSDB_LOG_VAR_LEN - 1); + (void)strncpy(logVar.name, name, TSDB_LOG_VAR_LEN - 1); if (NULL == taosArrayPush(pDebugFlagItem->array, &logVar)) { TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY); } @@ -320,12 +320,12 @@ int32_t cfgSetItem(SConfig *pCfg, const char *name, const char *value, ECfgSrcTy int32_t code = TSDB_CODE_SUCCESS; if (lock) { - taosThreadMutexLock(&pCfg->lock); + (void)taosThreadMutexLock(&pCfg->lock); } SConfigItem *pItem = cfgGetItem(pCfg, name); if (pItem == NULL) { - taosThreadMutexUnlock(&pCfg->lock); + (void)taosThreadMutexUnlock(&pCfg->lock); TAOS_RETURN(TSDB_CODE_CFG_NOT_FOUND); } @@ -374,7 +374,7 @@ int32_t cfgSetItem(SConfig *pCfg, const char *name, const char *value, ECfgSrcTy } if (lock) { - taosThreadMutexUnlock(&pCfg->lock); + (void)taosThreadMutexUnlock(&pCfg->lock); } TAOS_RETURN(code); @@ -398,12 +398,10 @@ void cfgLock(SConfig *pCfg) { return; } - taosThreadMutexLock(&pCfg->lock); + (void)taosThreadMutexLock(&pCfg->lock); } -void cfgUnLock(SConfig *pCfg) { - taosThreadMutexUnlock(&pCfg->lock); -} +void cfgUnLock(SConfig *pCfg) { (void)taosThreadMutexUnlock(&pCfg->lock); } int32_t cfgCheckRangeForDynUpdate(SConfig *pCfg, const char *name, const char *pVal, bool isServer) { ECfgDynType dynType = isServer ? CFG_DYN_SERVER : CFG_DYN_CLIENT; @@ -420,7 +418,7 @@ int32_t cfgCheckRangeForDynUpdate(SConfig *pCfg, const char *name, const char *p switch (pItem->dtype) { case CFG_DTYPE_STRING: { if (strcasecmp(name, "slowLogScope") == 0) { - char *tmp = taosStrdup(pVal); + char *tmp = taosStrdup(pVal); int32_t scope = 0; int32_t code = taosSetSlowLogScope(tmp, &scope); if (TSDB_CODE_SUCCESS != code) { @@ -508,7 +506,7 @@ static int32_t cfgAddItem(SConfig *pCfg, SConfigItem *pItem, const char *name) { int32_t len = strlen(name); char lowcaseName[CFG_NAME_MAX_LEN + 1] = {0}; - strntolower(lowcaseName, name, TMIN(CFG_NAME_MAX_LEN, len)); + (void)strntolower(lowcaseName, name, TMIN(CFG_NAME_MAX_LEN, len)); if (taosArrayPush(pCfg->array, pItem) == NULL) { if (pItem->dtype == CFG_DTYPE_STRING) { @@ -723,10 +721,10 @@ int32_t cfgDumpItemScope(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t void cfgDumpCfgS3(SConfig *pCfg, bool tsc, bool dump) { if (dump) { - printf(" s3 config"); - printf("\n"); - printf("================================================================="); - printf("\n"); + (void)printf(" s3 config"); + (void)printf("\n"); + (void)printf("================================================================="); + (void)printf("\n"); } else { uInfo(" s3 config"); uInfo("================================================================="); @@ -754,7 +752,7 @@ void cfgDumpCfgS3(SConfig *pCfg, bool tsc, bool dump) { switch (pItem->dtype) { case CFG_DTYPE_BOOL: if (dump) { - printf("%s %s %u\n", src, name, pItem->bval); + (void)printf("%s %s %u\n", src, name, pItem->bval); } else { uInfo("%s %s %u", src, name, pItem->bval); } @@ -762,14 +760,14 @@ void cfgDumpCfgS3(SConfig *pCfg, bool tsc, bool dump) { break; case CFG_DTYPE_INT32: if (dump) { - printf("%s %s %d\n", src, name, pItem->i32); + (void)printf("%s %s %d\n", src, name, pItem->i32); } else { uInfo("%s %s %d", src, name, pItem->i32); } break; case CFG_DTYPE_INT64: if (dump) { - printf("%s %s %" PRId64 "\n", src, name, pItem->i64); + (void)printf("%s %s %" PRId64 "\n", src, name, pItem->i64); } else { uInfo("%s %s %" PRId64, src, name, pItem->i64); } @@ -777,7 +775,7 @@ void cfgDumpCfgS3(SConfig *pCfg, bool tsc, bool dump) { case CFG_DTYPE_DOUBLE: case CFG_DTYPE_FLOAT: if (dump) { - printf("%s %s %.2f\n", src, name, pItem->fval); + (void)printf("%s %s %.2f\n", src, name, pItem->fval); } else { uInfo("%s %s %.2f", src, name, pItem->fval); } @@ -789,7 +787,7 @@ void cfgDumpCfgS3(SConfig *pCfg, bool tsc, bool dump) { case CFG_DTYPE_TIMEZONE: case CFG_DTYPE_NONE: if (dump) { - printf("%s %s %s\n", src, name, pItem->str); + (void)printf("%s %s %s\n", src, name, pItem->str); } else { uInfo("%s %s %s", src, name, pItem->str); } @@ -798,7 +796,7 @@ void cfgDumpCfgS3(SConfig *pCfg, bool tsc, bool dump) { } if (dump) { - printf("=================================================================\n"); + (void)printf("=================================================================\n"); } else { uInfo("================================================================="); } @@ -806,10 +804,10 @@ void cfgDumpCfgS3(SConfig *pCfg, bool tsc, bool dump) { void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) { if (dump) { - printf(" global config"); - printf("\n"); - printf("================================================================="); - printf("\n"); + (void)printf(" global config"); + (void)printf("\n"); + (void)printf("================================================================="); + (void)printf("\n"); } else { uInfo(" global config"); uInfo("================================================================="); @@ -836,7 +834,7 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) { switch (pItem->dtype) { case CFG_DTYPE_BOOL: if (dump) { - printf("%s %s %u\n", src, name, pItem->bval); + (void)printf("%s %s %u\n", src, name, pItem->bval); } else { uInfo("%s %s %u", src, name, pItem->bval); } @@ -844,14 +842,14 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) { break; case CFG_DTYPE_INT32: if (dump) { - printf("%s %s %d\n", src, name, pItem->i32); + (void)printf("%s %s %d\n", src, name, pItem->i32); } else { uInfo("%s %s %d", src, name, pItem->i32); } break; case CFG_DTYPE_INT64: if (dump) { - printf("%s %s %" PRId64 "\n", src, name, pItem->i64); + (void)printf("%s %s %" PRId64 "\n", src, name, pItem->i64); } else { uInfo("%s %s %" PRId64, src, name, pItem->i64); } @@ -859,7 +857,7 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) { case CFG_DTYPE_DOUBLE: case CFG_DTYPE_FLOAT: if (dump) { - printf("%s %s %.2f\n", src, name, pItem->fval); + (void)printf("%s %s %.2f\n", src, name, pItem->fval); } else { uInfo("%s %s %.2f", src, name, pItem->fval); } @@ -871,7 +869,7 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) { case CFG_DTYPE_TIMEZONE: case CFG_DTYPE_NONE: if (dump) { - printf("%s %s %s\n", src, name, pItem->str); + (void)printf("%s %s %s\n", src, name, pItem->str); } else { uInfo("%s %s %s", src, name, pItem->str); } @@ -880,7 +878,7 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) { } if (dump) { - printf("=================================================================\n"); + (void)printf("=================================================================\n"); } else { uInfo("================================================================="); } @@ -902,21 +900,21 @@ int32_t cfgLoadFromEnvVar(SConfig *pConfig) { pEnv++; (void)taosEnvToCfg(line, line); - paGetToken(line, &name, &olen); + (void)paGetToken(line, &name, &olen); if (olen == 0) continue; name[olen] = 0; - paGetToken(name + olen + 1, &value, &vlen); + (void)paGetToken(name + olen + 1, &value, &vlen); if (vlen == 0) continue; value[vlen] = 0; - paGetToken(value + vlen + 1, &value2, &vlen2); + (void)paGetToken(value + vlen + 1, &value2, &vlen2); if (vlen2 != 0) { value2[vlen2] = 0; - paGetToken(value2 + vlen2 + 1, &value3, &vlen3); + (void)paGetToken(value2 + vlen2 + 1, &value3, &vlen3); if (vlen3 != 0) { value3[vlen3] = 0; - paGetToken(value3 + vlen3 + 1, &value4, &vlen4); + (void)paGetToken(value3 + vlen3 + 1, &value4, &vlen4); if (vlen4 != 0) value4[vlen4] = 0; } } @@ -949,21 +947,21 @@ int32_t cfgLoadFromEnvCmd(SConfig *pConfig, const char **envCmd) { name = value = value2 = value3 = value4 = NULL; olen = vlen = vlen2 = vlen3 = vlen4 = 0; - paGetToken(buf, &name, &olen); + (void)paGetToken(buf, &name, &olen); if (olen == 0) continue; name[olen] = 0; - paGetToken(name + olen + 1, &value, &vlen); + (void)paGetToken(name + olen + 1, &value, &vlen); if (vlen == 0) continue; value[vlen] = 0; - paGetToken(value + vlen + 1, &value2, &vlen2); + (void)paGetToken(value + vlen + 1, &value2, &vlen2); if (vlen2 != 0) { value2[vlen2] = 0; - paGetToken(value2 + vlen2 + 1, &value3, &vlen3); + (void)paGetToken(value2 + vlen2 + 1, &value3, &vlen3); if (vlen3 != 0) { value3[vlen3] = 0; - paGetToken(value3 + vlen3 + 1, &value4, &vlen4); + (void)paGetToken(value3 + vlen3 + 1, &value4, &vlen4); if (vlen4 != 0) value4[vlen4] = 0; } } @@ -1017,21 +1015,21 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) { if (line[_bytes - 1] == '\n') line[_bytes - 1] = 0; (void)taosEnvToCfg(line, line); - paGetToken(line, &name, &olen); + (void)paGetToken(line, &name, &olen); if (olen == 0) continue; name[olen] = 0; - paGetToken(name + olen + 1, &value, &vlen); + (void)paGetToken(name + olen + 1, &value, &vlen); if (vlen == 0) continue; value[vlen] = 0; - paGetToken(value + vlen + 1, &value2, &vlen2); + (void)paGetToken(value + vlen + 1, &value2, &vlen2); if (vlen2 != 0) { value2[vlen2] = 0; - paGetToken(value2 + vlen2 + 1, &value3, &vlen3); + (void)paGetToken(value2 + vlen2 + 1, &value3, &vlen3); if (vlen3 != 0) { value3[vlen3] = 0; - paGetToken(value3 + vlen3 + 1, &value4, &vlen4); + (void)paGetToken(value3 + vlen3 + 1, &value4, &vlen4); if (vlen4 != 0) value4[vlen4] = 0; } } @@ -1045,7 +1043,7 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) { } } - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); uInfo("load from env cfg file %s success", filepath); TAOS_RETURN(TSDB_CODE_SUCCESS); @@ -1081,11 +1079,11 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) { if (line[_bytes - 1] == '\n') line[_bytes - 1] = 0; - paGetToken(line, &name, &olen); + (void)paGetToken(line, &name, &olen); if (olen == 0) continue; name[olen] = 0; - paGetToken(name + olen + 1, &value, &vlen); + (void)paGetToken(name + olen + 1, &value, &vlen); if (vlen == 0) continue; value[vlen] = 0; @@ -1098,7 +1096,7 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) { int32_t count = 1; while (vlen < 1024) { - paGetToken(value + vlen + 1 * count, &tmp, &len); + (void)paGetToken(value + vlen + 1 * count, &tmp, &len); if (len == 0) break; tmp[len] = 0; strcpy(newValue + vlen, tmp); @@ -1109,13 +1107,13 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) { code = cfgSetItem(pConfig, name, newValue, CFG_STYPE_CFG_FILE, true); if (TSDB_CODE_SUCCESS != code && TSDB_CODE_CFG_NOT_FOUND != code) break; } else { - paGetToken(value + vlen + 1, &value2, &vlen2); + (void)paGetToken(value + vlen + 1, &value2, &vlen2); if (vlen2 != 0) { value2[vlen2] = 0; - paGetToken(value2 + vlen2 + 1, &value3, &vlen3); + (void)paGetToken(value2 + vlen2 + 1, &value3, &vlen3); if (vlen3 != 0) { value3[vlen3] = 0; - paGetToken(value3 + vlen3 + 1, &value4, &vlen4); + (void)paGetToken(value3 + vlen3 + 1, &value4, &vlen4); if (vlen4 != 0) value4[vlen4] = 0; } } @@ -1138,7 +1136,7 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) { } } - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); if (TSDB_CODE_SUCCESS == code || TSDB_CODE_CFG_NOT_FOUND == code) { uInfo("load from cfg file %s success", filepath); @@ -1179,18 +1177,18 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) { // if(line[_bytes - 1] == '\n') line[_bytes - 1] = 0; -// paGetToken(line, &name, &olen); +// (void)paGetToken(line, &name, &olen); // if (olen == 0) continue; // name[olen] = 0; -// paGetToken(name + olen + 1, &value, &vlen); +// (void)paGetToken(name + olen + 1, &value, &vlen); // if (vlen == 0) continue; // value[vlen] = 0; -// paGetToken(value + vlen + 1, &value2, &vlen2); +// (void)paGetToken(value + vlen + 1, &value2, &vlen2); // if (vlen2 != 0) { // value2[vlen2] = 0; -// paGetToken(value2 + vlen2 + 1, &value3, &vlen3); +// (void)paGetToken(value2 + vlen2 + 1, &value3, &vlen3); // if (vlen3 != 0) value3[vlen3] = 0; // } @@ -1202,7 +1200,7 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) { // } // } -// taosCloseFile(&pFile); +// (void)taosCloseFile(&pFile); // if (line != NULL) taosMemoryFreeClear(line); // if (code == 0 || (code != 0 && terrno == TSDB_CODE_CFG_NOT_FOUND)) { @@ -1245,20 +1243,20 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { size_t fileSize = taosLSeekFile(pFile, 0, SEEK_END); char *buf = taosMemoryMalloc(fileSize + 1); if (!buf) { - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); uError("load json file error: %s, failed to alloc memory", filepath); TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY); } buf[fileSize] = 0; - taosLSeekFile(pFile, 0, SEEK_SET); + (void)taosLSeekFile(pFile, 0, SEEK_SET); if (taosReadFile(pFile, buf, fileSize) <= 0) { - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); uError("load json file error: %s", filepath); taosMemoryFreeClear(buf); TAOS_RETURN(TSDB_CODE_INVALID_DATA_FMT); } - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); pJson = tjsonParse(buf); if (NULL == pJson) { const char *jsonParseError = tjsonGetError(); @@ -1286,25 +1284,24 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { goto _err_json; } - memcpy(cfgLineBuf, itemName, itemNameLen); + (void)memcpy(cfgLineBuf, itemName, itemNameLen); cfgLineBuf[itemNameLen] = ' '; - memcpy(&cfgLineBuf[itemNameLen + 1], itemValueString, itemValueStringLen); - - paGetToken(cfgLineBuf, &name, &olen); + (void)memcpy(&cfgLineBuf[itemNameLen + 1], itemValueString, itemValueStringLen); + (void)paGetToken(cfgLineBuf, &name, &olen); if (olen == 0) continue; name[olen] = 0; - paGetToken(name + olen + 1, &value, &vlen); + (void)paGetToken(name + olen + 1, &value, &vlen); if (vlen == 0) continue; value[vlen] = 0; - paGetToken(value + vlen + 1, &value2, &vlen2); + (void)paGetToken(value + vlen + 1, &value2, &vlen2); if (vlen2 != 0) { value2[vlen2] = 0; - paGetToken(value2 + vlen2 + 1, &value3, &vlen3); + (void)paGetToken(value2 + vlen2 + 1, &value3, &vlen3); if (vlen3 != 0) { value3[vlen3] = 0; - paGetToken(value3 + vlen3 + 1, &value4, &vlen4); + (void)paGetToken(value3 + vlen3 + 1, &value4, &vlen4); if (vlen4 != 0) value4[vlen4] = 0; } } @@ -1348,7 +1345,7 @@ int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char *apolloUrl p++; p[strlen(p) - 1] = '\0'; } - memcpy(apolloUrl, p, TMIN(strlen(p) + 1, PATH_MAX)); + (void)memcpy(apolloUrl, p, TMIN(strlen(p) + 1, PATH_MAX)); uInfo("get apollo url from env cmd success"); TAOS_RETURN(TSDB_CODE_SUCCESS); } @@ -1370,7 +1367,7 @@ int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char *apolloUrl p++; p[strlen(p) - 1] = '\0'; } - memcpy(apolloUrl, p, TMIN(strlen(p) + 1, PATH_MAX)); + (void)memcpy(apolloUrl, p, TMIN(strlen(p) + 1, PATH_MAX)); uInfo("get apollo url from env variables success, apolloUrl=%s", apolloUrl); TAOS_RETURN(TSDB_CODE_SUCCESS); } @@ -1407,14 +1404,14 @@ int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char *apolloUrl p++; p[strlen(p) - 1] = '\0'; } - memcpy(apolloUrl, p, TMIN(strlen(p) + 1, PATH_MAX)); - taosCloseFile(&pFile); + (void)memcpy(apolloUrl, p, TMIN(strlen(p) + 1, PATH_MAX)); + (void)taosCloseFile(&pFile); uInfo("get apollo url from env file success"); TAOS_RETURN(TSDB_CODE_SUCCESS); } } } - taosCloseFile(&pFile); + (void)taosCloseFile(&pFile); } uInfo("fail get apollo url from cmd env file"); @@ -1438,7 +1435,7 @@ int32_t cfgCreateIter(SConfig *pConf, SConfigIter **ppIter) { TAOS_RETURN(TSDB_CODE_SUCCESS); } -SConfigItem *cfgNextIter(SConfigIter* pIter) { +SConfigItem *cfgNextIter(SConfigIter *pIter) { if (pIter->index < cfgGetSize(pIter->pConf)) { return taosArrayGet(pIter->pConf->array, pIter->index++); }