Skip to content

Commit 2bd3469

Browse files
author
Tor Didriksen
committed
Bug#35599395 Change literal 0 to nullptr where appropriate [noclose windows]
Build with clang -Wzero-as-null-pointer-constant in Debug and RelWithDebInfo mode. The purpose was to clean up windows-only code. We also found issues with code used by all platforms, because we have: in /c/program files/llvm/lib/clang/16/include/stddef.h but on linux define NULL __null And the later did not trigger the warning in all cases. Change-Id: I41446b09a87b4986bed061d994b299717c87940b
1 parent 6f8a398 commit 2bd3469

File tree

154 files changed

+801
-766
lines changed

Some content is hidden

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

154 files changed

+801
-766
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,6 +2123,11 @@ INCLUDE(maintainer)
21232123
INCLUDE(msvc_cppcheck)
21242124
DO_MSVC_CPPCHECK()
21252125

2126+
IF(WIN32_CLANG AND CMAKE_BUILD_TYPE_UPPER STREQUAL "DEBUG")
2127+
# Not yet fixed for Debug code
2128+
STRING_APPEND(CMAKE_CXX_FLAGS " -Wno-format")
2129+
ENDIF()
2130+
21262131
IF(WITH_UNIT_TESTS)
21272132
ENABLE_TESTING()
21282133
INCLUDE(googletest)

client/base/abstract_program.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ my_option *Abstract_program::get_options_array() { return &this->m_options[0]; }
5353

5454
Abstract_program::Abstract_program()
5555
: m_debug_options(this), m_help_options(this) {
56-
this->add_providers(&this->m_help_options, &this->m_debug_options, NULL);
56+
this->add_providers(&this->m_help_options, &this->m_debug_options, nullptr);
5757
}
5858

