From 3d325e29c4f1a14372d1072da1c2500f28c1b3d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 20 Apr 2018 09:36:42 +0300 Subject: [PATCH 1/6] MXS-1814: Log warning with log_debug in release mode With release mode binaries, the log_debug option has no effect. Now a warning is logged if the option is used. --- server/core/config.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/core/config.cc b/server/core/config.cc index 408f14342..b2b8399f8 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -1770,6 +1770,12 @@ handle_global_item(const char *name, const char *value) } else { +#ifndef SS_DEBUG + if (strcmp(name, "log_debug") == 0) + { + MXS_WARNING("The 'log_debug' option has no effect in release mode."); + } +#endif for (i = 0; lognames[i].name; i++) { if (strcasecmp(name, lognames[i].name) == 0) From 2c6d27d600a956f25bfd4c8d623e54a1401acf87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 20 Apr 2018 12:59:28 +0300 Subject: [PATCH 2/6] MXS-1815: Use all available CPUs with threads=auto The documentation stated that all CPUs would be used when threads=auto was used. In reality the behavior was the same as was with 2.0 (number of CPUs minus one). --- server/core/config.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/server/core/config.cc b/server/core/config.cc index b2b8399f8..ff41c2875 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -1433,10 +1433,7 @@ handle_global_item(const char *name, const char *value) { if (strcmp(value, CN_AUTO) == 0) { - if ((gateway.n_threads = get_processor_count()) > 1) - { - gateway.n_threads--; - } + gateway.n_threads = get_processor_count(); } else { From 0f0913fc99ccc97d8adcf98bc458f64ee1772815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 20 Apr 2018 13:54:12 +0300 Subject: [PATCH 3/6] Fix test build failures with GCC 8 GCC 8 enables -Werror=return-type by default which combined with -Werror causes the build to fail. --- maxscale-system-test/CMakeLists.txt | 2 +- maxscale-system-test/binlog_change_master.cpp | 5 ++--- maxscale-system-test/blob_test.cpp | 2 ++ maxscale-system-test/bulk_insert.cpp | 1 + maxscale-system-test/cdc_client.cpp | 2 ++ maxscale-system-test/connection_limit.cpp | 2 +- maxscale-system-test/mariadb_nodes.cpp | 6 +++--- maxscale-system-test/mariadb_nodes.h | 8 +++----- maxscale-system-test/maxinfo_func.cpp | 1 + maxscale-system-test/mxs1776_ps_exec_hang.cpp | 2 +- .../mxs657_restart_service.cpp | 2 ++ maxscale-system-test/mxs812_2.cpp | 2 ++ maxscale-system-test/rds_vpc.cpp | 5 +++-- maxscale-system-test/testconnections.cpp | 12 ++++++------ maxscale-system-test/testconnections.h | 18 ++++++------------ 15 files changed, 36 insertions(+), 34 deletions(-) diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index 02586c926..4e68fe6d5 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -53,7 +53,7 @@ add_library(testcore SHARED testconnections.cpp nodes.cpp mariadb_nodes.cpp maxs blob_test.cpp keepalived_func.cpp # Include the CDC connector in the core library ${CMAKE_SOURCE_DIR}/../connectors/cdc-connector/cdc_connector.cpp) -target_link_libraries(testcore ${MYSQL_CLIENT} ${JANSSON_LIBRARIES} z nsl m pthread ssl dl rt crypto crypt) +target_link_libraries(testcore ${MYSQL_CLIENT} ${JANSSON_LIBRARIES} z m pthread ssl dl rt crypto crypt) install(TARGETS testcore DESTINATION system-test) add_dependencies(testcore connector-c jansson) diff --git a/maxscale-system-test/binlog_change_master.cpp b/maxscale-system-test/binlog_change_master.cpp index a828d2de8..ed0e8e5e9 100644 --- a/maxscale-system-test/binlog_change_master.cpp +++ b/maxscale-system-test/binlog_change_master.cpp @@ -226,7 +226,7 @@ const char * setup_slave_gtid = MASTER_USE_GTID=Slave_pos"; -int select_new_master(TestConnections * test) +void select_new_master(TestConnections * test) { char log_file[256]; char log_file_new[256]; @@ -265,7 +265,7 @@ int select_new_master(TestConnections * test) if (!maxscale_log_file[0] || !maxscale_log_pos[0]) { test->add_result(1, "Failed to query for master status"); - return 1; + return; } test->tprintf("Real master file: %s\n", maxscale_log_file); @@ -320,7 +320,6 @@ int select_new_master(TestConnections * test) test->tprintf("slave started!\n"); test->repl->close_connections(); - } void *disconnect_thread( void *ptr ) diff --git a/maxscale-system-test/blob_test.cpp b/maxscale-system-test/blob_test.cpp index 1798de897..5727dd191 100644 --- a/maxscale-system-test/blob_test.cpp +++ b/maxscale-system-test/blob_test.cpp @@ -188,6 +188,8 @@ int check_longblob_data(TestConnections* Test, MYSQL * conn, unsigned long chunk mysql_stmt_free_result(stmt); mysql_stmt_close(stmt); + + return 0; } diff --git a/maxscale-system-test/bulk_insert.cpp b/maxscale-system-test/bulk_insert.cpp index fe83132da..6e48570d2 100644 --- a/maxscale-system-test/bulk_insert.cpp +++ b/maxscale-system-test/bulk_insert.cpp @@ -196,6 +196,7 @@ int bind_by_row(MYSQL *mysql) return show_mysql_error(mysql); } + return 0; } int main(int argc, char** argv) diff --git a/maxscale-system-test/cdc_client.cpp b/maxscale-system-test/cdc_client.cpp index f54263014..ce75208a0 100644 --- a/maxscale-system-test/cdc_client.cpp +++ b/maxscale-system-test/cdc_client.cpp @@ -251,4 +251,6 @@ void *query_thread(void *ptr) } Test->repl->close_connections(); + + return NULL; } diff --git a/maxscale-system-test/connection_limit.cpp b/maxscale-system-test/connection_limit.cpp index 7873ddf94..5083dfede 100644 --- a/maxscale-system-test/connection_limit.cpp +++ b/maxscale-system-test/connection_limit.cpp @@ -12,7 +12,7 @@ using namespace std; -int check_max_conn(int router, int max_conn, TestConnections * Test) +void check_max_conn(int router, int max_conn, TestConnections * Test) { MYSQL * conn[max_conn + 1]; diff --git a/maxscale-system-test/mariadb_nodes.cpp b/maxscale-system-test/mariadb_nodes.cpp index c90d87ead..875113e3c 100644 --- a/maxscale-system-test/mariadb_nodes.cpp +++ b/maxscale-system-test/mariadb_nodes.cpp @@ -102,7 +102,7 @@ void Mariadb_nodes::close_connections() -int Mariadb_nodes::read_env() +void Mariadb_nodes::read_env() { char * env; char env_name[64]; @@ -207,7 +207,7 @@ int Mariadb_nodes::read_env() } } -int Mariadb_nodes::print_env() +void Mariadb_nodes::print_env() { for (int i = 0; i < N; i++) { @@ -255,7 +255,7 @@ int Mariadb_nodes::find_master() return master_node; } -int Mariadb_nodes::change_master(int NewMaster, int OldMaster) +void Mariadb_nodes::change_master(int NewMaster, int OldMaster) { int i; //int OldMaster = FindMaster(); diff --git a/maxscale-system-test/mariadb_nodes.h b/maxscale-system-test/mariadb_nodes.h index a47d7b657..674d25e1c 100644 --- a/maxscale-system-test/mariadb_nodes.h +++ b/maxscale-system-test/mariadb_nodes.h @@ -168,14 +168,13 @@ public: /** * @brief reads IP, Ports, sshkeys for every node from enviromental variables as well as number of nodes (N) and User/Password - * @return 0 */ - int read_env(); + void read_env(); /** * @brief prints all nodes information * @return 0 */ - int print_env(); + void print_env(); /** * @brief find_master Tries to find Master node @@ -186,9 +185,8 @@ public: * @brief change_master set a new master node for Master/Slave setup * @param NewMaster index of new Master node * @param OldMaster index of current Master node - * @return 0 in case of success */ - int change_master(int NewMaster, int OldMaster); + void change_master(int NewMaster, int OldMaster); /** * @brief stop_nodes stops mysqld on all nodes diff --git a/maxscale-system-test/maxinfo_func.cpp b/maxscale-system-test/maxinfo_func.cpp index 9324b1db7..4b25486ce 100644 --- a/maxscale-system-test/maxinfo_func.cpp +++ b/maxscale-system-test/maxinfo_func.cpp @@ -298,4 +298,5 @@ int get_x_fl_from_json(char * line, long long int * x1, long long int * fl) json_decref(x_json); json_decref(fl_json); json_decref(root); + return 0; } diff --git a/maxscale-system-test/mxs1776_ps_exec_hang.cpp b/maxscale-system-test/mxs1776_ps_exec_hang.cpp index b98c116ba..c99f7b098 100644 --- a/maxscale-system-test/mxs1776_ps_exec_hang.cpp +++ b/maxscale-system-test/mxs1776_ps_exec_hang.cpp @@ -30,7 +30,7 @@ struct TestCase std::function func; }; -bool run_test(TestConnections& test, TestCase test_case) +void run_test(TestConnections& test, TestCase test_case) { test.maxscales->connect(); diff --git a/maxscale-system-test/mxs657_restart_service.cpp b/maxscale-system-test/mxs657_restart_service.cpp index c46a3db41..a17ef5f83 100644 --- a/maxscale-system-test/mxs657_restart_service.cpp +++ b/maxscale-system-test/mxs657_restart_service.cpp @@ -94,4 +94,6 @@ void *query_thread1( void *ptr ) Test->maxscales->execute_maxadmin_command(0, shutdown_cmd); Test->maxscales->execute_maxadmin_command(0, restart_cmd); } + + return NULL; } diff --git a/maxscale-system-test/mxs812_2.cpp b/maxscale-system-test/mxs812_2.cpp index c735b8b49..f7a6d9178 100644 --- a/maxscale-system-test/mxs812_2.cpp +++ b/maxscale-system-test/mxs812_2.cpp @@ -54,6 +54,8 @@ void* test_thr(void *data) mysql_close(mysql); } + + return NULL; } #define THREADS 5 diff --git a/maxscale-system-test/rds_vpc.cpp b/maxscale-system-test/rds_vpc.cpp index 6f9ed2bcc..bf10acfba 100644 --- a/maxscale-system-test/rds_vpc.cpp +++ b/maxscale-system-test/rds_vpc.cpp @@ -202,6 +202,7 @@ int RDS::destroy_route_tables() } } + return 0; } int RDS::detach_and_destroy_gw() @@ -552,7 +553,7 @@ int RDS::destroy_subnets_group() char * result; sprintf(cmd, "aws rds delete-db-subnet-group --db-subnet-group-name %s", get_subnetgroup_name()); puts(cmd); - execute_cmd(cmd, &result); + return execute_cmd(cmd, &result); } int RDS::create_rds_db(int N) @@ -679,7 +680,7 @@ int RDS::delete_rds_cluster() detach_and_destroy_gw(); printf("Destroy vpc\n"); - destroy_vpc(); + return destroy_vpc(); } int RDS::wait_for_nodes(size_t N) diff --git a/maxscale-system-test/testconnections.cpp b/maxscale-system-test/testconnections.cpp index 4182dadf7..7e638d579 100644 --- a/maxscale-system-test/testconnections.cpp +++ b/maxscale-system-test/testconnections.cpp @@ -22,7 +22,7 @@ static std::string required_repl_version; static std::string required_galera_version; } -static int signal_set(int sig, void (*handler)(int)) +static void signal_set(int sig, void (*handler)(int)) { struct sigaction sigact = {}; sigact.sa_handler = handler; @@ -381,7 +381,7 @@ void TestConnections::assert(bool result, const char *format, ...) } } -int TestConnections::read_env() +void TestConnections::read_env() { char *env; @@ -497,7 +497,7 @@ int TestConnections::read_env() } } -int TestConnections::print_env() +void TestConnections::print_env() { int i; printf("Maxscale IP\t%s\n", maxscales->IP[0]); @@ -611,7 +611,7 @@ void TestConnections::process_template(int m, const char *template_name, const c maxscales->copy_to_node_legacy((char *) "maxscale.cnf", (char *) dest, m); } -int TestConnections::init_maxscales() +void TestConnections::init_maxscales() { for (int i = 0; i < maxscales->N; i++) { @@ -619,7 +619,7 @@ int TestConnections::init_maxscales() } } -int TestConnections::init_maxscale(int m) +void TestConnections::init_maxscale(int m) { const char * template_name = get_template_name(test_name); @@ -1598,7 +1598,7 @@ int TestConnections::stop_timeout() return 0; } -int TestConnections::tprintf(const char *format, ...) +void TestConnections::tprintf(const char *format, ...) { timeval t2; gettimeofday(&t2, NULL); diff --git a/maxscale-system-test/testconnections.h b/maxscale-system-test/testconnections.h index 824732aa8..828fe449f 100644 --- a/maxscale-system-test/testconnections.h +++ b/maxscale-system-test/testconnections.h @@ -251,28 +251,24 @@ public: /** * @brief ReadEnv Reads all Maxscale and Master/Slave and Galera setups info from environmental variables - * @return 0 in case of success */ - int read_env(); + void read_env(); /** * @brief PrintIP Prints all Maxscale and Master/Slave and Galera setups info - * @return 0 */ - int print_env(); + void print_env(); /** * @brief InitMaxscale Copies MaxSclae.cnf and start MaxScale * @param m Number of Maxscale node - * @return 0 if case of success */ - int init_maxscale(int m = 0); + void init_maxscale(int m = 0); /** * @brief InitMaxscale Copies MaxSclae.cnf and start MaxScale on all Maxscale nodes - * @return 0 if case of success */ - int init_maxscales(); + void init_maxscales(); /** * @brief start_binlog configure first node as Master, Second as slave connected to Master and others as slave connected to MaxScale binlog router @@ -366,11 +362,9 @@ public: int stop_timeout(); /** - * @brief printf adds timestam to printf - * @param __format - * @return + * @brief printf with automatic timestamps */ - int tprintf(const char *format, ...); + void tprintf(const char *format, ...); /** * @brief Creats t1 table, insert data into it and checks if data can be correctly read from all Maxscale services 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 4/6] 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 From 8829e6d0c5f370b270c2d0ca8bb3b181b75ddcd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 20 Apr 2018 20:30:51 +0300 Subject: [PATCH 5/6] Reorder REST API configuration documentation The REST API configuration documentation is now located after all other global parameters in its own section. Added it to the ToC and put a link to it into the REST API overview document. --- .../Getting-Started/Configuration-Guide.md | 111 +++++++++--------- Documentation/REST-API/API.md | 5 + 2 files changed, 61 insertions(+), 55 deletions(-) diff --git a/Documentation/Getting-Started/Configuration-Guide.md b/Documentation/Getting-Started/Configuration-Guide.md index d9cfe0339..34fe181e5 100644 --- a/Documentation/Getting-Started/Configuration-Guide.md +++ b/Documentation/Getting-Started/Configuration-Guide.md @@ -13,6 +13,7 @@ plugin modules that tailor the behavior of the program. * [Configuration](#configuration) * [Special Parameter Types](#special-parameter-types) * [Global Settings](#global-settings) + * [REST API Configuration](#rest-api-configuration) * [Service](#service) * [Server](#server) * [Listener](#listener) @@ -607,61 +608,6 @@ is placed in the configuration file. However, in the `[maxscale]` section, to ensure that substitution will take place, place the `substitute_variables=true` line first. -### REST API Configuration - -The MaxScale REST API is an HTTP interface that provides JSON format data -intended to be consumed by monitoring appllications and visualization tools. - -The following options must be defined under the `[maxscale]` section in the -configuration file. - -#### `admin_host` - -The network interface where the HTTP admin interface listens on. The default -value is the IPv4 address `127.0.0.1` which only listens for local connections. - -#### `admin_port` - -The port where the HTTP admin interface listens on. The default value is port -8989. - -#### `admin_auth` - -Enable HTTP admin interface authentication using HTTP Basic Access -authentication. This is not a secure method of authentication without HTTPS but -it does add a small layer of security. This option is enabled by default. - -The admin interface authentication uses the same user as MaxAdmin network -interface. This means that new users can be added with both MaxAdmin and the -REST API. The default credentials for the interface are `admin:mariadb`. - -#### `admin_ssl_key` - -The path to the TLS private key in PEM format for the admin interface. - -If the `admin_ssl_key`, `admin_ssl_cert` and `admin_ssl_ca_cert` options are all -defined, the admin interface will use encrypted HTTPS instead of plain HTTP. - -#### `admin_ssl_cert` - -The path to the TLS public certificate in PEM format. See `admin_ssl_key` -documentation for more details. - -#### `admin_ssl_ca_cert` - -The path to the TLS CA certificate in PEM format. See `admin_ssl_key` -documentation for more details. - -#### `admin_enabled` - -Enable or disable the admin interface. This allows the admin interface to -be completely disabled to prevent access to it. - -#### `admin_log_auth_failures` - -Log authentication failures for the admin interface. This parameter expects a -boolean value and is enabled by default. - #### `sql_mode` Specifies whether the query classifier parser should initially expect _MariaDB_ @@ -760,6 +706,61 @@ Note that you need to specify with `retain_last_statements` how many statements MaxScale should retain for each session. Unless it has been set to another value than `0`, this configuration setting will not have an effect. +### REST API Configuration + +The MaxScale REST API is an HTTP interface that provides JSON format data +intended to be consumed by monitoring appllications and visualization tools. + +The following options must be defined under the `[maxscale]` section in the +configuration file. + +#### `admin_host` + +The network interface where the HTTP admin interface listens on. The default +value is the IPv4 address `127.0.0.1` which only listens for local connections. + +#### `admin_port` + +The port where the HTTP admin interface listens on. The default value is port +8989. + +#### `admin_auth` + +Enable HTTP admin interface authentication using HTTP Basic Access +authentication. This is not a secure method of authentication without HTTPS but +it does add a small layer of security. This option is enabled by default. + +The admin interface authentication uses the same user as MaxAdmin network +interface. This means that new users can be added with both MaxAdmin and the +REST API. The default credentials for the interface are `admin:mariadb`. + +#### `admin_ssl_key` + +The path to the TLS private key in PEM format for the admin interface. + +If the `admin_ssl_key`, `admin_ssl_cert` and `admin_ssl_ca_cert` options are all +defined, the admin interface will use encrypted HTTPS instead of plain HTTP. + +#### `admin_ssl_cert` + +The path to the TLS public certificate in PEM format. See `admin_ssl_key` +documentation for more details. + +#### `admin_ssl_ca_cert` + +The path to the TLS CA certificate in PEM format. See `admin_ssl_key` +documentation for more details. + +#### `admin_enabled` + +Enable or disable the admin interface. This allows the admin interface to +be completely disabled to prevent access to it. + +#### `admin_log_auth_failures` + +Log authentication failures for the admin interface. This parameter expects a +boolean value and is enabled by default. + ### Service A service represents the database service that MariaDB MaxScale offers to the diff --git a/Documentation/REST-API/API.md b/Documentation/REST-API/API.md index ee066af3d..f5db82172 100644 --- a/Documentation/REST-API/API.md +++ b/Documentation/REST-API/API.md @@ -21,6 +21,11 @@ Although JSON does not define a syntax for comments, some of the JSON examples have C-style inline comments in them. These comments use `//` to mark the start of the comment and extend to the end of the current line. +## Configuration + +Read the [REST API](../Getting-Started/Configuration-Guide.md#rest-api-configuration) +section of the configuration guide for more details on how to configure the REST API. + ## Authentication The MaxScale REST API uses [HTTP Basic Access](https://tools.ietf.org/html/rfc2617#section-2) From d67320e06aeccbb9fe4a2e0d7115222c17434032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 20 Apr 2018 23:08:57 +0300 Subject: [PATCH 6/6] Fix more GCC 8 build failures Fixed string truncation warnings by reducing max parameter lengths by one where applicable. The binlogrouter filename lengths are slightly different so using memcpy to work around the warnings is an adequate "solution" until the root of the problem is solved. Removed unnecessary CMake policy settings from qc_sqlite. Adding a self-dependency on the source file of an external project has no effect and only caused warnings to be logged. --- query_classifier/qc_sqlite/CMakeLists.txt | 5 ----- server/core/config.cc | 3 ++- server/core/internal/skygw_utils.h | 6 +++--- server/inih/ini.c | 4 ++-- server/modules/routing/binlogrouter/blr_file.c | 4 ++-- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/query_classifier/qc_sqlite/CMakeLists.txt b/query_classifier/qc_sqlite/CMakeLists.txt index 59c82a1ac..345e48610 100644 --- a/query_classifier/qc_sqlite/CMakeLists.txt +++ b/query_classifier/qc_sqlite/CMakeLists.txt @@ -1,7 +1,3 @@ -if(NOT ${CMAKE_VERSION} VERSION_LESS 3.0.0) - cmake_policy(SET CMP0046 OLD) -endif() - include(ExternalProject) ExternalProject_Add(maxscale_sqlite @@ -10,7 +6,6 @@ ExternalProject_Add(maxscale_sqlite CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/sqlite-src-3110100/configure --with-pic --enable-maxscale BUILD_COMMAND make sqlite3.c INSTALL_COMMAND "") -add_dependencies(maxscale_sqlite ${CMAKE_CURRENT_SOURCE_DIR}/sqlite-src-3110100/src/parse.y) include_directories(${CMAKE_BINARY_DIR}/sqlite-bld-3110100/tsrc) include_directories(${CMAKE_BINARY_DIR}/sqlite-bld-3110100) diff --git a/server/core/config.cc b/server/core/config.cc index ff41c2875..469d65482 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -2537,7 +2537,8 @@ config_get_release_string(char* release) } have_distribution = true; - strncpy(release, new_to, RELEASE_STR_LENGTH); + strncpy(release, new_to, RELEASE_STR_LENGTH - 1); + release[RELEASE_STR_LENGTH - 1] = '\0'; } } } diff --git a/server/core/internal/skygw_utils.h b/server/core/internal/skygw_utils.h index 1c4b6e85c..6fca7cc1c 100644 --- a/server/core/internal/skygw_utils.h +++ b/server/core/internal/skygw_utils.h @@ -46,12 +46,12 @@ typedef enum { MES_RC_FAIL, MES_RC_SUCCESS, MES_RC_TIMEOUT } skygw_mes_rc_t; static const char* timestamp_formatstr = "%04d-%02d-%02d %02d:%02d:%02d "; /** One for terminating '\0' */ -static const size_t timestamp_len = (4 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 3 + 1) * sizeof(char); +static const size_t timestamp_len = (4 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 3 + 1 + 16) * sizeof(char); static const char* timestamp_formatstr_hp = "%04d-%02d-%02d %02d:%02d:%02d.%03d "; /** One for terminating '\0' */ -static const size_t timestamp_len_hp = (4 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 3 + 3 + 1) * sizeof( - char); +static const size_t timestamp_len_hp = (4 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 2 + 1 + 3 + 3 + 1 + 16) * + sizeof(char); struct skygw_thread_st { diff --git a/server/inih/ini.c b/server/inih/ini.c index 9f9110eaf..ac185fb55 100644 --- a/server/inih/ini.c +++ b/server/inih/ini.c @@ -117,7 +117,7 @@ int ini_parse_file(FILE* file, end = find_char_or_comment(start + 1, ']'); if (*end == ']') { *end = '\0'; - strncpy0(section, start + 1, sizeof(section)); + strncpy0(section, start + 1, sizeof(section) - 1); *prev_name = '\0'; } else if (!error) { @@ -141,7 +141,7 @@ int ini_parse_file(FILE* file, rstrip(value); /* Valid name[=:]value pair found, call handler */ - strncpy0(prev_name, name, sizeof(prev_name)); + strncpy0(prev_name, name, sizeof(prev_name) - 1); if (!handler(user, section, name, value) && !error) error = lineno; } diff --git a/server/modules/routing/binlogrouter/blr_file.c b/server/modules/routing/binlogrouter/blr_file.c index 8561621d4..81cc564c2 100644 --- a/server/modules/routing/binlogrouter/blr_file.c +++ b/server/modules/routing/binlogrouter/blr_file.c @@ -1669,7 +1669,7 @@ blr_file_next_exists(ROUTER_INSTANCE *router, sprintf(buf, BINLOG_NAMEFMT, router->fileroot, filenum + 1); sprintf(bigbuf, "%s/%s", router->binlogdir, buf); // Set the new file name in the output - strncpy(next_file, buf, BINLOG_FNAMELEN); + memcpy(next_file, buf, BINLOG_FNAMELEN); next_file[BINLOG_FNAMELEN] = '\0'; } else @@ -1712,7 +1712,7 @@ blr_file_next_exists(ROUTER_INSTANCE *router, result.gtid_elms.server_id, result.file); // Set the new file name in the output - strncpy(next_file, result.file, BINLOG_FNAMELEN); + memcpy(next_file, result.file, BINLOG_FNAMELEN); next_file[BINLOG_FNAMELEN] = '\0'; MXS_DEBUG("The next Binlog file from GTID maps repo is [%s]",