From cf93ca70d1d79d5d3ddfc78bfa7b50e14c886342 Mon Sep 17 00:00:00 2001 From: ZhongChunHe Date: Fri, 14 May 2021 11:56:37 +0800 Subject: [PATCH] fix declaration shadows previous local/global errors --- src/connector/odbc/examples/c/main.c | 6 +-- src/connector/odbc/src/base/tsdb_impl.c | 4 +- src/kit/shell/src/shellCheck.c | 24 +++++------ src/kit/shell/src/shellEngine.c | 42 ++++++++++---------- src/kit/shell/src/shellImport.c | 22 +++++----- src/kit/shell/src/shellLinux.c | 2 +- src/kit/taosdemo/taosdemo.c | 4 +- src/kit/taosdump/taosdump.c | 2 +- src/tsdb/src/tsdbCommit.c | 6 +-- tests/comparisonTest/tdengine/tdengineTest.c | 8 ++-- 10 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/connector/odbc/examples/c/main.c b/src/connector/odbc/examples/c/main.c index e36c75688e..3ad32dbe53 100644 --- a/src/connector/odbc/examples/c/main.c +++ b/src/connector/odbc/examples/c/main.c @@ -18,8 +18,8 @@ #define CHK_TEST(statement) \ do { \ D("testing: %s", #statement); \ - int r = (statement); \ - if (r) { \ + int _r = (statement); \ + if (_r) { \ D("testing failed: %s", #statement); \ return 1; \ } \ @@ -181,7 +181,7 @@ static int do_statement(SQLHSTMT stmt, const char *statement) { r = traverse_cols(stmt, cols); char buf[4096]; while (1) { - SQLRETURN r = SQLFetch(stmt); + r = SQLFetch(stmt); if (r==SQL_NO_DATA) break; CHK_RESULT(r, SQL_HANDLE_STMT, stmt, ""); for (size_t i=0; itsdb_params = tsdb_params; for (int i=0; ithreadNum, sizeof(ShellThreadObj)); - for (int t = 0; t < args->threadNum; ++t) { + ShellThreadObj *threadObj = (ShellThreadObj *)calloc(_args->threadNum, sizeof(ShellThreadObj)); + for (int t = 0; t < _args->threadNum; ++t) { ShellThreadObj *pThread = threadObj + t; pThread->threadIndex = t; - pThread->totalThreads = args->threadNum; + pThread->totalThreads = _args->threadNum; pThread->taos = con; - pThread->db = args->database; + pThread->db = _args->database; pthread_attr_init(&thattr); pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE); @@ -167,31 +167,31 @@ static void shellRunCheckThreads(TAOS *con, SShellArguments *args) { } } - for (int t = 0; t < args->threadNum; ++t) { + for (int t = 0; t < _args->threadNum; ++t) { pthread_join(threadObj[t].threadID, NULL); } - for (int t = 0; t < args->threadNum; ++t) { + for (int t = 0; t < _args->threadNum; ++t) { taos_close(threadObj[t].taos); } free(threadObj); } -void shellCheck(TAOS *con, SShellArguments *args) { +void shellCheck(TAOS *con, SShellArguments *_args) { int64_t start = taosGetTimestampMs(); - if (shellUseDb(con, args->database) != 0) { + if (shellUseDb(con, _args->database) != 0) { shellFreeTbnames(); return; } - if (shellShowTables(con, args->database) != 0) { + if (shellShowTables(con, _args->database) != 0) { shellFreeTbnames(); return; } - fprintf(stdout, "total %d tables will be checked by %d threads\n", tbNum, args->threadNum); - shellRunCheckThreads(con, args); + fprintf(stdout, "total %d tables will be checked by %d threads\n", tbNum, _args->threadNum); + shellRunCheckThreads(con, _args); int64_t end = taosGetTimestampMs(); fprintf(stdout, "total %d tables checked, failed:%d, time spent %.2f seconds\n", checkedNum, errorNum, diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index 0eb1248fad..d4176fca91 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -56,24 +56,24 @@ extern TAOS *taos_connect_auth(const char *ip, const char *user, const char *aut /* * FUNCTION: Initialize the shell. */ -TAOS *shellInit(SShellArguments *args) { +TAOS *shellInit(SShellArguments *_args) { printf("\n"); printf(CLIENT_VERSION, tsOsName, taos_get_client_info()); fflush(stdout); // set options before initializing - if (args->timezone != NULL) { - taos_options(TSDB_OPTION_TIMEZONE, args->timezone); + if (_args->timezone != NULL) { + taos_options(TSDB_OPTION_TIMEZONE, _args->timezone); } - if (args->is_use_passwd) { - if (args->password == NULL) args->password = getpass("Enter password: "); + if (_args->is_use_passwd) { + if (_args->password == NULL) _args->password = getpass("Enter password: "); } else { - args->password = TSDB_DEFAULT_PASS; + _args->password = TSDB_DEFAULT_PASS; } - if (args->user == NULL) { - args->user = TSDB_DEFAULT_USER; + if (_args->user == NULL) { + _args->user = TSDB_DEFAULT_USER; } if (taos_init()) { @@ -84,10 +84,10 @@ TAOS *shellInit(SShellArguments *args) { // Connect to the database. TAOS *con = NULL; - if (args->auth == NULL) { - con = taos_connect(args->host, args->user, args->password, args->database, args->port); + if (_args->auth == NULL) { + con = taos_connect(_args->host, _args->user, _args->password, _args->database, _args->port); } else { - con = taos_connect_auth(args->host, args->user, args->auth, args->database, args->port); + con = taos_connect_auth(_args->host, _args->user, _args->auth, _args->database, _args->port); } if (con == NULL) { @@ -100,14 +100,14 @@ TAOS *shellInit(SShellArguments *args) { read_history(); // Check if it is temperory run - if (args->commands != NULL || args->file[0] != 0) { - if (args->commands != NULL) { - printf("%s%s\n", PROMPT_HEADER, args->commands); - shellRunCommand(con, args->commands); + if (_args->commands != NULL || _args->file[0] != 0) { + if (_args->commands != NULL) { + printf("%s%s\n", PROMPT_HEADER, _args->commands); + shellRunCommand(con, _args->commands); } - if (args->file[0] != 0) { - source_file(con, args->file); + if (_args->file[0] != 0) { + source_file(con, _args->file); } taos_close(con); @@ -116,14 +116,14 @@ TAOS *shellInit(SShellArguments *args) { } #ifndef WINDOWS - if (args->dir[0] != 0) { - source_dir(con, args); + if (_args->dir[0] != 0) { + source_dir(con, _args); taos_close(con); exit(EXIT_SUCCESS); } - if (args->check != 0) { - shellCheck(con, args); + if (_args->check != 0) { + shellCheck(con, _args); taos_close(con); exit(EXIT_SUCCESS); } diff --git a/src/kit/shell/src/shellImport.c b/src/kit/shell/src/shellImport.c index af61995c61..5de50a3aaf 100644 --- a/src/kit/shell/src/shellImport.c +++ b/src/kit/shell/src/shellImport.c @@ -233,15 +233,15 @@ void* shellImportThreadFp(void *arg) return NULL; } -static void shellRunImportThreads(SShellArguments* args) +static void shellRunImportThreads(SShellArguments* _args) { pthread_attr_t thattr; - ShellThreadObj *threadObj = (ShellThreadObj *)calloc(args->threadNum, sizeof(ShellThreadObj)); - for (int t = 0; t < args->threadNum; ++t) { + ShellThreadObj *threadObj = (ShellThreadObj *)calloc(_args->threadNum, sizeof(ShellThreadObj)); + for (int t = 0; t < _args->threadNum; ++t) { ShellThreadObj *pThread = threadObj + t; pThread->threadIndex = t; - pThread->totalThreads = args->threadNum; - pThread->taos = taos_connect(args->host, args->user, args->password, args->database, tsDnodeShellPort); + pThread->totalThreads = _args->threadNum; + pThread->taos = taos_connect(_args->host, _args->user, _args->password, _args->database, tsDnodeShellPort); if (pThread->taos == NULL) { fprintf(stderr, "ERROR: thread:%d failed connect to TDengine, error:%s\n", pThread->threadIndex, "null taos"/*taos_errstr(pThread->taos)*/); exit(0); @@ -256,18 +256,18 @@ static void shellRunImportThreads(SShellArguments* args) } } - for (int t = 0; t < args->threadNum; ++t) { + for (int t = 0; t < _args->threadNum; ++t) { pthread_join(threadObj[t].threadID, NULL); } - for (int t = 0; t < args->threadNum; ++t) { + for (int t = 0; t < _args->threadNum; ++t) { taos_close(threadObj[t].taos); } free(threadObj); } -void source_dir(TAOS* con, SShellArguments* args) { - shellGetDirectoryFileList(args->dir); +void source_dir(TAOS* con, SShellArguments* _args) { + shellGetDirectoryFileList(_args->dir); int64_t start = taosGetTimestampMs(); if (shellTablesSQLFile[0] != 0) { @@ -276,7 +276,7 @@ void source_dir(TAOS* con, SShellArguments* args) { fprintf(stdout, "import %s finished, time spent %.2f seconds\n", shellTablesSQLFile, (end - start) / 1000.0); } - shellRunImportThreads(args); + shellRunImportThreads(_args); int64_t end = taosGetTimestampMs(); - fprintf(stdout, "import %s finished, time spent %.2f seconds\n", args->dir, (end - start) / 1000.0); + fprintf(stdout, "import %s finished, time spent %.2f seconds\n", _args->dir, (end - start) / 1000.0); } diff --git a/src/kit/shell/src/shellLinux.c b/src/kit/shell/src/shellLinux.c index 37050c416c..4eead252fd 100644 --- a/src/kit/shell/src/shellLinux.c +++ b/src/kit/shell/src/shellLinux.c @@ -415,7 +415,7 @@ void set_terminal_mode() { } } -void get_history_path(char *history) { snprintf(history, TSDB_FILENAME_LEN, "%s/%s", getenv("HOME"), HISTORY_FILE); } +void get_history_path(char *_history) { snprintf(_history, TSDB_FILENAME_LEN, "%s/%s", getenv("HOME"), HISTORY_FILE); } void clearScreen(int ecmd_pos, int cursor_pos) { struct winsize w; diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 49d89dc597..3afb4d5876 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -3884,7 +3884,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { goto PARSE_OVER; } - cJSON* maxSqlLen = cJSON_GetObjectItem(stbInfo, "max_sql_len"); + maxSqlLen = cJSON_GetObjectItem(stbInfo, "max_sql_len"); if (maxSqlLen && maxSqlLen->type == cJSON_Number) { int32_t len = maxSqlLen->valueint; if (len > TSDB_MAX_ALLOWED_SQL_LEN) { @@ -3918,7 +3918,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { goto PARSE_OVER; } */ - cJSON* interlaceRows = cJSON_GetObjectItem(stbInfo, "interlace_rows"); + interlaceRows = cJSON_GetObjectItem(stbInfo, "interlace_rows"); if (interlaceRows && interlaceRows->type == cJSON_Number) { if (interlaceRows->valueint < 0) { errorPrint("%s() LN%d, failed to read json, interlace rows input mistake\n", diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c index f80ac069a0..15db83297c 100644 --- a/src/kit/taosdump/taosdump.c +++ b/src/kit/taosdump/taosdump.c @@ -1017,7 +1017,7 @@ int taosDumpOut(struct arguments *arguments) { sprintf(command, "use %s", dbInfos[0]->name); result = taos_query(taos, command); - int32_t code = taos_errno(result); + code = taos_errno(result); if (code != 0) { fprintf(stderr, "invalid database %s\n", dbInfos[0]->name); goto _exit_failure; diff --git a/src/tsdb/src/tsdbCommit.c b/src/tsdb/src/tsdbCommit.c index 4351cce51c..24f1c11628 100644 --- a/src/tsdb/src/tsdbCommit.c +++ b/src/tsdb/src/tsdbCommit.c @@ -958,11 +958,11 @@ static int tsdbWriteBlockInfo(SCommitH *pCommih) { } static int tsdbWriteBlockIdx(SCommitH *pCommih) { - SBlockIdx *pBlkIdx; + SBlockIdx *pBlkIdx = NULL; SDFile * pHeadf = TSDB_COMMIT_HEAD_FILE(pCommih); size_t nidx = taosArrayGetSize(pCommih->aBlkIdx); - int tlen = 0, size; - int64_t offset; + int tlen = 0, size = 0; + int64_t offset = 0; if (nidx <= 0) { // All data are deleted diff --git a/tests/comparisonTest/tdengine/tdengineTest.c b/tests/comparisonTest/tdengine/tdengineTest.c index 1298aa8323..d1cf3a1f98 100644 --- a/tests/comparisonTest/tdengine/tdengineTest.c +++ b/tests/comparisonTest/tdengine/tdengineTest.c @@ -189,8 +189,8 @@ void writeDataImp(void *param) { counter++; if (counter >= arguments.rowsPerRequest) { - TAOS_RES *result = taos_query(taos, sql); - int32_t code = taos_errno(result); + result = taos_query(taos, sql); + code = taos_errno(result); if (code != 0) { printf("thread:%d error:%d reason:%s\n", pThread->threadId, code, taos_errstr(taos)); } @@ -207,8 +207,8 @@ void writeDataImp(void *param) { } if (counter > 0) { - TAOS_RES *result = taos_query(taos, sql); - int32_t code = taos_errno(result); + result = taos_query(taos, sql); + code = taos_errno(result); if (code != 0) { printf("thread:%d error:%d reason:%s\n", pThread->threadId, code, taos_errstr(taos)); } -- GitLab