From 421e64ceeba2c64ddc9cd87a2d3678497596d21f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 20 Apr 2018 14:58:38 +0300 Subject: [PATCH] Take -Wall into use for tests Take almost all warnings into use except `format-overflow` and `unused-function`. format-overflow needs to be handled in a separate commit. --- maxscale-system-test/CMakeLists.txt | 8 ++++---- maxscale-system-test/big_load.cpp | 6 ++---- maxscale-system-test/binlog_big_transaction.cpp | 3 +-- maxscale-system-test/binlog_change_master.cpp | 6 +----- maxscale-system-test/blob_test.cpp | 8 ++++---- maxscale-system-test/bug448.cpp | 1 - maxscale-system-test/bug529.cpp | 3 +-- maxscale-system-test/bug601.cpp | 3 +-- maxscale-system-test/bug673.cpp | 1 - maxscale-system-test/cdc_client.cpp | 6 +----- .../change_master_during_session.cpp | 2 +- .../crash_out_of_files_galera.cpp | 1 - maxscale-system-test/encrypted_passwords.cpp | 1 - maxscale-system-test/fwf2.cpp | 1 - maxscale-system-test/get_my_ip.cpp | 4 ++-- maxscale-system-test/mariadb_func.cpp | 8 +++----- maxscale-system-test/mariadb_nodes.h | 2 +- maxscale-system-test/maxinfo_func.cpp | 4 ++-- maxscale-system-test/maxinfo_func.h | 2 +- maxscale-system-test/mxs1323_retry_read.cpp | 1 - maxscale-system-test/mxs1719.cpp | 1 - maxscale-system-test/mxs1808_long_data.cpp | 4 ++-- maxscale-system-test/mxs365.cpp | 6 +++--- .../mxs548_short_session_change_user.cpp | 6 ++---- maxscale-system-test/mxs564_big_dump.cpp | 5 ++--- maxscale-system-test/mxs657_restart.cpp | 3 +-- maxscale-system-test/mxs657_restart_service.cpp | 3 +-- maxscale-system-test/mxs729_maxadmin.cpp | 7 +------ maxscale-system-test/mxs922_listener_ssl.cpp | 2 +- .../mysqlmon_failover_rolling_master.cpp | 1 - .../mysqlmon_failover_stress.cpp | 4 +--- maxscale-system-test/mysqlmon_rejoin_bad2.cpp | 1 - .../mysqlmon_switchover_stress.cpp | 4 +--- maxscale-system-test/non_native_setup.cpp | 2 +- maxscale-system-test/rds_vpc.cpp | 2 -- maxscale-system-test/rw_select_insert.cpp | 3 --- maxscale-system-test/rwsplit_conn_num.cpp | 1 - maxscale-system-test/server_weight.cpp | 9 ++++----- maxscale-system-test/setup_binlog_gtid.cpp | 9 --------- maxscale-system-test/sql_t1.cpp | 5 ++--- maxscale-system-test/sysbench_kill_slave.cpp | 7 +++---- maxscale-system-test/templates.h.in | 6 +++--- maxscale-system-test/testconnections.cpp | 16 ++++------------ 43 files changed, 57 insertions(+), 121 deletions(-) diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index 4e68fe6d5..c29b60745 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -21,10 +21,10 @@ set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") -set(CMAKE_CXX_FLAGS "-std=c++11 -ggdb -Werror") -set(CMAKE_CXX_FLAGS_DEBUG "-std=c++11 -ggdb -Werror") -set(CMAKE_CXX_FLAGS_RELEASE "-std=c++11 -ggdb -Werror") -set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-std=c++11 -ggdb -Werror") +set(CMAKE_CXX_FLAGS "-std=c++11 -ggdb -Wall -Werror -Wno-format-overflow -Wno-unused-function") +set(CMAKE_CXX_FLAGS_DEBUG "-std=c++11 -ggdb -Wall -Werror -Wno-format-overflow -Wno-unused-function") +set(CMAKE_CXX_FLAGS_RELEASE "-std=c++11 -ggdb -Wall -Werror -Wno-format-overflow -Wno-unused-function") +set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-std=c++11 -ggdb -Wall -Werror -Wno-format-overflow -Wno-unused-function") enable_testing() diff --git a/maxscale-system-test/big_load.cpp b/maxscale-system-test/big_load.cpp index 592860716..a6412750b 100644 --- a/maxscale-system-test/big_load.cpp +++ b/maxscale-system-test/big_load.cpp @@ -60,8 +60,6 @@ void load(long int *new_inserts, long int *new_selects, long int *selects, long pthread_t thread1[threads_num]; pthread_t thread2[threads_num]; - int iret1[threads_num]; - int iret2[threads_num]; Test->tprintf("COM_INSERT and COM_SELECT before executing test\n"); @@ -72,8 +70,8 @@ void load(long int *new_inserts, long int *new_selects, long int *selects, long /* Create independent threads each of them will execute function */ for (int i = 0; i < threads_num; i++) { - iret1[i] = pthread_create(&thread1[i], NULL, query_thread1, &data); - iret2[i] = pthread_create(&thread2[i], NULL, query_thread2, &data); + pthread_create(&thread1[i], NULL, query_thread1, &data); + pthread_create(&thread2[i], NULL, query_thread2, &data); } Test->tprintf("Threads are running %d seconds \n", run_time); sleep(run_time); diff --git a/maxscale-system-test/binlog_big_transaction.cpp b/maxscale-system-test/binlog_big_transaction.cpp index a847d92c1..72bc6dcda 100644 --- a/maxscale-system-test/binlog_big_transaction.cpp +++ b/maxscale-system-test/binlog_big_transaction.cpp @@ -28,9 +28,8 @@ int main(int argc, char *argv[]) Test->start_binlog(0); pthread_t threads; - int iret; exit_flag = 0; - iret = pthread_create( &threads, NULL, disconnect_thread, NULL); + pthread_create( &threads, NULL, disconnect_thread, NULL); Test->repl->connect(); for (int i = 0; i < 100000; i++) diff --git a/maxscale-system-test/binlog_change_master.cpp b/maxscale-system-test/binlog_change_master.cpp index ed0e8e5e9..0a8632e08 100644 --- a/maxscale-system-test/binlog_change_master.cpp +++ b/maxscale-system-test/binlog_change_master.cpp @@ -132,15 +132,12 @@ int main(int argc, char *argv[]) Test->tprintf("Starting binlog configuration\n"); Test->start_binlog(0); - pthread_t disconnec_thread_t; - int disconnect_iret; pthread_t transaction_thread_t; - int transaction_iret; exit_flag = 0; Test->tprintf("Starting query thread\n"); - transaction_iret = pthread_create(&transaction_thread_t, NULL, transaction_thread, NULL); + pthread_create(&transaction_thread_t, NULL, transaction_thread, NULL); Test->tprintf("Sleeping\n"); Test->stop_timeout(); @@ -229,7 +226,6 @@ const char * setup_slave_gtid = void select_new_master(TestConnections * test) { char log_file[256]; - char log_file_new[256]; char log_pos[256]; char maxscale_log_file[256]; diff --git a/maxscale-system-test/blob_test.cpp b/maxscale-system-test/blob_test.cpp index 5727dd191..6bb3f85a9 100644 --- a/maxscale-system-test/blob_test.cpp +++ b/maxscale-system-test/blob_test.cpp @@ -3,9 +3,9 @@ int test_longblob(TestConnections* Test, MYSQL * conn, char * blob_name, unsigned long chunk_size, int chunks, int rows) { - unsigned long size = chunk_size; + int size = chunk_size; unsigned long * data; - unsigned long i, j; + int i, j; MYSQL_BIND param[1]; char sql[256]; int global_res = Test->global_result; @@ -171,9 +171,9 @@ int check_longblob_data(TestConnections* Test, MYSQL * conn, unsigned long chunk { Test->add_result(1, "id field is wrong! Expected %d, but it is %d\n", row + 1, r_id); } - for (int y = 0; y < chunk_size * chunks; y++) + for (int y = 0; y < (int)chunk_size * chunks; y++) { - if (data[y] != y) + if ((int)data[y] != y) { Test->add_result(1, "expected %d, got %d", data[y], y); break; diff --git a/maxscale-system-test/bug448.cpp b/maxscale-system-test/bug448.cpp index 8621742ba..754a9e39d 100644 --- a/maxscale-system-test/bug448.cpp +++ b/maxscale-system-test/bug448.cpp @@ -12,7 +12,6 @@ int main(int argc, char *argv[]) { char my_ip[1024]; char my_ip_db[1024]; - char sql[1024]; char * first_dot; TestConnections * Test = new TestConnections(argc, argv); diff --git a/maxscale-system-test/bug529.cpp b/maxscale-system-test/bug529.cpp index 76306d490..9b217b0c5 100644 --- a/maxscale-system-test/bug529.cpp +++ b/maxscale-system-test/bug529.cpp @@ -140,7 +140,6 @@ int main(int argc, char *argv[]) char sql[100]; pthread_t parall_traffic1; - int check_iret; MYSQL * conn; MYSQL * rwsplit_conn[conn_N]; @@ -199,7 +198,7 @@ int main(int argc, char *argv[]) Test->tprintf("Opening more connection to ReadConn slave in parallel thread\n"); - check_iret = pthread_create( ¶ll_traffic1, NULL, parall_traffic, NULL); + pthread_create( ¶ll_traffic1, NULL, parall_traffic, NULL); for (i = 0; i < Test->repl->N; i++) { diff --git a/maxscale-system-test/bug601.cpp b/maxscale-system-test/bug601.cpp index 43a771c8b..abe0f24e7 100644 --- a/maxscale-system-test/bug601.cpp +++ b/maxscale-system-test/bug601.cpp @@ -57,7 +57,6 @@ int main(int argc, char *argv[]) pthread_t parall_traffic1[100]; - int check_iret[100]; Test->set_timeout(60); Test->repl->connect(); @@ -75,7 +74,7 @@ int main(int argc, char *argv[]) for (int j = 0; j < 25; j++) { - check_iret[j] = pthread_create(¶ll_traffic1[j], NULL, parall_traffic, NULL); + pthread_create(¶ll_traffic1[j], NULL, parall_traffic, NULL); } Test->tprintf("Doing change_user in the loop"); diff --git a/maxscale-system-test/bug673.cpp b/maxscale-system-test/bug673.cpp index b3d792ef9..1a049a6a3 100644 --- a/maxscale-system-test/bug673.cpp +++ b/maxscale-system-test/bug673.cpp @@ -17,7 +17,6 @@ int main(int argc, char *argv[]) test.set_timeout(60); for (int i = 0; i < 2; i++) { - char result[1024]; test.add_result(test.maxscales->ssh_node_f(0, true, "maxadmin show dbusers \"RW Split Router\"|grep 'User names'"), "Old style objects in maxadmin commands should succeed"); test.add_result(test.maxscales->ssh_node_f(0, true, "maxadmin show dbusers RW-Split-Router|grep 'User names'"), diff --git a/maxscale-system-test/cdc_client.cpp b/maxscale-system-test/cdc_client.cpp index ce75208a0..264210f35 100644 --- a/maxscale-system-test/cdc_client.cpp +++ b/maxscale-system-test/cdc_client.cpp @@ -130,13 +130,9 @@ bool cdc_com(TestConnections *Test) if (nfds > 0) { - // for each ready socket - //for(int i = 0; i < nfds; i++) - //{ - int fd = events[0].data.fd; char *json = read_sc(sock); Test->tprintf("%s", json); - //} + if (ignore_first > 0) { ignore_first--; // ignoring first reads diff --git a/maxscale-system-test/change_master_during_session.cpp b/maxscale-system-test/change_master_during_session.cpp index f0d073c3c..1c53c07f1 100644 --- a/maxscale-system-test/change_master_during_session.cpp +++ b/maxscale-system-test/change_master_during_session.cpp @@ -30,7 +30,7 @@ int main(int argc, char *argv[]) Test->set_timeout(60); Test->repl->change_master(1, 0); Test->tprintf("executing 3 INSERTs\n"); - for (int i = 0; i++; i < 3) + for (int i = 0; i < 3; i++) { Test->set_timeout(60); sprintf(sql, "INSERT INTO t1 (x1, fl) VALUES(%d, 2);", i); diff --git a/maxscale-system-test/crash_out_of_files_galera.cpp b/maxscale-system-test/crash_out_of_files_galera.cpp index cec708657..8e66fd19d 100644 --- a/maxscale-system-test/crash_out_of_files_galera.cpp +++ b/maxscale-system-test/crash_out_of_files_galera.cpp @@ -15,7 +15,6 @@ int main(int argc, char *argv[]) { TestConnections * Test = new TestConnections(argc, argv); Test->set_timeout(20); - int q; long int i1, i2; long int selects[256]; diff --git a/maxscale-system-test/encrypted_passwords.cpp b/maxscale-system-test/encrypted_passwords.cpp index 35c728c90..bd752038c 100644 --- a/maxscale-system-test/encrypted_passwords.cpp +++ b/maxscale-system-test/encrypted_passwords.cpp @@ -40,7 +40,6 @@ int hash_password(TestConnections *test) test->maxscales->stop_maxscale(0); test->stop_timeout(); - int res = 0; int exit_code; test->tprintf("Creating a new encrypted password\n"); char *enc_pw = test->maxscales->ssh_node_output(0, "maxpasswd /var/lib/maxscale/ skysql", true, &exit_code); diff --git a/maxscale-system-test/fwf2.cpp b/maxscale-system-test/fwf2.cpp index ab2fa535c..bd0e1dbd9 100644 --- a/maxscale-system-test/fwf2.cpp +++ b/maxscale-system-test/fwf2.cpp @@ -62,7 +62,6 @@ int main(int argc, char *argv[]) char pass_file[4096]; char deny_file[4096]; char rules_dir[4096]; - FILE* file; sprintf(rules_dir, "%s/fw2/", test_dir); int N = 5; diff --git a/maxscale-system-test/get_my_ip.cpp b/maxscale-system-test/get_my_ip.cpp index 2b4574d2d..84a7e953f 100644 --- a/maxscale-system-test/get_my_ip.cpp +++ b/maxscale-system-test/get_my_ip.cpp @@ -33,11 +33,11 @@ int get_my_ip(char * remote_ip, char * my_ip ) serv.sin_addr.s_addr = inet_addr( remote_ip ); serv.sin_port = htons( dns_port ); - int err = connect( sock , (const struct sockaddr*) &serv , sizeof(serv) ); + connect( sock , (const struct sockaddr*) &serv , sizeof(serv) ); struct sockaddr_in name; socklen_t namelen = sizeof(name); - err = getsockname(sock, (struct sockaddr*) &name, &namelen); + getsockname(sock, (struct sockaddr*) &name, &namelen); char buffer[100]; const char* p = inet_ntop(AF_INET, &name.sin_addr, buffer, 100); diff --git a/maxscale-system-test/mariadb_func.cpp b/maxscale-system-test/mariadb_func.cpp index 2a61cbd25..39509948e 100644 --- a/maxscale-system-test/mariadb_func.cpp +++ b/maxscale-system-test/mariadb_func.cpp @@ -390,7 +390,7 @@ int execute_query_count_rows(MYSQL* conn, const char* sql) { rval = 0; - for (int i = 0; i < total && i < 1024; i++) + for (unsigned int i = 0; i < total && i < 1024; i++) { rval += num_of_rows[i]; } @@ -403,7 +403,6 @@ int get_conn_num(MYSQL* conn, std::string ip, std::string hostname, std::string { MYSQL_RES *res; MYSQL_ROW row; - unsigned long long int num_fields; unsigned long long int rows; unsigned long long int i; unsigned int conn_num = 0; @@ -436,7 +435,7 @@ int get_conn_num(MYSQL* conn, std::string ip, std::string hostname, std::string } else { - num_fields = mysql_num_fields(res); + mysql_num_fields(res); rows = mysql_num_rows(res); for (i = 0; i < rows; i++) { @@ -472,7 +471,6 @@ int find_field(MYSQL* conn, const char* sql, const char* field_name, char* value MYSQL_RES *res; MYSQL_ROW row; MYSQL_FIELD *field; - unsigned long long int num_fields; unsigned int ret = 1; unsigned long long int filed_i = 0; unsigned long long int i = 0; @@ -492,7 +490,7 @@ int find_field(MYSQL* conn, const char* sql, const char* field_name, char* value } else { - num_fields = mysql_num_fields(res); + mysql_num_fields(res); while ((field = mysql_fetch_field(res)) && ret != 0) { if (strstr(field->name, field_name) != NULL) diff --git a/maxscale-system-test/mariadb_nodes.h b/maxscale-system-test/mariadb_nodes.h index 674d25e1c..2b2b398f9 100644 --- a/maxscale-system-test/mariadb_nodes.h +++ b/maxscale-system-test/mariadb_nodes.h @@ -38,7 +38,7 @@ public: */ Mariadb_nodes(const char *pref, const char *test_cwd, bool verbose); - ~Mariadb_nodes(); + virtual ~Mariadb_nodes(); /** * @brief MYSQL structs for every backend node diff --git a/maxscale-system-test/maxinfo_func.cpp b/maxscale-system-test/maxinfo_func.cpp index 4b25486ce..5ae54ad2e 100644 --- a/maxscale-system-test/maxinfo_func.cpp +++ b/maxscale-system-test/maxinfo_func.cpp @@ -107,7 +107,7 @@ char * get_maxinfo(const char * page, TestConnections* Test) //Test->tprintf("Query is:\n<>\n%s<>\n", get); //Send the query to the server - int sent = 0; + size_t sent = 0; while (sent < strlen(get)) { tmpres = send(sock, get + sent, strlen(get) - sent, 0); @@ -178,7 +178,7 @@ char * read_sc(int sock) int send_so(int sock, char * data) { int tmpres; - int sent = 0; + size_t sent = 0; while (sent < strlen(data)) { tmpres = send(sock, data + sent, strlen(data) - sent, 0); diff --git a/maxscale-system-test/maxinfo_func.h b/maxscale-system-test/maxinfo_func.h index a3a07a6ed..1a9686201 100644 --- a/maxscale-system-test/maxinfo_func.h +++ b/maxscale-system-test/maxinfo_func.h @@ -15,7 +15,7 @@ char * get_maxinfo(const char *page, TestConnections* Test); char * read_sc(int sock); int send_so(int sock, char * data); -static char hexconvtab[] = "0123456789abcdef"; +static char hexconvtab[] __attribute__((unused)) = "0123456789abcdef"; static char* bin2hex(const unsigned char *old, const size_t oldlen); char * cdc_auth_srt(char * user, char * password); int setnonblocking(int sock); diff --git a/maxscale-system-test/mxs1323_retry_read.cpp b/maxscale-system-test/mxs1323_retry_read.cpp index 246f9d088..8b8c3af39 100644 --- a/maxscale-system-test/mxs1323_retry_read.cpp +++ b/maxscale-system-test/mxs1323_retry_read.cpp @@ -31,7 +31,6 @@ int main(int argc, char *argv[]) { TestConnections test(argc, argv); - char server_id[2][1024]; test.repl->connect(); std::string master = test.repl->get_server_id_str(0); std::string slave = test.repl->get_server_id_str(1); diff --git a/maxscale-system-test/mxs1719.cpp b/maxscale-system-test/mxs1719.cpp index 4a1811dc9..b206a0cab 100644 --- a/maxscale-system-test/mxs1719.cpp +++ b/maxscale-system-test/mxs1719.cpp @@ -35,7 +35,6 @@ void run(TestConnections& test) MYSQL* pMysql = mysql_init(NULL); test.assert(pMysql, "Could not create MYSQL handle."); - const char* zHost = test.maxscales->IP[0]; const char* zUser = test.maxscales->user_name; const char* zPassword = test.maxscales->password; int port = test.maxscales->rwsplit_port[0]; diff --git a/maxscale-system-test/mxs1808_long_data.cpp b/maxscale-system-test/mxs1808_long_data.cpp index c0617f6ab..b32af6788 100644 --- a/maxscale-system-test/mxs1808_long_data.cpp +++ b/maxscale-system-test/mxs1808_long_data.cpp @@ -19,11 +19,11 @@ static int test_long_data(MYSQL *conn, int sqlsize) MYSQL_STMT *stmt; stmt = mysql_stmt_init(conn); - int rc, int_data; + int int_data; MYSQL_RES *result; MYSQL_BIND my_bind[1]; - rc = mysql_autocommit(conn, 1); + mysql_autocommit(conn, 1); if (NULL == stmt) { diff --git a/maxscale-system-test/mxs365.cpp b/maxscale-system-test/mxs365.cpp index 2cc057ffb..162b4c149 100644 --- a/maxscale-system-test/mxs365.cpp +++ b/maxscale-system-test/mxs365.cpp @@ -24,7 +24,7 @@ void create_data_file(char* filename, size_t size) while (filesize < maxsize) { char buffer[1024]; - sprintf(buffer, "%d,'%x','%x'\n", i, i << 10 + i, i << 5 + i); + sprintf(buffer, "%d,'%x','%x'\n", i, i << (10 + i), i << (5 + i)); int written = write(fd, buffer, strlen(buffer)); if (written <= 0) { @@ -67,8 +67,8 @@ int main(int argc, char *argv[]) test->tprintf("Re-connect to Maxscale\n"); test->set_timeout(20); test->maxscales->connect_maxscale(0); - char query[1024]; - snprintf(query, sizeof (filename), + char query[1024 + sizeof(filename)]; + snprintf(query, sizeof (query), "LOAD DATA LOCAL INFILE '%s' INTO TABLE test.dump FIELDS TERMINATED BY ','", filename); test->tprintf("Loading data\n"); diff --git a/maxscale-system-test/mxs548_short_session_change_user.cpp b/maxscale-system-test/mxs548_short_session_change_user.cpp index 17878a9b7..d2b452beb 100644 --- a/maxscale-system-test/mxs548_short_session_change_user.cpp +++ b/maxscale-system-test/mxs548_short_session_change_user.cpp @@ -76,10 +76,8 @@ int main(int argc, char *argv[]) } pthread_t thread1[threads_num]; - int iret1[threads_num]; pthread_t thread_master[master_load_threads_num]; - int iret_master[master_load_threads_num]; Test->repl->connect(); Test->maxscales->connect_maxscale(0); @@ -98,13 +96,13 @@ int main(int argc, char *argv[]) /* Create independent threads each of them will create some load on Master */ for (i = 0; i < master_load_threads_num; i++) { - iret_master[i] = pthread_create(&thread_master[i], NULL, query_thread_master, &data_master[i]); + pthread_create(&thread_master[i], NULL, query_thread_master, &data_master[i]); } /* Create independent threads each of them will execute function */ for (i = 0; i < threads_num; i++) { - iret1[i] = pthread_create(&thread1[i], NULL, query_thread1, &data[i]); + pthread_create(&thread1[i], NULL, query_thread1, &data[i]); } Test->tprintf("Threads are running %d seconds \n", run_time); diff --git a/maxscale-system-test/mxs564_big_dump.cpp b/maxscale-system-test/mxs564_big_dump.cpp index a58d7ad09..f7e3a087c 100644 --- a/maxscale-system-test/mxs564_big_dump.cpp +++ b/maxscale-system-test/mxs564_big_dump.cpp @@ -54,7 +54,6 @@ int main(int argc, char *argv[]) pthread_t thread1[threads_num]; - int iret1[threads_num]; //Test->repl->flush_hosts(); Test->set_timeout(20); @@ -98,7 +97,7 @@ int main(int argc, char *argv[]) /* Create independent threads each of them will execute function */ for (i = 0; i < threads_num; i++) { - iret1[i] = pthread_create(&thread1[i], NULL, query_thread1, &data[i]); + pthread_create(&thread1[i], NULL, query_thread1, &data[i]); } Test->tprintf("Threads are running %d seconds \n", run_time); @@ -132,7 +131,7 @@ int main(int argc, char *argv[]) } for (i = 0; i < threads_num; i++) { - iret1[i] = pthread_create(&thread1[i], NULL, query_thread1, &data[i]); + pthread_create(&thread1[i], NULL, query_thread1, &data[i]); } Test->set_timeout(3 * run_time + 60); diff --git a/maxscale-system-test/mxs657_restart.cpp b/maxscale-system-test/mxs657_restart.cpp index 9f26758ee..1d8da91d4 100644 --- a/maxscale-system-test/mxs657_restart.cpp +++ b/maxscale-system-test/mxs657_restart.cpp @@ -25,7 +25,6 @@ int main(int argc, char *argv[]) { Test = new TestConnections(argc, argv); pthread_t restart_t; - int check_iret; int i, j; @@ -33,7 +32,7 @@ int main(int argc, char *argv[]) Test->set_timeout(2000); - check_iret = pthread_create(&restart_t, NULL, kill_vm_thread, NULL); + pthread_create(&restart_t, NULL, kill_vm_thread, NULL); int iter = 1000; if (Test->smoke) diff --git a/maxscale-system-test/mxs657_restart_service.cpp b/maxscale-system-test/mxs657_restart_service.cpp index a17ef5f83..05c39e5c7 100644 --- a/maxscale-system-test/mxs657_restart_service.cpp +++ b/maxscale-system-test/mxs657_restart_service.cpp @@ -32,12 +32,11 @@ void sht_rst_service() int threads_num = 5; pthread_t thread1[threads_num]; - int iret1[threads_num]; int i; for (i = 0; i < threads_num; i++) { - iret1[i] = pthread_create(&thread1[i], NULL, query_thread1, NULL); + pthread_create(&thread1[i], NULL, query_thread1, NULL); } Test->tprintf("Trying to shutdown and restart RW Split router in the loop\n"); diff --git a/maxscale-system-test/mxs729_maxadmin.cpp b/maxscale-system-test/mxs729_maxadmin.cpp index 2df74be27..edc4d2b3d 100644 --- a/maxscale-system-test/mxs729_maxadmin.cpp +++ b/maxscale-system-test/mxs729_maxadmin.cpp @@ -137,14 +137,9 @@ int main(int argc, char *argv[]) add_remove_maxadmin_user(Test); Test->tprintf("trying long wierd user\n"); - char * st10 = Test->maxscales->ssh_node_output(0, + Test->maxscales->ssh_node_output(0, "maxadmin enable account yygrgtrпрекури6н33имн756ККККЕН:УИГГГГ*?:*:*fj34oru34h275g23457g2v90590+u764gv56837fbv62381§SDFERGtrg45ergfergergefewfergt456ty", true, &exit_code); - /*Test->tprintf("Result: %s\n", st10); - if (strstr(st10, "has been successfully added") == NULL) - { - Test->add_result(1, "Wrong list of MaxAdmin users\n"); - }*/ Test->check_maxscale_alive(0); Test->maxscales->ssh_node_f(0, true, "rm -rf /var/lib/maxscale/passwd"); diff --git a/maxscale-system-test/mxs922_listener_ssl.cpp b/maxscale-system-test/mxs922_listener_ssl.cpp index 92e5feb69..59e7a527c 100644 --- a/maxscale-system-test/mxs922_listener_ssl.cpp +++ b/maxscale-system-test/mxs922_listener_ssl.cpp @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) sleep(1); test->maxscales->connect_maxscale(0); - test->try_query(test->maxscales->conn_rwsplit[0], "select @@server_id") == 0; + test->try_query(test->maxscales->conn_rwsplit[0], "select @@server_id"); config.create_ssl_listener(Config::SERVICE_RCONN_SLAVE); MYSQL *conn = open_conn(test->maxscales->readconn_master_port[0], test->maxscales->IP[0], diff --git a/maxscale-system-test/mysqlmon_failover_rolling_master.cpp b/maxscale-system-test/mysqlmon_failover_rolling_master.cpp index cc22ba144..07999c21b 100644 --- a/maxscale-system-test/mysqlmon_failover_rolling_master.cpp +++ b/maxscale-system-test/mysqlmon_failover_rolling_master.cpp @@ -185,7 +185,6 @@ void check(XTestConnections& test) } std::string values; - MYSQL_ROW row; int num_rows = mysql_num_rows(pRes); test.add_result(num_rows != i_end, "Query returned %d rows when %d rows were expected", num_rows, i_end); diff --git a/maxscale-system-test/mysqlmon_failover_stress.cpp b/maxscale-system-test/mysqlmon_failover_stress.cpp index d639daf1f..bac0f9ff3 100755 --- a/maxscale-system-test/mysqlmon_failover_stress.cpp +++ b/maxscale-system-test/mysqlmon_failover_stress.cpp @@ -227,7 +227,7 @@ private: int id = s_nRows * random_decimal_fraction(); ss_dassert(id >= 0); - ss_dassert(id <= s_nRows); + ss_dassert(id <= (int)s_nRows); return id; } @@ -503,8 +503,6 @@ void check_server_statuses(TestConnections& test) void run(TestConnections& test) { - int n_threads = Client::DEFAULT_N_CLIENTS; - cout << "\nConnecting to MaxScale." << endl; test.maxscales->connect_maxscale(); diff --git a/maxscale-system-test/mysqlmon_rejoin_bad2.cpp b/maxscale-system-test/mysqlmon_rejoin_bad2.cpp index 7b89d2551..1a39f1bd3 100644 --- a/maxscale-system-test/mysqlmon_rejoin_bad2.cpp +++ b/maxscale-system-test/mysqlmon_rejoin_bad2.cpp @@ -66,7 +66,6 @@ static void expect(TestConnections& test, const char* zServer, const char* zStat int main(int argc, char** argv) { - char result_tmp[bufsize]; interactive = strcmp(argv[argc - 1], "interactive") == 0; Mariadb_nodes::require_gtid(true); TestConnections test(argc, argv); diff --git a/maxscale-system-test/mysqlmon_switchover_stress.cpp b/maxscale-system-test/mysqlmon_switchover_stress.cpp index 209a0a8e8..ab7df2421 100644 --- a/maxscale-system-test/mysqlmon_switchover_stress.cpp +++ b/maxscale-system-test/mysqlmon_switchover_stress.cpp @@ -230,7 +230,7 @@ private: int id = s_nRows * random_decimal_fraction(); ss_dassert(id >= 0); - ss_dassert(id <= s_nRows); + ss_dassert(id <= (int)s_nRows); return id; } @@ -559,8 +559,6 @@ void switchover(TestConnections& test, int next_master_id, int current_master_id void run(TestConnections& test) { - int n_threads = Client::DEFAULT_N_CLIENTS; - cout << "\nConnecting to MaxScale." << endl; test.maxscales->connect_maxscale(); diff --git a/maxscale-system-test/non_native_setup.cpp b/maxscale-system-test/non_native_setup.cpp index 166d90d33..4855a759f 100644 --- a/maxscale-system-test/non_native_setup.cpp +++ b/maxscale-system-test/non_native_setup.cpp @@ -23,7 +23,7 @@ int main(int argc, char *argv[]) char** local_argv = &argv[1]; TestConnections * Test = new TestConnections(local_argc, local_argv); - + (void)Test; sleep(3); return 0; diff --git a/maxscale-system-test/rds_vpc.cpp b/maxscale-system-test/rds_vpc.cpp index bf10acfba..a7c6a188e 100644 --- a/maxscale-system-test/rds_vpc.cpp +++ b/maxscale-system-test/rds_vpc.cpp @@ -35,7 +35,6 @@ json_t * RDS::get_subnets_group_descr(char * json) { json_t *root; json_error_t error; - char * j; root = json_loads( json, 0, &error ); if ( !root ) @@ -167,7 +166,6 @@ int RDS::destroy_subnets() int RDS::destroy_route_tables() { json_t *root; - json_error_t error; char cmd[1024]; char * json; diff --git a/maxscale-system-test/rw_select_insert.cpp b/maxscale-system-test/rw_select_insert.cpp index 13b47c635..1935c4499 100644 --- a/maxscale-system-test/rw_select_insert.cpp +++ b/maxscale-system-test/rw_select_insert.cpp @@ -79,10 +79,7 @@ int check_com_select(long int *new_selects, long int *new_inserts, long int *sel int check_com_insert(long int *new_selects, long int *new_inserts, long int *selects, long int *inserts, Mariadb_nodes * Nodes, int expected) { - int i; int result = 0; - int NodesNum = Nodes->N; - int diff_ins = new_inserts[0] - inserts[0]; int diff_sel = new_selects[0] - selects[0]; diff --git a/maxscale-system-test/rwsplit_conn_num.cpp b/maxscale-system-test/rwsplit_conn_num.cpp index 9322f3d69..0588bbb52 100644 --- a/maxscale-system-test/rwsplit_conn_num.cpp +++ b/maxscale-system-test/rwsplit_conn_num.cpp @@ -22,7 +22,6 @@ int main(int argc, char *argv[]) MYSQL *conn[TestConnNum]; int i; int conn_num; - int res = 0; MYSQL * backend_conn; for (i = 0; i < Test->repl->N; i++) diff --git a/maxscale-system-test/server_weight.cpp b/maxscale-system-test/server_weight.cpp index c10978d70..cfc7fa4aa 100644 --- a/maxscale-system-test/server_weight.cpp +++ b/maxscale-system-test/server_weight.cpp @@ -61,11 +61,11 @@ serversize_rws=1000000 #include "testconnections.h" -void check_conn_num(TestConnections* Test, int * Nc, unsigned int conn_num) +void check_conn_num(TestConnections* Test, int * Nc) { for (int i = 0; i < 4; i++) { - conn_num = get_conn_num(Test->galera->nodes[i], Test->maxscales->IP[0], Test->maxscales->hostname[0], + int conn_num = get_conn_num(Test->galera->nodes[i], Test->maxscales->IP[0], Test->maxscales->hostname[0], (char *) "test"); Test->tprintf("connections to node %d: %u (expected: %u)\n", i, conn_num, Nc[i]); if ((i < 4) && (Nc[i] != conn_num)) @@ -96,7 +96,6 @@ int main(int argc, char *argv[]) Test->tprintf("Sleeping 15 seconds\n"); sleep(15); - unsigned int conn_num; int Nc[4]; Nc[0] = maxscale_conn_num / 6; @@ -105,7 +104,7 @@ int main(int argc, char *argv[]) Nc[3] = 0; Test->set_timeout(30); - check_conn_num(Test, Nc, conn_num); + check_conn_num(Test, Nc); for (i = 0; i < maxscale_conn_num; i++) { @@ -136,7 +135,7 @@ int main(int argc, char *argv[]) Nc[0] = maxscale_conn_num; Test->set_timeout(30); - check_conn_num(Test, Nc, conn_num); + check_conn_num(Test, Nc); for (i = 0; i < maxscale_conn_num; i++) diff --git a/maxscale-system-test/setup_binlog_gtid.cpp b/maxscale-system-test/setup_binlog_gtid.cpp index b580ac72e..20e7eada9 100644 --- a/maxscale-system-test/setup_binlog_gtid.cpp +++ b/maxscale-system-test/setup_binlog_gtid.cpp @@ -17,11 +17,6 @@ int main(int argc, char *argv[]) TestConnections * Test = new TestConnections(argc, argv); Test->set_timeout(3000); - int options_set = 3; - if (Test->smoke) - { - options_set = 1; - } Test->repl->connect(); execute_query(Test->repl->nodes[0], (char *) "DROP TABLE IF EXISTS t1;"); @@ -30,12 +25,8 @@ int main(int argc, char *argv[]) Test->binlog_master_gtid = true; Test->binlog_slave_gtid = true; -// for (int option = 0; option < options_set; option++) - //{ - // Test->binlog_cmd_option = option; Test->start_binlog(0); test_binlog(Test); - //} Test->check_log_err(0, "SET NAMES utf8mb4", false); Test->check_log_err(0, "set autocommit=1", false); diff --git a/maxscale-system-test/sql_t1.cpp b/maxscale-system-test/sql_t1.cpp index 222402b4e..6bfe3cec0 100644 --- a/maxscale-system-test/sql_t1.cpp +++ b/maxscale-system-test/sql_t1.cpp @@ -149,7 +149,7 @@ char* allocate_insert_string(int fl, int N) sql_size = 16; } - if (fl >= sql_size) + if ((size_t)fl >= sql_size) { fprintf(stderr, "Insert index %d is too large, setting it to %lu", fl, sql_size - 1); fl = sql_size - 1; @@ -212,7 +212,6 @@ int check_if_t1_exists(MYSQL *conn) { MYSQL_RES *res; MYSQL_ROW row; - unsigned long long int num_fields; int t1 = 0; if (conn != NULL) @@ -232,7 +231,7 @@ int check_if_t1_exists(MYSQL *conn) } else { - num_fields = mysql_num_fields(res); + mysql_num_fields(res); if (mysql_num_rows(res) > 0) { while ((row = mysql_fetch_row(res)) != NULL) diff --git a/maxscale-system-test/sysbench_kill_slave.cpp b/maxscale-system-test/sysbench_kill_slave.cpp index 012b2e029..d7b44cff1 100644 --- a/maxscale-system-test/sysbench_kill_slave.cpp +++ b/maxscale-system-test/sysbench_kill_slave.cpp @@ -16,14 +16,13 @@ TestConnections * Test ; pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; int exit_flag = 0; int start_flag = 0; -unsigned int old_slave; +int old_slave; void *kill_vm_thread( void *ptr ); int main(int argc, char *argv[]) { Test = new TestConnections(argc, argv); pthread_t kill_vm_thread1; - int check_iret; char sys1[4096]; int port[3]; @@ -53,7 +52,7 @@ int main(int argc, char *argv[]) for (int k = 0; k < 3; k++) { Test->tprintf("Trying test with port %d\n", port[k]); - check_iret = pthread_create( &kill_vm_thread1, NULL, kill_vm_thread, NULL); + pthread_create( &kill_vm_thread1, NULL, kill_vm_thread, NULL); if (port[k] == Test->maxscales->readconn_slave_port[0] ) { @@ -137,7 +136,7 @@ void *kill_vm_thread( void *ptr ) fflush(stdout); old_slave = 1; } - char sys1[4096]; + printf("Killing VM %s\n", Test->repl->IP[old_slave]); fflush(stdout); Test->repl->block_node(old_slave); diff --git a/maxscale-system-test/templates.h.in b/maxscale-system-test/templates.h.in index 261b0052e..aa64d2036 100644 --- a/maxscale-system-test/templates.h.in +++ b/maxscale-system-test/templates.h.in @@ -5,13 +5,13 @@ static struct { const char* test_name; const char* test_template; -} cnf_templates[] = { +} cnf_templates[] __attribute__((unused)) = { @CNF_TEMPLATES@ {NULL, NULL}}; /** The default template to use */ -static const char * default_template = "replication"; +static const char * default_template __attribute__((unused)) = "replication"; /** This is the working directory for all tests */ -static const char *test_dir = "@CMAKE_SOURCE_DIR@"; +static const char *test_dir __attribute__((unused)) = "@CMAKE_SOURCE_DIR@"; #endif diff --git a/maxscale-system-test/testconnections.cpp b/maxscale-system-test/testconnections.cpp index 7e638d579..d7705a0e3 100644 --- a/maxscale-system-test/testconnections.cpp +++ b/maxscale-system-test/testconnections.cpp @@ -67,7 +67,6 @@ void TestConnections::require_galera_version(const char *version) TestConnections::TestConnections(int argc, char *argv[]): enable_timeouts(true), global_result(0), - use_ipv6(false), use_snapshots(false), no_backend_log_copy(false), verbose(false), @@ -79,7 +78,8 @@ TestConnections::TestConnections(int argc, char *argv[]): binlog_slave_gtid(false), no_galera(false), no_vm_revert(true), - threads(4) + threads(4), + use_ipv6(false) { signal_set(SIGSEGV, sigfatal_handler); signal_set(SIGABRT, sigfatal_handler); @@ -499,7 +499,6 @@ void TestConnections::read_env() void TestConnections::print_env() { - int i; printf("Maxscale IP\t%s\n", maxscales->IP[0]); printf("Maxscale User name\t%s\n", maxscales->user_name); printf("Maxscale Password\t%s\n", maxscales->password); @@ -664,7 +663,7 @@ void TestConnections::init_maxscale(int m) for (waits = 0; waits < 15; waits++) { - if (maxscales->ssh_node(m, "/bin/sh -c \"maxadmin help > /dev/null || exit 1\"", true) == 0); + if (maxscales->ssh_node(m, "/bin/sh -c \"maxadmin help > /dev/null || exit 1\"", true) == 0) { break; } @@ -1517,11 +1516,8 @@ int TestConnections::get_client_ip(int m, char * ip) MYSQL_RES *res; MYSQL_ROW row; int ret = 1; - unsigned long long int num_fields; - //unsigned long long int row_i=0; unsigned long long int rows; unsigned long long int i; - unsigned int conn_num = 0; maxscales->connect_rwsplit(m); if (execute_query(maxscales->conn_rwsplit[m], @@ -1540,7 +1536,6 @@ int TestConnections::get_client_ip(int m, char * ip) { printf("Error: can't execute SQL-query: show processlist\n"); printf("%s\n\n", mysql_error(conn)); - conn_num = 0; } else { @@ -1548,11 +1543,10 @@ int TestConnections::get_client_ip(int m, char * ip) if (res == NULL) { printf("Error: can't get the result description\n"); - conn_num = -1; } else { - num_fields = mysql_num_fields(res); + mysql_num_fields(res); rows = mysql_num_rows(res); for (i = 0; i < rows; i++) { @@ -1906,8 +1900,6 @@ int TestConnections::revert_snapshot(char * snapshot_name) bool TestConnections::test_bad_config(int m, const char *config) { - char src[PATH_MAX]; - process_template(m, config, "./"); // Set the timeout to prevent hangs with configurations that work