Skip to content

Commit 605df79

Browse files
author
Tor Didriksen
committed
Bug #34638573 Compile MySQL with clang 15
Clang 15 comes with a few new warnings: variable 'cnt' set but not used -Wunused-but-set-variable argument 'ptr' of type 'const LinearSectionPtr[3]' with mismatched bound -Warray-parameter out-of-line definition of constexpr static data member is redundant in C++17 and is deprecated -Wdeprecated unqualified call to 'std::move' -Wunqualified-std-cast-call builtin __has_trivial_copy is deprecated; use __is_trivially_copyable instead -Wdeprecated-builtins Fix these, to get a clean build also with Clang 15. Change-Id: I315b7b77e2bf3a6bacf091aeb8887d0902d3f950 (cherry picked from commit 05a8ca809e5bc3a42359158de0d99dedf7f00b66)
1 parent 7715e8b commit 605df79

File tree

107 files changed

+217
-452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+217
-452
lines changed

client/check/mysqlcheck_core.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ static void print_result() {
269269
MYSQL_ROW row;
270270
char prev[NAME_LEN * 3 + 2];
271271
char prev_alter[MAX_ALTER_STR_SIZE];
272-
uint i;
273272
size_t dot_pos;
274273
bool found_error = false, table_rebuild = false;
275274

@@ -279,7 +278,7 @@ static void print_result() {
279278
prev[0] = '\0';
280279
prev_alter[0] = 0;
281280

282-
for (i = 0; (row = mysql_fetch_row(res)); i++) {
281+
while ((row = mysql_fetch_row(res))) {
283282
int changed = strcmp(prev, row[0]);
284283
bool status = !strcmp(row[2], "status");
285284

client/mysqlslap.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,12 +1673,11 @@ static int run_scheduler(stats *sptr, statement *stmts, uint concur,
16731673
}
16741674

16751675
extern "C" void *run_task(void *p) {
1676-
ulonglong counter = 0, queries;
1676+
ulonglong queries;
16771677
ulonglong detach_counter;
16781678
unsigned int commit_counter;
16791679
MYSQL *mysql;
16801680
MYSQL_RES *result;
1681-
MYSQL_ROW row;
16821681
statement *ptr;
16831682
thread_context *con = (thread_context *)p;
16841683

@@ -1783,7 +1782,8 @@ extern "C" void *run_task(void *p) {
17831782
fprintf(stderr, "%s: Error when storing result: %d %s\n",
17841783
my_progname, mysql_errno(mysql), mysql_error(mysql));
17851784
else {
1786-
while ((row = mysql_fetch_row(result))) counter++;
1785+
while (mysql_fetch_row(result)) {
1786+
}
17871787
mysql_free_result(result);
17881788
}
17891789
}

extra/libfido2/libfido2-1.8.0/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,9 @@ if(CMAKE_COMPILER_IS_GNUCC)
309309
endif()
310310

311311
DISABLE_MISSING_PROFILE_WARNING()
312+
IF(MY_COMPILER_IS_GNU_OR_CLANG)
313+
STRING_APPEND(CMAKE_C_FLAGS " -Wno-strict-prototypes")
314+
ENDIF()
312315

313316
# Decide which keyword to use for thread-local storage.
314317
if(CMAKE_COMPILER_IS_GNUCC OR

plugin/clone/src/clone_hton.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ int hton_clone_apply_begin(THD *thd, const char *clone_data_dir,
236236
return (clone_args.m_err);
237237
}
238238

239-
uint32_t loop_index = 0;
239+
uint32_t loop_index [[maybe_unused]] = 0;
240240

241241
for (auto &loc_iter : clone_loc_vec) {
242242
uint32_t task_id = 0;

plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/task_debug.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ char *mystrcat(char *dest, int *size, const char *src) {
3838
int current_size = *size;
3939
char *ret = dest;
4040

41-
int num = 0;
4241
while (*dest) {
43-
num++;
4442
dest++;
4543
}
4644

plugin/group_replication/src/plugin.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ SERVICE_TYPE(log_builtins_string) * log_bs;
8080
These pointers will be initialized on plugin_group_replication_init()
8181
or plugin_group_replication_start().
8282
*/
83-
constexpr gr_modules::mask gr_modules::all_modules;
8483
/** The plugin applier */
8584
Applier_module *applier_module = nullptr;
8685
/** The plugin recovery module */

router/src/harness/include/mysql/harness/net_ts/internet.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,3 @@
2323
*/
2424

2525
#include "mysql/harness/net_ts/internet.h"
26-
27-
// materialize constexpr's
28-
29-
constexpr net::ip::resolver_base::flags net::ip::resolver_base::passive;

router/src/harness/include/mysql/harness/net_ts/socket.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,3 @@
2323
*/
2424

2525
#include "mysql/harness/net_ts/socket.h"
26-
27-
// materialize constexpr's
28-
29-
constexpr net::socket_base::wait_type net::socket_base::wait_write;
30-
constexpr net::socket_base::wait_type net::socket_base::wait_read;
31-
constexpr net::socket_base::wait_type net::socket_base::wait_error;
32-
33-
constexpr net::socket_base::shutdown_type net::socket_base::shutdown_receive;
34-
constexpr net::socket_base::shutdown_type net::socket_base::shutdown_send;
35-
constexpr net::socket_base::shutdown_type net::socket_base::shutdown_both;
36-
37-
constexpr net::socket_base::message_flags net::socket_base::message_peek;
38-
constexpr net::socket_base::message_flags
39-
net::socket_base::message_do_not_route;
40-
constexpr net::socket_base::message_flags net::socket_base::message_out_of_band;

router/src/harness/src/config_parser.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ using mysql_harness::utility::strip;
5353

5454
namespace mysql_harness {
5555

56-
// satisfy ODR requirements
57-
constexpr const char *Config::DEFAULT_PATTERN;
58-
5956
bool is_valid_conf_ident_char(const char ch) {
6057
return isalnum(ch) || ch == '_';
6158
}

router/src/harness/src/logging/handler.cc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,6 @@ std::string Handler::format(const Record &record) const {
132132

133133
void Handler::handle(const Record &record) { do_log(record); }
134134

135-
// satisfy ODR
136-
constexpr const char *StreamHandler::kDefaultName;
137-
138135
////////////////////////////////////////////////////////////////
139136
// class StreamHandler
140137

@@ -159,9 +156,6 @@ NullHandler::NullHandler(bool format_messages, LogLevel level,
159156

160157
void NullHandler::do_log(const Record & /*record*/) {}
161158

162-
// satisfy ODR
163-
constexpr const char *NullHandler::kDefaultName;
164-
165159
////////////////////////////////////////////////////////////////
166160
// class FileHandler
167161

@@ -299,9 +293,6 @@ void FileHandler::do_log(const Record &record) {
299293
}
300294
}
301295

302-
// satisfy ODR
303-
constexpr const char *FileHandler::kDefaultName;
304-
305296
FileHandler::~FileHandler() = default;
306297

307298
} // namespace logging

router/src/harness/src/stdx/io/file_handle.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ using namespace std::string_literals;
6262
namespace stdx {
6363
namespace io {
6464

65-
constexpr const file_handle::native_handle_type file_handle::invalid_handle;
66-
constexpr const flag::value_type flag::unlink_on_first_close;
67-
6865
static std::error_code last_posix_error_code() {
6966
return {errno, std::generic_category()};
7067
}

router/src/harness/src/tls_server_context.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ constexpr int kMinRsaKeySize{2048};
5757
#endif
5858
constexpr int kMinDhKeySize{1024};
5959

60-
constexpr std::array<const char *, 9>
61-
TlsServerContext::unacceptable_cipher_spec;
62-
6360
namespace {
6461
const SSL_METHOD *server_method =
6562
#if OPENSSL_VERSION_NUMBER >= ROUTER_OPENSSL_VERSION(1, 1, 0)

router/src/http/src/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ TARGET_INCLUDE_DIRECTORIES(http_auth_realm PRIVATE
162162

163163
ADD_HARNESS_PLUGIN(http_server
164164
SOURCES
165-
content_type.cc
166165
http_auth.cc
167166
http_auth_method_basic.cc
168167
http_server_component.cc

router/src/http/src/base64.cc

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,3 @@
2323
*/
2424

2525
#include "../src/base64.h"
26-
27-
// instantiate the constexpr's
28-
29-
namespace Base64Alphabet {
30-
constexpr alphabet_type Base64::alphabet;
31-
constexpr inverse_alphabet_type Base64::inverse_alphabet;
32-
constexpr alphabet_type Mcf::alphabet;
33-
constexpr inverse_alphabet_type Mcf::inverse_alphabet;
34-
constexpr alphabet_type Crypt::alphabet;
35-
constexpr inverse_alphabet_type Crypt::inverse_alphabet;
36-
constexpr alphabet_type Bcrypt::alphabet;
37-
constexpr inverse_alphabet_type Bcrypt::inverse_alphabet;
38-
constexpr alphabet_type Uuencode::alphabet;
39-
constexpr inverse_alphabet_type Uuencode::inverse_alphabet;
40-
} // namespace Base64Alphabet

router/src/http/src/content_type.cc

Lines changed: 0 additions & 34 deletions
This file was deleted.

router/src/http/src/http_auth_method_basic.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@
3232

3333
#include "../src/base64.h"
3434

35-
// instantiate the constexpr members
36-
constexpr const char HttpAuthMethodBasic::kMethodName[];
37-
3835
HttpAuthMethodBasic::AuthData HttpAuthMethodBasic::decode_authorization(
3936
const std::string &http_auth_data, std::error_code &ec) {
4037
std::vector<uint8_t> decoded;

router/src/http/src/kdf_pbkdf2.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@
4242

4343
#include "base64.h"
4444

45-
constexpr char Pbkdf2McfType::kTypeSha256[];
46-
constexpr char Pbkdf2McfType::kTypeSha512[];
47-
constexpr unsigned long Pbkdf2McfAdaptor::kMaxRounds;
48-
constexpr unsigned long Pbkdf2McfAdaptor::kMinRounds;
49-
constexpr size_t Pbkdf2McfAdaptor::kMaxSaltLength;
50-
5145
std::vector<uint8_t> Pbkdf2::salt() {
5246
std::vector<uint8_t> out(16);
5347

router/src/http/src/kdf_sha_crypt.cc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,6 @@
4242

4343
#include "base64.h"
4444

45-
constexpr char ShaCryptMcfType::kTypeSha256[];
46-
constexpr char ShaCryptMcfType::kTypeSha512[];
47-
constexpr char ShaCryptMcfType::kTypeCachingSha2Password[];
48-
constexpr unsigned long ShaCryptMcfAdaptor::kDefaultRounds;
49-
constexpr unsigned long ShaCryptMcfAdaptor::kMinRounds;
50-
constexpr unsigned long ShaCryptMcfAdaptor::kMaxRounds;
51-
5245
std::string ShaCrypt::salt() {
5346
// 12 byte input, generate 16 byte output
5447
std::vector<uint8_t> out(12);

router/src/http/tests/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ SET_TARGET_PROPERTIES(routertest_http_auth_method PROPERTIES
7979

8080
add_test_file(test_content_type.cc
8181
MODULE http
82-
EXTRA_SOURCES ../src/content_type.cc
8382
)
8483
## content_type.cc is from the http_server plugin and its symbols are marked a "dllimport"
8584
## by default. As we use them directly, mark them as "static" instead.
@@ -105,7 +104,6 @@ IF(LIBFUZZER_COMPILE_FLAGS)
105104
../src/kdf_sha_crypt.cc
106105
../src/kdf_pbkdf2.cc
107106
../src/mcf_error.cc
108-
../src/base64.cc
109107
COMPONENT Router
110108
LINK_LIBRARIES ${SSL_LIBRARIES} metadata_cache
111109
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
@@ -121,7 +119,6 @@ IF(LIBFUZZER_COMPILE_FLAGS)
121119
MYSQL_ADD_EXECUTABLE(routerfuzz_auth_method_basic
122120
fuzz_auth_method_basic.cc
123121
../src/http_auth_method_basic.cc
124-
../src/base64.cc
125122
COMPONENT Router
126123
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
127124
SKIP_INSTALL
@@ -135,7 +132,6 @@ IF(LIBFUZZER_COMPILE_FLAGS)
135132
## base64
136133
MYSQL_ADD_EXECUTABLE(routerfuzz_base64
137134
fuzz_base64.cc
138-
../src/base64.cc
139135
COMPONENT Router
140136
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
141137
SKIP_INSTALL

router/src/json_schema_embedder/json_schema_embedder.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ int main(int argc, const char **argv) {
7070
"//\n"
7171
"// (see " __FILE__ ")\n"
7272
"#include \"%s\"\n"
73-
"\n"
74-
"constexpr const char %s::data_[];\n",
73+
"\n",
7574
argv[0], in_filename, out_filename, hdr_filename, symbol_name,
76-
hdr_filename, symbol_name))
75+
hdr_filename))
7776
throw_error("Failed writing output file", out_filename);
7877
if (fclose(out_file))
7978
throw_error("Failed closing output file", out_filename);

router/src/mock_server/src/authentication.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,12 @@ std::optional<std::vector<uint8_t>> MySQLNativePassword::scramble(
113113
return impl::scramble(nonce, password, EVP_sha1(), true);
114114
}
115115

116-
constexpr char MySQLNativePassword::name[];
117-
118116
// caching_sha2_password
119117

120118
std::optional<std::vector<uint8_t>> CachingSha2Password::scramble(
121119
std::string_view nonce, std::string_view password) {
122120
return impl::scramble(nonce, password, EVP_sha256(), false);
123121
}
124-
constexpr char CachingSha2Password::name[];
125122

126123
// clear_text_password
127124

@@ -134,5 +131,3 @@ std::optional<std::vector<uint8_t>> ClearTextPassword::scramble(
134131

135132
return res;
136133
}
137-
138-
constexpr char ClearTextPassword::name[];

router/src/mock_server/src/mock_server_rest_client.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@
3737
#include <stdexcept>
3838
#include <thread>
3939

40-
/* static */ constexpr std::chrono::milliseconds
41-
MockServerRestClient::kMockServerMaxRestEndpointStepTime;
42-
/* static */ constexpr std::chrono::milliseconds
43-
MockServerRestClient::kMockServerDefaultRestEndpointTimeout;
44-
4540
MockServerRestClient::MockServerRestClient(const uint16_t http_port,
4641
const std::string &http_hostname)
4742
: http_hostname_(http_hostname), http_port_(http_port) {}

router/src/rest_connection_pool/src/rest_connection_pool_config.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
#include "mysqlrouter/connection_pool_component.h"
3636
#include "mysqlrouter/rest_api_utils.h"
3737

38-
constexpr const char RestConnectionPoolConfig::path_regex[];
39-
4038
bool RestConnectionPoolConfig::on_handle_request(
4139
HttpRequest &req, const std::string & /* base_path */,
4240
const std::vector<std::string> &path_matches) {

router/src/rest_connection_pool/src/rest_connection_pool_list.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
#include "mysqlrouter/connection_pool_component.h"
3131
#include "mysqlrouter/rest_api_utils.h"
3232

33-
constexpr const char RestConnectionPoolList::path_regex[];
34-
3533
bool RestConnectionPoolList::on_handle_request(
3634
HttpRequest &req, const std::string & /* base_path */,
3735
const std::vector<std::string> & /* path_matches */) {

router/src/rest_connection_pool/src/rest_connection_pool_status.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
#include "mysqlrouter/connection_pool_component.h"
3838
#include "mysqlrouter/rest_api_utils.h"
3939

40-
constexpr const char RestConnectionPoolStatus::path_regex[];
41-
4240
bool RestConnectionPoolStatus::on_handle_request(
4341
HttpRequest &req, const std::string & /* base_path */,
4442
const std::vector<std::string> &path_matches) {

router/src/rest_metadata_cache/src/rest_clusters_list.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
#include "mysqlrouter/metadata_cache.h"
3535
#include "mysqlrouter/rest_api_utils.h"
3636

37-
constexpr const char RestClustersList::path_regex[];
38-
3937
bool RestClustersList::on_handle_request(
4038
HttpRequest &req, const std::string & /* base_path */,
4139
const std::vector<std::string> & /* path_matches */) {

router/src/rest_metadata_cache/src/rest_clusters_nodes.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
#include "mysqlrouter/metadata_cache.h"
3535
#include "mysqlrouter/rest_api_utils.h"
3636

37-
constexpr const char RestClustersNodes::path_regex[];
38-
3937
static const char *server_mode_to_string(metadata_cache::ServerMode mode) {
4038
switch (mode) {
4139
case metadata_cache::ServerMode::ReadOnly:

router/src/rest_metadata_cache/src/rest_metadata_cache_config.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
#include "mysqlrouter/metadata_cache.h"
3535
#include "mysqlrouter/rest_api_utils.h"
3636

37-
constexpr const char RestMetadataCacheConfig::path_regex[];
38-
3937
template <class AllocatorType>
4038
static rapidjson::Value json_value_from_string(const std::string &s,
4139
AllocatorType &allocator) {

0 commit comments

Comments
 (0)