diff --git a/Documentation/Getting-Started/Configuration-Guide.md b/Documentation/Getting-Started/Configuration-Guide.md index cc98e209d..3e9511166 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) diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index e3c198c79..79cd9cf23 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() @@ -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/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 a828d2de8..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(); @@ -226,10 +223,9 @@ 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]; char log_pos[256]; char maxscale_log_file[256]; @@ -265,7 +261,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 +316,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..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; @@ -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/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/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/cache_runtime.cpp b/maxscale-system-test/cache_runtime.cpp index bceeed138..9b8eaa341 100644 --- a/maxscale-system-test/cache_runtime.cpp +++ b/maxscale-system-test/cache_runtime.cpp @@ -136,9 +136,6 @@ void init(TestConnections& test) void run(TestConnections& test) { init(test); - - MYSQL* pMysql = test.maxscales->conn_rwsplit[0]; - int value; // Let's populate the cache. diff --git a/maxscale-system-test/cache_runtime_ttl.cpp b/maxscale-system-test/cache_runtime_ttl.cpp index 38fdd5697..5be27708e 100644 --- a/maxscale-system-test/cache_runtime_ttl.cpp +++ b/maxscale-system-test/cache_runtime_ttl.cpp @@ -145,9 +145,6 @@ void init(TestConnections& test) void run(TestConnections& test) { init(test); - - MYSQL* pMysql = test.maxscales->conn_rwsplit[0]; - int value; // Let's set a long hard_ttl so that it will not interfere diff --git a/maxscale-system-test/cdc_client.cpp b/maxscale-system-test/cdc_client.cpp index f54263014..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 @@ -251,4 +247,6 @@ void *query_thread(void *ptr) } Test->repl->close_connections(); + + return NULL; } 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/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/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 4643813f2..da886c881 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) @@ -536,7 +534,7 @@ Row get_row(MYSQL* conn, std::string sql) if (row) { - for (int i = 0; i < mysql_num_fields(res); i++) + for (unsigned int i = 0; i < mysql_num_fields(res); i++) { rval.push_back(row[i]); } diff --git a/maxscale-system-test/mariadb_nodes.cpp b/maxscale-system-test/mariadb_nodes.cpp index f4238a836..388c0fee3 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) { for (int i = 0; i < N; i++) { diff --git a/maxscale-system-test/mariadb_nodes.h b/maxscale-system-test/mariadb_nodes.h index a47d7b657..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 @@ -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..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); @@ -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/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/mxs1506_no_master.cpp b/maxscale-system-test/mxs1506_no_master.cpp index 1b95c71f4..3225a610f 100644 --- a/maxscale-system-test/mxs1506_no_master.cpp +++ b/maxscale-system-test/mxs1506_no_master.cpp @@ -15,7 +15,7 @@ using namespace std; bool query(TestConnections& test) { test.maxscales->connect(); - execute_query_silent(test.maxscales->conn_rwsplit[0], "SET @a = 1") == 0; + execute_query_silent(test.maxscales->conn_rwsplit[0], "SET @a = 1"); sleep(5); Row row = get_row(test.maxscales->conn_rwsplit[0], "SELECT @a"); test.maxscales->disconnect(); 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/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/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 c46a3db41..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"); @@ -94,4 +93,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/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/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/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 6f9ed2bcc..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; @@ -202,6 +200,7 @@ int RDS::destroy_route_tables() } } + return 0; } int RDS::detach_and_destroy_gw() @@ -552,7 +551,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 +678,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/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 4182dadf7..d7705a0e3 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; @@ -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); @@ -381,7 +381,7 @@ void TestConnections::assert(bool result, const char *format, ...) } } -int TestConnections::read_env() +void TestConnections::read_env() { char *env; @@ -497,9 +497,8 @@ int TestConnections::read_env() } } -int TestConnections::print_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); @@ -611,7 +610,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 +618,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); @@ -664,7 +663,7 @@ int 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++) { @@ -1598,7 +1592,7 @@ int TestConnections::stop_timeout() return 0; } -int TestConnections::tprintf(const char *format, ...) +void TestConnections::tprintf(const char *format, ...) { timeval t2; gettimeofday(&t2, NULL); @@ -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 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 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 5f44fed37..522be53f7 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -1454,10 +1454,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 { @@ -1819,6 +1816,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) @@ -2585,7 +2588,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]",