5959
void Abstract_program::run(int argc, char **argv) {
@@ -97,7 +97,7 @@ void Abstract_program::init_name(char *name_from_cmd_line) {
9797
char *name;
9898

9999
char name_buf[FN_REFLEN];
100-
if (GetModuleFileName(NULL, name_buf, FN_REFLEN) != 0) {
100+
if (GetModuleFileName(nullptr, name_buf, FN_REFLEN) != 0) {
101101
name = name_buf;
102102
} else {
103103
name = name_from_cmd_line;

client/check/mysqlcheck.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static const char *opt_skip_database = "";
7575
static uint opt_zstd_compress_level = default_zstd_compression_level;
7676
static char *opt_compress_algorithm = nullptr;
7777
#if defined(_WIN32)
78-
static char *shared_memory_base_name = 0;
78+
static char *shared_memory_base_name = nullptr;
7979
#endif
8080
static uint opt_protocol = 0;
8181
static char *opt_bind_addr = nullptr;
@@ -187,8 +187,8 @@ static struct my_option my_long_options[] = {
187187
NO_ARG, 0, 0, 0, nullptr, 0, nullptr},
188188
#include "multi_factor_passwordopt-longopts.h"
189189
#ifdef _WIN32
190-
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
191-
NO_ARG, 0, 0, 0, 0, 0, 0},
190+
{"pipe", 'W', "Use named pipes to connect to server.", nullptr, nullptr,
191+
nullptr, GET_NO_ARG, NO_ARG, 0, 0, 0, nullptr, 0, nullptr},
192192
#endif
193193
{"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
194194
&opt_plugin_dir, &opt_plugin_dir, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0,
@@ -219,8 +219,8 @@ static struct my_option my_long_options[] = {
219219
#if defined(_WIN32)
220220
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
221221
"Base name of shared memory.", &shared_memory_base_name,
222-
&shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0,
223-
0},
222+
&shared_memory_base_name, nullptr, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0,
223+
nullptr, 0, nullptr},
224224
#endif
225225
{"silent", 's', "Print only error messages.", &opt_silent, &opt_silent,
226226
nullptr, GET_BOOL, NO_ARG, 0, 0, 0, nullptr, 0, nullptr},

client/dump/row_group_dump_task.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void Row_group_dump_task::set_completed() {
3232
for (std::vector<Row *>::iterator it = m_rows.begin(); it != m_rows.end();
3333
++it) {
3434
delete *it;
35-
*it = NULL;
35+
*it = nullptr;
3636
}
3737

3838
Abstract_simple_dump_task::set_completed();

client/mysql.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ static uint opt_zstd_compress_level = default_zstd_compression_level;
240240
static char *opt_compress_algorithm = nullptr;
241241

242242
#if defined(_WIN32)
243-
static char *shared_memory_base_name = 0;
243+
static char *shared_memory_base_name = nullptr;
244244
#endif
245245
static uint opt_protocol = 0;
246246
static const CHARSET_INFO *charset_info = &my_charset_latin1;
@@ -1914,8 +1914,8 @@ static struct my_option my_long_options[] = {
19141914
#endif
19151915
#include "multi_factor_passwordopt-longopts.h"
19161916
#ifdef _WIN32
1917-
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
1918-
NO_ARG, 0, 0, 0, 0, 0, 0},
1917+
{"pipe", 'W', "Use named pipes to connect to server.", nullptr, nullptr,
1918+
nullptr, GET_NO_ARG, NO_ARG, 0, 0, 0, nullptr, 0, nullptr},
19191919
#endif
19201920
{"port", 'P',
19211921
"Port number to use for connection or 0 for default to, in "
@@ -1952,8 +1952,8 @@ static struct my_option my_long_options[] = {
19521952
#if defined(_WIN32)
19531953
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
19541954
"Base name of shared memory.", &shared_memory_base_name,
1955-
&shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0,
1956-
0},
1955+
&shared_memory_base_name, nullptr, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0,
1956+
nullptr, 0, nullptr},
19571957
#endif
19581958
{"socket", 'S', "The socket file to use for connection.",
19591959
&opt_mysql_unix_port, &opt_mysql_unix_port, nullptr, GET_STR_ALLOC,

client/mysql_secure_installation.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ static struct my_option my_connection_options[] = {
8080
nullptr, nullptr, nullptr, GET_PASSWORD, OPT_ARG, 0, 0, 0, nullptr, 0,
8181
nullptr},
8282
#ifdef _WIN32
83-
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
84-
NO_ARG, 0, 0, 0, 0, 0, 0},
83+
{"pipe", 'W', "Use named pipes to connect to server.", nullptr, nullptr,
84+
nullptr, GET_NO_ARG, NO_ARG, 0, 0, 0, nullptr, 0, nullptr},
8585
#endif
8686
{"port", 'P',
8787
"Port number to use for connection or 0 for default to, in "
@@ -98,8 +98,8 @@ static struct my_option my_connection_options[] = {
9898
#if defined(_WIN32)
9999
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
100100
"Base name of shared memory.", &shared_memory_base_name,
101-
&shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0,
102-
0},
101+
&shared_memory_base_name, nullptr, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0,
102+
nullptr, 0, nullptr},
103103
#endif
104104
{"socket", 'S', "Socket file to be used for connection.", &opt_socket,
105105
&opt_socket, nullptr, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, nullptr, 0,

client/mysqladmin.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static bool opt_show_warnings = false;
8383
static uint opt_zstd_compress_level = default_zstd_compression_level;
8484
static char *opt_compress_algorithm = nullptr;
8585
#if defined(_WIN32)
86-
static char *shared_memory_base_name = 0;
86+
static char *shared_memory_base_name = nullptr;
8787
#endif
8888
static uint opt_protocol = 0;
8989
static myf error_flags; /* flags to pass to my_printf_error, like ME_BELL */
@@ -236,8 +236,8 @@ static struct my_option my_long_options[] = {
236236
nullptr, GET_BOOL, NO_ARG, 0, 0, 0, nullptr, 0, nullptr},
237237
#include "multi_factor_passwordopt-longopts.h"
238238
#ifdef _WIN32
239-
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
240-
NO_ARG, 0, 0, 0, 0, 0, 0},
239+
{"pipe", 'W', "Use named pipes to connect to server.", nullptr, nullptr,
240+
nullptr, GET_NO_ARG, NO_ARG, 0, 0, 0, nullptr, 0, nullptr},
241241
#endif
242242
{"port", 'P',
243243
"Port number to use for connection or 0 for default to, in "
@@ -259,8 +259,8 @@ static struct my_option my_long_options[] = {
259259
#if defined(_WIN32)
260260
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
261261
"Base name of shared memory.", &shared_memory_base_name,
262-
&shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0,
263-
0},
262+
&shared_memory_base_name, nullptr, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0,
263+
nullptr, 0, nullptr},
264264
#endif
265265
{"silent", 's', "Silently exit if one can't connect to server.", nullptr,
266266
nullptr, nullptr, GET_NO_ARG, NO_ARG, 0, 0, 0, nullptr, 0, nullptr},

client/mysqlbinlog.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1949,7 +1949,8 @@ static struct my_option my_long_options[] = {
19491949
#if defined(_WIN32)
19501950
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
19511951
"Base name of shared memory.", &shared_memory_base_name,
1952-
&shared_memory_base_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
1952+
&shared_memory_base_name, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr,
1953+
0, nullptr},
19531954
#endif
19541955
{"short-form", 's',
19551956
"Just show regular queries: no extra info and no "

client/mysqldump.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static enum enum_set_gtid_purged_mode {
193193
} opt_set_gtid_purged_mode = SET_GTID_PURGED_AUTO;
194194

195195
#if defined(_WIN32)
196-
static char *shared_memory_base_name = 0;
196+
static char *shared_memory_base_name = nullptr;
197197
#endif
198198
static uint opt_protocol = 0;
199199
static char *opt_plugin_dir = nullptr, *opt_default_auth = nullptr;
@@ -524,8 +524,8 @@ static struct my_option my_long_options[] = {
524524
0, 0, nullptr, 0, nullptr},
525525
#include "multi_factor_passwordopt-longopts.h"
526526
#ifdef _WIN32
527-
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, nullptr,
528-
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
527+
{"pipe", 'W', "Use named pipes to connect to server.", nullptr, nullptr,
528+
nullptr, GET_NO_ARG, NO_ARG, 0, 0, 0, nullptr, 0, nullptr},
529529
#endif
530530
{"port", 'P', "Port number to use for connection.", &opt_mysql_port,
531531
&opt_mysql_port, nullptr, GET_UINT, REQUIRED_ARG, 0, 0, 0, nullptr, 0,
@@ -568,8 +568,8 @@ static struct my_option my_long_options[] = {
568568
#if defined(_WIN32)
569569
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
570570
"Base name of shared memory.", &shared_memory_base_name,
571-
&shared_memory_base_name, nullptr, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0,
572-
0, 0},
571+
&shared_memory_base_name, nullptr, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0,
572+
nullptr, 0, nullptr},
573573
#endif
574574
/*
575575
Note that the combination --single-transaction --master-data

client/mysqlimport.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static char *opt_compress_algorithm = nullptr;
8989
#include "multi_factor_passwordopt-vars.h"
9090
#include "sslopt-vars.h"
9191
#if defined(_WIN32)
92-
static char *shared_memory_base_name = 0;
92+
static char *shared_memory_base_name = nullptr;
9393
#endif
9494

9595
static struct my_option my_long_options[] = {
@@ -182,8 +182,8 @@ static struct my_option my_long_options[] = {
182182
nullptr},
183183
#include "multi_factor_passwordopt-longopts.h"
184184
#ifdef _WIN32
185-
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
186-
NO_ARG, 0, 0, 0, 0, 0, 0},
185+
{"pipe", 'W', "Use named pipes to connect to server.", nullptr, nullptr,
186+
nullptr, GET_NO_ARG, NO_ARG, 0, 0, 0, nullptr, 0, nullptr},
187187
#endif
188188
{"plugin_dir", OPT_PLUGIN_DIR, "Directory for client-side plugins.",
189189
&opt_plugin_dir, &opt_plugin_dir, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0,
@@ -206,8 +206,8 @@ static struct my_option my_long_options[] = {
206206
#if defined(_WIN32)
207207
{"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME,
208208
"Base name of shared memory.", &shared_memory_base_name,
209-
&shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0,
210-
0},
209+
&shared_memory_base_name, nullptr, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0,
210+
nullptr, 0, nullptr},
211211
#endif
212212
{"silent", 's', "Be more silent.", &silent, &silent, nullptr, GET_BOOL,
213213
NO_ARG, 0, 0, 0, nullptr, 0, nullptr},

0 commit comments

Comments
 (0)