Skip to content

Commit 79869f8

Browse files
author
Steinar H. Gunderson
committed
Bug #32907475: USE [[MAYBE_UNUSED]]
Use the C++17 attribute [[maybe_unused]] instead of our macro MY_ATTRIBUTE((unused)). This extends the support to e.g. MSVC. Change-Id: I9896c90847ed47111f2623d235f2f161ef54667f
1 parent 236ab55 commit 79869f8

File tree

517 files changed

+2537
-2669
lines changed

Some content is hidden

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

517 files changed

+2537
-2669
lines changed

client/base/abstract_program.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,10 @@ class Abstract_program : public Options::Composite_options_provider {
120120
Redirects call to option_parsed of main Abstract_program instance.
121121
If we have anonymous functions or binding this should be removed.
122122
*/
123-
static bool callback_option_parsed(
124-
int optid, const struct my_option *opt MY_ATTRIBUTE((unused)),
125-
char *argument);
123+
static bool callback_option_parsed(int optid,
124+
const struct my_option *opt
125+
[[maybe_unused]],
126+
char *argument);
126127

127128
Options::Debug_options m_debug_options;
128129
Options::Help_options m_help_options;

client/base/debug_options.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ void Debug_options::create_options() {
7777
#endif
7878
}
7979

80-
void Debug_options::debug_option_callback(
81-
char *argument MY_ATTRIBUTE((unused))) {
80+
void Debug_options::debug_option_callback(char *argument [[maybe_unused]]) {
8281
if (this->m_dbug_option.has_value()) {
8382
DBUG_PUSH(this->m_dbug_option.value().c_str());
8483
}

client/base/debug_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Debug_options : public Abstract_options_provider {
5858
void options_parsed() override;
5959

6060
private:
61-
void debug_option_callback(char *argument MY_ATTRIBUTE((unused)));
61+
void debug_option_callback(char *argument [[maybe_unused]]);
6262

6363
Abstract_program *m_program;
6464
bool m_debug_info_flag{false};

client/base/help_options.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ void Help_options::create_options() {
5555
std::bind(&Help_options::version_callback, this, _1)));
5656
}
5757

58-
void Help_options::help_callback(char *argument MY_ATTRIBUTE((unused))) {
58+
void Help_options::help_callback(char *argument [[maybe_unused]]) {
5959
this->print_usage();
6060
exit(0);
6161
}
6262

63-
void Help_options::version_callback(char *argument MY_ATTRIBUTE((unused))) {
63+
void Help_options::version_callback(char *argument [[maybe_unused]]) {
6464
this->print_version_line();
6565
exit(0);
6666
}

client/base/help_options.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ class Help_options : public Abstract_options_provider {
5858
virtual void print_usage();
5959

6060
private:
61-
void help_callback(char *argument MY_ATTRIBUTE((unused)));
62-
void version_callback(char *argument MY_ATTRIBUTE((unused)));
61+
void help_callback(char *argument [[maybe_unused]]);
62+
void version_callback(char *argument [[maybe_unused]]);
6363

6464
void print_version_line();
6565

client/base/mysql_connection_options.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,14 @@ const char *Mysql_connection_options::get_null_or_string(
232232
}
233233

234234
#ifdef _WIN32
235-
void Mysql_connection_options::pipe_protocol_callback(
236-
char *not_used MY_ATTRIBUTE((unused))) {
235+
void Mysql_connection_options::pipe_protocol_callback(char *not_used
236+
[[maybe_unused]]) {
237237
this->m_protocol = MYSQL_PROTOCOL_PIPE;
238238
}
239239
#endif
240240

241-
void Mysql_connection_options::protocol_callback(
242-
char *not_used MY_ATTRIBUTE((unused))) {
241+
void Mysql_connection_options::protocol_callback(char *not_used
242+
[[maybe_unused]]) {
243243
this->m_protocol = find_type_or_exit(this->m_protocol_string.value().c_str(),
244244
&sql_protocol_typelib, "protocol");
245245
}

client/base/mysql_connection_options.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ class Mysql_connection_options : public Composite_options_provider,
115115
*/
116116
void db_error(MYSQL *connection, const char *when);
117117
#ifdef _WIN32
118-
void pipe_protocol_callback(char *not_used MY_ATTRIBUTE((unused)));
118+
void pipe_protocol_callback(char *not_used [[maybe_unused]]);
119119
#endif
120-
void protocol_callback(char *not_used MY_ATTRIBUTE((unused)));
120+
void protocol_callback(char *not_used [[maybe_unused]]);
121121

122122
static bool mysql_inited;
123123

client/base/ssl_options.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ void Mysql_connection_options::Ssl_options::create_options() {
7171
this, _1)));
7272
}
7373

74-
void Mysql_connection_options::Ssl_options::ca_option_callback(
75-
char *argument MY_ATTRIBUTE((unused))) {
74+
void Mysql_connection_options::Ssl_options::ca_option_callback(char *argument [
75+
[maybe_unused]]) {
7676
if (!ssl_mode_set_explicitly) ::opt_ssl_mode = SSL_MODE_VERIFY_CA;
7777
}
7878

client/mysql.cc

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,8 +1959,7 @@ static void usage(int version) {
19591959
my_print_variables(my_long_options);
19601960
}
19611961

1962-
bool get_one_option(int optid,
1963-
const struct my_option *opt MY_ATTRIBUTE((unused)),
1962+
bool get_one_option(int optid, const struct my_option *opt [[maybe_unused]],
19641963
char *argument) {
19651964
switch (optid) {
19661965
case OPT_CHARSETS_DIR:
@@ -2747,9 +2746,8 @@ static void initialize_readline(char *name) {
27472746
array of matches, or NULL if there aren't any.
27482747
*/
27492748

2750-
static char **new_mysql_completion(const char *text,
2751-
int start MY_ATTRIBUTE((unused)),
2752-
int end MY_ATTRIBUTE((unused))) {
2749+
static char **new_mysql_completion(const char *text, int start [[maybe_unused]],
2750+
int end [[maybe_unused]]) {
27532751
if (!status.batch && !quick)
27542752
#if defined(USE_NEW_EDITLINE_INTERFACE)
27552753
return rl_completion_matches(text, new_command_generator);
@@ -3115,8 +3113,8 @@ static void print_help_item(MYSQL_ROW *cur, int num_name, int num_cat,
31153113
tee_fprintf(PAGER, " %s\n", (*cur)[num_name]);
31163114
}
31173115

3118-
static int com_server_help(String *buffer MY_ATTRIBUTE((unused)),
3119-
char *line MY_ATTRIBUTE((unused)), char *help_arg) {
3116+
static int com_server_help(String *buffer [[maybe_unused]],
3117+
char *line [[maybe_unused]], char *help_arg) {
31203118
MYSQL_ROW cur;
31213119
const char *server_cmd;
31223120
char cmd_buf[100 + 1];
@@ -3212,8 +3210,8 @@ static int com_server_help(String *buffer MY_ATTRIBUTE((unused)),
32123210
return error;
32133211
}
32143212

3215-
static int com_help(String *buffer MY_ATTRIBUTE((unused)),
3216-
char *line MY_ATTRIBUTE((unused))) {
3213+
static int com_help(String *buffer [[maybe_unused]],
3214+
char *line [[maybe_unused]]) {
32173215
int i, j;
32183216
char *help_arg = strchr(line, ' '), buff[32], *end;
32193217
if (help_arg) {
@@ -3253,14 +3251,14 @@ static int com_help(String *buffer MY_ATTRIBUTE((unused)),
32533251
}
32543252

32553253
/* ARGSUSED */
3256-
static int com_clear(String *buffer, char *line MY_ATTRIBUTE((unused))) {
3254+
static int com_clear(String *buffer, char *line [[maybe_unused]]) {
32573255
if (status.add_to_history) fix_line(buffer);
32583256
buffer->length(0);
32593257
return 0;
32603258
}
32613259

32623260
/* ARGSUSED */
3263-
static int com_charset(String *buffer MY_ATTRIBUTE((unused)), char *line) {
3261+
static int com_charset(String *buffer [[maybe_unused]], char *line) {
32643262
char buff[256], *param;
32653263
const CHARSET_INFO *new_cs;
32663264
strmake(buff, line, sizeof(buff) - 1);
@@ -3287,7 +3285,7 @@ static int com_charset(String *buffer MY_ATTRIBUTE((unused)), char *line) {
32873285
1 if fatal error
32883286
*/
32893287

3290-
static int com_go(String *buffer, char *line MY_ATTRIBUTE((unused))) {
3288+
static int com_go(String *buffer, char *line [[maybe_unused]]) {
32913289
char buff[200]; /* about 110 chars used so far */
32923290
char time_buff[52 + 3 + 1]; /* time max + space&parens + NUL */
32933291
MYSQL_RES *result;
@@ -3966,8 +3964,8 @@ static void print_tab_data(MYSQL_RES *result) {
39663964
}
39673965
}
39683966

3969-
static int com_tee(String *buffer MY_ATTRIBUTE((unused)),
3970-
char *line MY_ATTRIBUTE((unused))) {
3967+
static int com_tee(String *buffer [[maybe_unused]],
3968+
char *line [[maybe_unused]]) {
39713969
char file_name[FN_REFLEN], *end, *param;
39723970

39733971
while (my_isspace(charset_info, *line)) line++;
@@ -3999,8 +3997,8 @@ static int com_tee(String *buffer MY_ATTRIBUTE((unused)),
39993997
return 0;
40003998
}
40013999

4002-
static int com_notee(String *buffer MY_ATTRIBUTE((unused)),
4003-
char *line MY_ATTRIBUTE((unused))) {
4000+
static int com_notee(String *buffer [[maybe_unused]],
4001+
char *line [[maybe_unused]]) {
40044002
if (opt_outfile) end_tee();
40054003
tee_fprintf(stdout, "Outfile disabled.\n");
40064004
return 0;
@@ -4011,8 +4009,8 @@ static int com_notee(String *buffer MY_ATTRIBUTE((unused)),
40114009
*/
40124010

40134011
#ifdef USE_POPEN
4014-
static int com_pager(String *buffer MY_ATTRIBUTE((unused)),
4015-
char *line MY_ATTRIBUTE((unused))) {
4012+
static int com_pager(String *buffer [[maybe_unused]],
4013+
char *line [[maybe_unused]]) {
40164014
char pager_name[FN_REFLEN], *end, *param;
40174015

40184016
if (status.batch) return 0;
@@ -4046,8 +4044,8 @@ static int com_pager(String *buffer MY_ATTRIBUTE((unused)),
40464044
return 0;
40474045
}
40484046

4049-
static int com_nopager(String *buffer MY_ATTRIBUTE((unused)),
4050-
char *line MY_ATTRIBUTE((unused))) {
4047+
static int com_nopager(String *buffer [[maybe_unused]],
4048+
char *line [[maybe_unused]]) {
40514049
my_stpcpy(pager, "stdout");
40524050
opt_nopager = true;
40534051
PAGER = stdout;
@@ -4061,7 +4059,7 @@ static int com_nopager(String *buffer MY_ATTRIBUTE((unused)),
40614059
*/
40624060

40634061
#ifdef USE_POPEN
4064-
static int com_edit(String *buffer, char *line MY_ATTRIBUTE((unused))) {
4062+
static int com_edit(String *buffer, char *line [[maybe_unused]]) {
40654063
char filename[FN_REFLEN], buff[160];
40664064
int fd, tmp;
40674065
const char *editor;
@@ -4099,22 +4097,22 @@ static int com_edit(String *buffer, char *line MY_ATTRIBUTE((unused))) {
40994097

41004098
/* If arg is given, exit without errors. This happens on command 'quit' */
41014099

4102-
static int com_quit(String *buffer MY_ATTRIBUTE((unused)),
4103-
char *line MY_ATTRIBUTE((unused))) {
4100+
static int com_quit(String *buffer [[maybe_unused]],
4101+
char *line [[maybe_unused]]) {
41044102
status.exit_status = 0;
41054103
return 1;
41064104
}
41074105

4108-
static int com_rehash(String *buffer MY_ATTRIBUTE((unused)),
4109-
char *line MY_ATTRIBUTE((unused))) {
4106+
static int com_rehash(String *buffer [[maybe_unused]],
4107+
char *line [[maybe_unused]]) {
41104108
#ifdef HAVE_READLINE
41114109
build_completion_hash(true, false);
41124110
#endif
41134111
return 0;
41144112
}
41154113

4116-
static int com_shell(String *buffer MY_ATTRIBUTE((unused)),
4117-
char *line MY_ATTRIBUTE((unused))) {
4114+
static int com_shell(String *buffer [[maybe_unused]],
4115+
char *line [[maybe_unused]]) {
41184116
char *shell_cmd;
41194117

41204118
/* Skip space from line begin */
@@ -4134,7 +4132,7 @@ static int com_shell(String *buffer MY_ATTRIBUTE((unused)),
41344132
return 0;
41354133
}
41364134

4137-
static int com_print(String *buffer, char *line MY_ATTRIBUTE((unused))) {
4135+
static int com_print(String *buffer, char *line [[maybe_unused]]) {
41384136
tee_puts("--------------", stdout);
41394137
(void)tee_fputs(buffer->c_ptr(), stdout);
41404138
if (!buffer->length() || (*buffer)[buffer->length() - 1] != '\n')
@@ -4190,7 +4188,7 @@ static int com_connect(String *buffer, char *line) {
41904188
return error;
41914189
}
41924190

4193-
static int com_source(String *buffer MY_ATTRIBUTE((unused)), char *line) {
4191+
static int com_source(String *buffer [[maybe_unused]], char *line) {
41944192
char source_name[FN_REFLEN], *end, *param;
41954193
LINE_BUFFER *line_buff;
41964194
int error;
@@ -4236,7 +4234,7 @@ static int com_source(String *buffer MY_ATTRIBUTE((unused)), char *line) {
42364234
}
42374235

42384236
/* ARGSUSED */
4239-
static int com_delimiter(String *buffer MY_ATTRIBUTE((unused)), char *line) {
4237+
static int com_delimiter(String *buffer [[maybe_unused]], char *line) {
42404238
char buff[256], *tmp;
42414239

42424240
strmake(buff, line, sizeof(buff) - 1);
@@ -4259,7 +4257,7 @@ static int com_delimiter(String *buffer MY_ATTRIBUTE((unused)), char *line) {
42594257
}
42604258

42614259
/* ARGSUSED */
4262-
static int com_use(String *buffer MY_ATTRIBUTE((unused)), char *line) {
4260+
static int com_use(String *buffer [[maybe_unused]], char *line) {
42634261
char *tmp, buff[FN_REFLEN + 1];
42644262
int select_db;
42654263
uint warnings;
@@ -4386,22 +4384,21 @@ static int normalize_dbname(const char *line, char *buff, uint buff_size) {
43864384
return 0;
43874385
}
43884386

4389-
static int com_warnings(String *buffer MY_ATTRIBUTE((unused)),
4390-
char *line MY_ATTRIBUTE((unused))) {
4387+
static int com_warnings(String *buffer [[maybe_unused]],
4388+
char *line [[maybe_unused]]) {
43914389
show_warnings = true;
43924390
put_info("Show warnings enabled.", INFO_INFO);
43934391
return 0;
43944392
}
43954393

4396-
static int com_nowarnings(String *buffer MY_ATTRIBUTE((unused)),
4397-
char *line MY_ATTRIBUTE((unused))) {
4394+
static int com_nowarnings(String *buffer [[maybe_unused]],
4395+
char *line [[maybe_unused]]) {
43984396
show_warnings = false;
43994397
put_info("Show warnings disabled.", INFO_INFO);
44004398
return 0;
44014399
}
44024400

4403-
static int com_query_attributes(String *buffer MY_ATTRIBUTE((unused)),
4404-
char *line) {
4401+
static int com_query_attributes(String *buffer [[maybe_unused]], char *line) {
44054402
char buff[1024], *param, name[1024];
44064403
memset(buff, 0, sizeof(buff));
44074404
strmake(buff, line, sizeof(buff) - 1);
@@ -4728,8 +4725,8 @@ static int sql_connect(char *host, char *database, char *user, char *password,
47284725
}
47294726
}
47304727

4731-
static int com_status(String *buffer MY_ATTRIBUTE((unused)),
4732-
char *line MY_ATTRIBUTE((unused))) {
4728+
static int com_status(String *buffer [[maybe_unused]],
4729+
char *line [[maybe_unused]]) {
47334730
const char *status_str;
47344731
char buff[40];
47354732
ulonglong id;
@@ -5317,7 +5314,7 @@ static void get_current_os_sudouser() {
53175314
return;
53185315
}
53195316

5320-
static int com_prompt(String *buffer MY_ATTRIBUTE((unused)), char *line) {
5317+
static int com_prompt(String *buffer [[maybe_unused]], char *line) {
53215318
char *ptr = strchr(line, ' ');
53225319
prompt_counter = 0;
53235320
my_free(current_prompt);
@@ -5330,8 +5327,8 @@ static int com_prompt(String *buffer MY_ATTRIBUTE((unused)), char *line) {
53305327
return 0;
53315328
}
53325329

5333-
static int com_resetconnection(String *buffer MY_ATTRIBUTE((unused)),
5334-
char *line MY_ATTRIBUTE((unused))) {
5330+
static int com_resetconnection(String *buffer [[maybe_unused]],
5331+
char *line [[maybe_unused]]) {
53355332
int error;
53365333
global_attrs->clear(connected ? &mysql : nullptr);
53375334
error = mysql_reset_connection(&mysql);

client/mysql_config_editor.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,10 @@ static struct my_option my_help_command_options[] = {
237237
0, nullptr, 0, nullptr}};
238238

239239
extern "C" {
240-
static bool my_program_get_one_option(
241-
int optid, const struct my_option *opt MY_ATTRIBUTE((unused)),
242-
char *argument MY_ATTRIBUTE((unused))) {
240+
static bool my_program_get_one_option(int optid,
241+
const struct my_option *opt
242+
[[maybe_unused]],
243+
char *argument [[maybe_unused]]) {
243244
switch (optid) {
244245
case '#':
245246
DBUG_PUSH(argument ? argument : "d:t:o,/tmp/mysql_config_editor.trace");

0 commit comments

Comments
 (0)