Skip to content

Commit 7079e5e

Browse files
author
Tor Didriksen
committed
Bug#35877574 Enable -Wformat for clang on windows
The -Werror compiler option is currently disabled for debug builds with clang on Windows. Enable it, and fix all warnings. Change-Id: I79541fcf29037a8bf528fe582ad9e0cce00e240a
1 parent bcafe25 commit 7079e5e

File tree

18 files changed

+58
-52
lines changed

18 files changed

+58
-52
lines changed

CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,11 +2088,6 @@ INCLUDE(maintainer)
20882088
INCLUDE(msvc_cppcheck)
20892089
DO_MSVC_CPPCHECK()
20902090

2091-
IF(WIN32_CLANG AND CMAKE_BUILD_TYPE_UPPER STREQUAL "DEBUG")
2092-
# Not yet fixed for Debug code
2093-
STRING_APPEND(CMAKE_CXX_FLAGS " -Wno-format")
2094-
ENDIF()
2095-
20962091
IF(WITH_UNIT_TESTS)
20972092
ENABLE_TESTING()
20982093
INCLUDE(googletest)

client/mysqltest.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8203,9 +8203,9 @@ void fix_win_paths(const char *val, size_t len [[maybe_unused]]) {
82038203
DBUG_PRINT("info", ("Converted \\ to / in %s", val));
82048204
}
82058205
}
8206-
DBUG_PRINT("exit", (" val: %s, len: %d", val, len));
8206+
DBUG_PRINT("exit", (" val: %s, len: %zu", val, len));
82078207
}
8208-
#endif
8208+
#endif // _WIN32
82098209

82108210
/*
82118211
Append the result for one field to the dynamic string ds

include/mysql/components/services/bits/my_io_bits.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ typedef int MY_MODE;
5353
typedef int mode_t;
5454
typedef int socket_len_t;
5555
typedef SOCKET my_socket;
56+
#define MY_SOCKET_FMT "%llu"
5657
#else
5758
typedef mode_t MY_MODE;
5859
typedef socklen_t socket_len_t;
5960
typedef int my_socket; /* File descriptor for sockets */
61+
#define MY_SOCKET_FMT "%d"
6062
#endif /* _WIN32 */
6163

6264
#endif /* COMPONENTS_SERVICES_BITS_MY_IO_BITS_H */

libmysql/authentication_win/common.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Sid::Sid(const wchar_t *account_name)
141141
#ifndef NDEBUG
142142
Error_message_buf error_buf;
143143
DBUG_PRINT("error", ("Could not determine SID buffer size, "
144-
"LookupAccountName() failed with error %X (%s)",
144+
"LookupAccountName() failed with error %lX (%s)",
145145
GetLastError(), get_last_error_message(error_buf)));
146146
#endif
147147
return;
@@ -160,7 +160,7 @@ Sid::Sid(const wchar_t *account_name)
160160
#ifndef NDEBUG
161161
Error_message_buf error_buf;
162162
DBUG_PRINT("error", ("Could not determine SID of '%S', "
163-
"LookupAccountName() failed with error %X (%s)",
163+
"LookupAccountName() failed with error %lX (%s)",
164164
account_name, GetLastError(),
165165
get_last_error_message(error_buf)));
166166
#endif
@@ -203,7 +203,7 @@ Sid::Sid(HANDLE token)
203203
#ifndef NDEBUG
204204
Error_message_buf error_buf;
205205
DBUG_PRINT("error", ("Could not determine SID buffer size, "
206-
"GetTokenInformation() failed with error %X (%s)",
206+
"GetTokenInformation() failed with error %lX (%s)",
207207
GetLastError(), get_last_error_message(error_buf)));
208208
#endif
209209
return;
@@ -219,7 +219,7 @@ Sid::Sid(HANDLE token)
219219
if (!success) {
220220
Error_message_buf error_buf;
221221
DBUG_PRINT("error", ("Could not read SID from security token, "
222-
"GetTokenInformation() failed with error %X (%s)",
222+
"GetTokenInformation() failed with error %lX (%s)",
223223
GetLastError(), get_last_error_message(error_buf)));
224224
}
225225
#endif
@@ -259,7 +259,7 @@ const char *Sid::as_string() {
259259
#ifndef NDEBUG
260260
Error_message_buf error_buf;
261261
DBUG_PRINT("error", ("Could not get textual representation of a SID, "
262-
"ConvertSidToStringSid() failed with error %X (%s)",
262+
"ConvertSidToStringSid() failed with error %lX (%s)",
263263
GetLastError(), get_last_error_message(error_buf)));
264264
#endif
265265
m_as_string = nullptr;
@@ -297,7 +297,7 @@ UPN::UPN() : m_buf(nullptr) {
297297
#ifndef NDEBUG
298298
Error_message_buf error_buf;
299299
DBUG_PRINT("note", ("When determining UPN"
300-
", GetUserNameEx() failed with error %X (%s)",
300+
", GetUserNameEx() failed with error %lX (%s)",
301301
GetLastError(), get_last_error_message(error_buf)));
302302
#endif
303303
if (ERROR_MORE_DATA == GetLastError())
@@ -382,7 +382,7 @@ char *wchar_to_utf8(const wchar_t *string, size_t *len) {
382382
Error_message_buf error_buf;
383383
DBUG_PRINT("error",
384384
("Could not convert string '%S' to utf8"
385-
", WideCharToMultiByte() failed with error %X (%s)",
385+
", WideCharToMultiByte() failed with error %lX (%s)",
386386
string, GetLastError(), get_last_error_message(error_buf)));
387387
#endif
388388

@@ -443,7 +443,7 @@ wchar_t *utf8_to_wchar(const char *string, size_t *len) {
443443
#ifndef NDEBUG
444444
Error_message_buf error_buf;
445445
DBUG_PRINT("error", ("Could not convert UPN from UTF-8"
446-
", MultiByteToWideChar() failed with error %X (%s)",
446+
", MultiByteToWideChar() failed with error %lX (%s)",
447447
GetLastError(), get_last_error_message(error_buf)));
448448
#endif
449449

libmysql/authentication_win/handshake.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Handshake::Handshake(const char *ssp, side_t side)
6060

6161
if (ret != SEC_E_OK) {
6262
DBUG_PRINT("error", ("AcqireCredentialsHandle() failed"
63-
" with error %X",
63+
" with error %lX",
6464
ret));
6565
ERROR_LOG(ERROR, ("Could not obtain local credentials"
6666
" required for authentication"));
@@ -106,7 +106,7 @@ int Handshake::packet_processing_loop() {
106106
ERROR_LOG(ERROR, ("Error reading packet in round %d", m_round));
107107
return 1;
108108
}
109-
DBUG_PRINT("info", ("Got packet of length %d", packet.len()));
109+
DBUG_PRINT("info", ("Got packet of length %zu", packet.len()));
110110

111111
/*
112112
Process received data, possibly generating new data to be sent.
@@ -127,7 +127,7 @@ int Handshake::packet_processing_loop() {
127127
if (!new_data.is_null()) {
128128
DBUG_PRINT("info", ("Round %d started", m_round));
129129

130-
DBUG_PRINT("info", ("Sending packet of length %d", new_data.len()));
130+
DBUG_PRINT("info", ("Sending packet of length %zu", new_data.len()));
131131
const int ret = write_packet(new_data);
132132
if (ret) {
133133
ERROR_LOG(ERROR, ("Error writing packet in round %d", m_round));

libmysql/authentication_win/handshake_client.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ int Handshake_client::write_packet(Blob &data) {
144144

145145
if (m_round == 1 && data.len() > 254) {
146146
len2 = data.len() - 254;
147-
DBUG_PRINT("info", ("Splitting first packet of length %lu"
148-
", %lu bytes will be sent in a second part",
147+
DBUG_PRINT("info", ("Splitting first packet of length %zu"
148+
", %zu bytes will be sent in a second part",
149149
data.len(), len2));
150150
/*
151151
Store in byte 255 the number of 512b blocks that are needed to
@@ -277,7 +277,7 @@ Blob Handshake_client::process_data(const Blob &data) {
277277

278278
if (process_result(ret)) {
279279
DBUG_PRINT("error",
280-
("InitializeSecurityContext() failed with error %X", ret));
280+
("InitializeSecurityContext() failed with error %lX", ret));
281281
return Blob();
282282
}
283283

@@ -447,7 +447,7 @@ int win_auth_handshake_client(MYSQL_PLUGIN_VIO *vio, MYSQL *mysql) {
447447
ERROR_LOG(ERROR, ("Error reading initial packet"));
448448
return CR_ERROR;
449449
}
450-
DBUG_PRINT("info", ("Got initial packet of length %d", service_name.len()));
450+
DBUG_PRINT("info", ("Got initial packet of length %zu", service_name.len()));
451451

452452
// Create authentication handshake context using the given service name.
453453

mysys/my_lib.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags) {
197197
void *rawmem = nullptr;
198198

199199
DBUG_TRACE;
200-
DBUG_PRINT("my", ("path: '%s' stat: %d MyFlags: %d", path, MyFlags));
200+
DBUG_PRINT("my", ("path: '%s' MyFlags: %d", path, MyFlags));
201201

202202
/* Put LIB-CHAR as last path-character if not there */
203203
tmp_file = tmp_path;

plugin/x/src/client.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,8 @@ void Client::on_client_addr() {
448448

449449
void Client::on_accept() {
450450
DBUG_TRACE;
451-
log_debug("%s: Accepted client connection from %s (sock:%i)", client_id(),
452-
client_address(), m_connection->get_fd());
451+
log_debug("%s: Accepted client connection from %s (sock:" MY_SOCKET_FMT ")",
452+
client_id(), client_address(), m_connection->get_fd());
453453

454454
DBUG_EXECUTE_IF("client_accept_timeout", {
455455
int32_t i = 0;

sql-common/client.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6681,9 +6681,9 @@ static mysql_state_machine_status csm_begin_connect(mysql_async_connect *ctx) {
66816681

66826682
DBUG_PRINT("info", ("No success, try next address."));
66836683
}
6684-
DBUG_PRINT("info",
6685-
("End of connect attempts, sock: %d status: %d error: %d",
6686-
sock, status, saved_error));
6684+
DBUG_PRINT("info", ("End of connect attempts, sock: " MY_SOCKET_FMT
6685+
" status: %d error: %d",
6686+
sock, status, saved_error));
66876687

66886688
freeaddrinfo(res_lst);
66896689
if (client_bind_ai_lst) freeaddrinfo(client_bind_ai_lst);

sql/rpl_replica.cc

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4364,21 +4364,26 @@ static int sql_delay_event(Log_event *ev, THD *thd, Relay_log_info *rli) {
43644364
if (sql_delay_end > now) {
43654365
nap_time = sql_delay_end - now;
43664366

4367-
DBUG_PRINT("info",
4368-
("sql_delay= %lu "
4369-
"now= %ld "
4370-
"sql_delay_end= %ld "
4371-
"nap_time= %ld",
4372-
sql_delay, (long)now, (long)sql_delay_end, (long)nap_time));
4373-
DBUG_PRINT("info", ("delaying replication event %lu secs", nap_time));
4367+
DBUG_PRINT(
4368+
"info",
4369+
("sql_delay= %lu "
4370+
"now= %ld "
4371+
"sql_delay_end= %ld "
4372+
"nap_time= %ld",
4373+
static_cast<unsigned long>(sql_delay), static_cast<long>(now),
4374+
static_cast<long>(sql_delay_end), static_cast<long>(nap_time)));
4375+
DBUG_PRINT("info", ("delaying replication event %lu secs",
4376+
static_cast<unsigned long>(nap_time)));
43744377
rli->start_sql_delay(sql_delay_end);
43754378
mysql_mutex_unlock(&rli->data_lock);
43764379
return slave_sleep(thd, nap_time, sql_slave_killed, rli);
43774380
} else {
4378-
DBUG_PRINT("info", ("sql_delay= %lu "
4379-
"now= %ld "
4380-
"sql_delay_end= %ld ",
4381-
sql_delay, (long)now, (long)sql_delay_end));
4381+
DBUG_PRINT("info",
4382+
("sql_delay= %lu "
4383+
"now= %ld "
4384+
"sql_delay_end= %ld ",
4385+
static_cast<unsigned long>(sql_delay),
4386+
static_cast<long>(now), static_cast<long>(sql_delay_end)));
43824387
}
43834388
}
43844389
}

sql/sql_thd_internal_api.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ void thd_init(THD *thd, char *stack_start) {
125125

126126
if (!thd->system_thread) {
127127
DBUG_PRINT("info",
128-
("init new connection. thd: %p fd: %d", thd,
128+
("init new connection. thd: %p fd: " MY_SOCKET_FMT, thd,
129129
mysql_socket_getfd(
130130
thd->get_protocol_classic()->get_vio()->mysql_socket)));
131131
}

storage/innobase/buf/buf0rea.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,9 @@ ulint buf_read_ahead_linear(const page_id_t &page_id,
571571
os_aio_simulated_wake_handler_threads();
572572

573573
if (count) {
574-
DBUG_PRINT("ib_buf", ("linear read-ahead %lu pages, " UINT32PF ":" UINT32PF,
575-
count, page_id.space(), page_id.page_no()));
574+
DBUG_PRINT("ib_buf",
575+
("linear read-ahead " ULINTPF " pages, " UINT32PF ":" UINT32PF,
576+
count, page_id.space(), page_id.page_no()));
576577
}
577578

578579
/* Read ahead is considered one I/O operation for the purpose of

storage/innobase/dict/dict0dict.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3606,7 +3606,7 @@ ulint dict_table_get_highest_foreign_id(
36063606

36073607
biggest_id = (size > biggest_id) ? size : biggest_id;
36083608

3609-
DBUG_PRINT("dict_table_get_highest_foreign_id", ("id: %lu", biggest_id));
3609+
DBUG_PRINT("dict_table_get_highest_foreign_id", ("id: " ULINTPF, biggest_id));
36103610

36113611
return biggest_id;
36123612
}

storage/innobase/que/que0que.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ void que_graph_free_recursive(que_node_t *node) /*!< in: query graph node */
375375
}
376376

377377
DBUG_PRINT("que_graph_free_recursive",
378-
("node: %p, type: %lu", node, que_node_get_type(node)));
378+
("node: %p, type: " ULINTPF, node, que_node_get_type(node)));
379379

380380
switch (que_node_get_type(node)) {
381381
case QUE_NODE_FORK:

storage/innobase/row/row0upd.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3159,8 +3159,9 @@ static dberr_t row_upd(upd_node_t *node, /*!< in: row update node */
31593159
ut_ad(!node->table->skip_alter_undo);
31603160

31613161
DBUG_PRINT("row_upd", ("table: %s", node->table->name.m_name));
3162-
DBUG_PRINT("row_upd", ("info bits in update vector: 0x%lx",
3163-
node->update ? node->update->info_bits : 0));
3162+
DBUG_PRINT("row_upd",
3163+
("info bits in update vector: " IF_WIN("0x%llx", "0x%lx"),
3164+
node->update ? node->update->info_bits : 0));
31643165
DBUG_PRINT("row_upd",
31653166
("foreign_id: %s", node->foreign ? node->foreign->id : "NULL"));
31663167

vio/vio.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ Vio &Vio::operator=(Vio &&vio) {
210210

211211
static bool vio_init(Vio *vio, enum enum_vio_type type, my_socket sd,
212212
uint flags) {
213-
DBUG_PRINT("enter vio_init", ("type: %d sd: %d flags: %d", type, sd, flags));
213+
DBUG_PRINT("enter vio_init",
214+
("type: %d sd: " MY_SOCKET_FMT " flags: %d", type, sd, flags));
214215

215216
mysql_socket_setfd(&vio->mysql_socket, sd);
216217

@@ -426,7 +427,7 @@ Vio *mysql_socket_vio_new(MYSQL_SOCKET mysql_socket, enum_vio_type type,
426427
Vio *vio;
427428
my_socket sd = mysql_socket_getfd(mysql_socket);
428429
DBUG_TRACE;
429-
DBUG_PRINT("enter", ("sd: %d", sd));
430+
DBUG_PRINT("enter", ("sd: " MY_SOCKET_FMT, sd));
430431

431432
if ((vio = internal_vio_create(flags))) {
432433
if (vio_init(vio, type, sd, flags)) {
@@ -444,7 +445,7 @@ Vio *vio_new(my_socket sd, enum enum_vio_type type, uint flags) {
444445
Vio *vio;
445446
MYSQL_SOCKET mysql_socket = MYSQL_INVALID_SOCKET;
446447
DBUG_TRACE;
447-
DBUG_PRINT("enter", ("sd: %d", sd));
448+
DBUG_PRINT("enter", ("sd: " MY_SOCKET_FMT, sd));
448449

449450
mysql_socket_setfd(&mysql_socket, sd);
450451
vio = mysql_socket_vio_new(mysql_socket, type, flags);

vio/viosocket.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ size_t vio_read_buff(Vio *vio, uchar *buf, size_t size) {
180180
size_t rc;
181181
#define VIO_UNBUFFERED_READ_MIN_SIZE 2048
182182
DBUG_TRACE;
183-
DBUG_PRINT("enter", ("sd: %d buf: %p size: %u",
183+
DBUG_PRINT("enter", ("sd: " MY_SOCKET_FMT " buf: %p size: %u",
184184
mysql_socket_getfd(vio->mysql_socket), buf, (uint)size));
185185

186186
if (vio->read_pos < vio->read_end) {
@@ -401,7 +401,7 @@ int vio_keepalive(Vio *vio, bool set_keep_alive) {
401401
uint opt = 0;
402402
DBUG_TRACE;
403403
DBUG_PRINT("enter",
404-
("sd: %d set_keep_alive: %d",
404+
("sd: " MY_SOCKET_FMT " set_keep_alive: %d",
405405
mysql_socket_getfd(vio->mysql_socket), (int)set_keep_alive));
406406
if (vio->type != VIO_TYPE_NAMEDPIPE) {
407407
if (set_keep_alive) opt = 1;

vio/viossl.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,8 @@ static int ssl_do(struct st_VioSSLFd *ptr, Vio *vio, long timeout,
643643
#endif
644644

645645
DBUG_TRACE;
646-
DBUG_PRINT("enter", ("ptr: %p, sd: %d ctx: %p", ptr, sd, ptr->ssl_context));
646+
DBUG_PRINT("enter", ("ptr: %p, sd: " MY_SOCKET_FMT " ctx: %p", ptr, sd,
647+
ptr->ssl_context));
647648

648649
if (!sslptr) {
649650
sslptr = &ssl;

0 commit comments

Comments
 (0)