Skip to content

Commit 6889e5c

Browse files
author
Tor Didriksen
committed
Bug #32354435 BACKPORT TO 5.7: BUG #32216281 REMOVE DBUG_OFF AND DBUG_ASSERT
Replace DBUG_ASSERT() with assert(). These are semantically the same (DBUG_ASSERT() has been #defined to assert() for a long time), but nonstandard. Manually edited: dbug/user.r include/my_dbug.h libbinlogevents/include/wrapper_functions.h libmysql/authentication_win/common.h Everything else is automated: replace DBUG_ASSERT with assert, and re-indent each region according to appropriate C style in each source file. Change-Id: Ib56a4e1f9677c04227ddf618e03c67dee05b98a4
1 parent 29ecc44 commit 6889e5c

File tree

621 files changed

+9989
-10012
lines changed

Some content is hidden

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

621 files changed

+9989
-10012
lines changed

client/base/abstract_option.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License, version 2.0,
@@ -180,7 +180,7 @@ template<typename T_type> void
180180
Abstract_option<T_type>::set_option_changed_listener(
181181
I_option_changed_listener* listener)
182182
{
183-
DBUG_ASSERT(this->m_option_changed_listener == NULL);
183+
assert(this->m_option_changed_listener == NULL);
184184

185185
this->m_option_changed_listener= listener;
186186
}

client/base/abstract_options_provider.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License, version 2.0,
@@ -154,7 +154,7 @@ Abstract_options_provider::~Abstract_options_provider()
154154

155155
void Abstract_options_provider::set_option_changed_listener(I_option_changed_listener* listener)
156156
{
157-
DBUG_ASSERT(this->m_option_changed_listener == NULL);
157+
assert(this->m_option_changed_listener == NULL);
158158
this->m_option_changed_listener= listener;
159159
}
160160

client/base/composite_options_provider.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License, version 2.0,
@@ -33,7 +33,7 @@ using namespace Mysql::Tools::Base::Options;
3333
void Composite_options_provider::add_providers(
3434
I_options_provider* first, ...)
3535
{
36-
DBUG_ASSERT(this->m_options_providers.size() == 0);
36+
assert(this->m_options_providers.size() == 0);
3737

3838
va_list options_to_add;
3939
va_start(options_to_add, first);

client/mysql.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2020, Oracle and/or its affiliates.
2+
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License, version 2.0,
@@ -2468,7 +2468,7 @@ static COMMANDS *find_command(char *name)
24682468
char *end;
24692469
DBUG_ENTER("find_command");
24702470

2471-
DBUG_ASSERT(name != NULL);
2471+
assert(name != NULL);
24722472
DBUG_PRINT("enter", ("name: '%s'", name));
24732473

24742474
while (my_isspace(charset_info, *name))
@@ -4103,7 +4103,7 @@ static int get_result_width(MYSQL_RES *result)
41034103

41044104
#ifndef DBUG_OFF
41054105
offset= mysql_field_tell(result);
4106-
DBUG_ASSERT(offset == 0);
4106+
assert(offset == 0);
41074107
#else
41084108
offset= 0;
41094109
#endif

client/mysql_secure_installation.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License, version 2.0,
@@ -944,7 +944,7 @@ int main(int argc,char *argv[])
944944
if ((rc= my_handle_options(&argc, &argv, my_connection_options,
945945
my_arguments_get_one_option, NULL, TRUE)))
946946
{
947-
DBUG_ASSERT(0);
947+
assert(0);
948948
}
949949

950950
init_connection_options(&mysql);

client/mysqladmin.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License, version 2.0,
@@ -910,7 +910,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
910910
return -1;
911911
}
912912

913-
DBUG_ASSERT(mysql_num_rows(res) < MAX_MYSQL_VAR);
913+
assert(mysql_num_rows(res) < MAX_MYSQL_VAR);
914914

915915
if (!opt_vertical)
916916
print_header(res);

client/mysqlbinlog.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License, version 2.0,
@@ -111,7 +111,7 @@ rewrite_db(char **buf, ulong *buf_size,
111111
if (new_db_it == map_mysqlbinlog_rewrite_db.end())
112112
return false;
113113
const char *new_db=new_db_it->second.c_str();
114-
DBUG_ASSERT(new_db && new_db != old_db);
114+
assert(new_db && new_db != old_db);
115115

116116
size_t new_db_len= strlen(new_db);
117117

@@ -2336,7 +2336,7 @@ static Exit_status dump_single_log(PRINT_EVENT_INFO *print_event_info,
23362336
rc= dump_remote_log_entries(print_event_info, logname);
23372337
break;
23382338
default:
2339-
DBUG_ASSERT(0);
2339+
assert(0);
23402340
break;
23412341
}
23422342
DBUG_RETURN(rc);
@@ -2605,7 +2605,7 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
26052605
ptr_buffer+= BINLOG_NAME_INFO_SIZE;
26062606

26072607
command_size= ptr_buffer - command_buffer;
2608-
DBUG_ASSERT(command_size == (allocation_size - 1));
2608+
assert(command_size == (allocation_size - 1));
26092609
}
26102610
else
26112611
{
@@ -2647,7 +2647,7 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
26472647
global_sid_lock->unlock();
26482648

26492649
command_size= ptr_buffer - command_buffer;
2650-
DBUG_ASSERT(command_size == (allocation_size - 1));
2650+
assert(command_size == (allocation_size - 1));
26512651
}
26522652

26532653
if (simple_command(mysql, command, command_buffer, command_size, 1))
@@ -2834,7 +2834,7 @@ static Exit_status dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info,
28342834

28352835
if (type == binary_log::LOAD_EVENT)
28362836
{
2837-
DBUG_ASSERT(raw_mode);
2837+
assert(raw_mode);
28382838
warning("Attempting to load a remote pre-4.0 binary log that contains "
28392839
"LOAD DATA INFILE statements. The file will not be copied from "
28402840
"the remote server. ");

client/mysqldump.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License, version 2.0,
@@ -942,7 +942,7 @@ get_one_option(int optid, const struct my_option *opt MY_ATTRIBUTE((unused)),
942942
for (ptr= compatible_mode_names; *ptr; ptr++)
943943
size_for_sql_mode+= strlen(*ptr);
944944
size_for_sql_mode+= sizeof(compatible_mode_names)-1;
945-
DBUG_ASSERT(sizeof(compatible_mode_normal_str)>=size_for_sql_mode);
945+
assert(sizeof(compatible_mode_normal_str)>=size_for_sql_mode);
946946
}
947947
#endif
948948
mode= opt_compatible_mode;
@@ -1976,7 +1976,7 @@ static void print_xml_tag(FILE * xml_file, const char* sbeg,
19761976
while (attribute_name != NullS)
19771977
{
19781978
attribute_value= va_arg(arg_list, char *);
1979-
DBUG_ASSERT(attribute_value != NullS);
1979+
assert(attribute_value != NullS);
19801980

19811981
fputc(' ', xml_file);
19821982
fputs(attribute_name, xml_file);
@@ -4060,9 +4060,9 @@ static void dump_table(char *table, char *db)
40604060
extended_row.length+= mysql_hex_string(extended_row.str +
40614061
extended_row.length,
40624062
row[i], length);
4063-
DBUG_ASSERT(extended_row.length+1 <= extended_row.max_length);
4063+
assert(extended_row.length+1 <= extended_row.max_length);
40644064
/* mysql_hex_string() already terminated string by '\0' */
4065-
DBUG_ASSERT(extended_row.str[extended_row.length] == '\0');
4065+
assert(extended_row.str[extended_row.length] == '\0');
40664066
}
40674067
else
40684068
{
@@ -4665,7 +4665,7 @@ static int dump_all_databases()
46654665
db_cnt++;
46664666
}
46674667
}
4668-
DBUG_ASSERT(mysql_db_found);
4668+
assert(mysql_db_found);
46694669
memset(database_list, 0, sizeof(*database_list));
46704670
my_free(database_list);
46714671

@@ -5107,7 +5107,7 @@ static char *get_actual_table_name(const char *old_table_name, MEM_ROOT *root)
51075107
DBUG_ENTER("get_actual_table_name");
51085108

51095109
/* Check memory for quote_for_like() */
5110-
DBUG_ASSERT(2*sizeof(old_table_name) < sizeof(show_name_buff));
5110+
assert(2*sizeof(old_table_name) < sizeof(show_name_buff));
51115111
my_snprintf(query, sizeof(query), "SHOW TABLES LIKE %s",
51125112
quote_for_like(old_table_name, show_name_buff));
51135113

@@ -5670,7 +5670,7 @@ char check_if_ignore_table(const char *table_name, char *table_type)
56705670
DBUG_ENTER("check_if_ignore_table");
56715671

56725672
/* Check memory for quote_for_like() */
5673-
DBUG_ASSERT(2*sizeof(table_name) < sizeof(show_name_buff));
5673+
assert(2*sizeof(table_name) < sizeof(show_name_buff));
56745674
my_snprintf(buff, sizeof(buff), "show table status like %s",
56755675
quote_for_like(table_name, show_name_buff));
56765676
if (mysql_query_with_error_report(mysql, &res, buff))

client/mysqlslap.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License, version 2.0,
@@ -1990,13 +1990,13 @@ extern "C" void *run_task(void *p)
19901990
Just in case someone runs this under an experimental engine we don't
19911991
want a crash so the if() is placed here.
19921992
*/
1993-
DBUG_ASSERT(primary_keys_number_of);
1993+
assert(primary_keys_number_of);
19941994
if (primary_keys_number_of)
19951995
{
19961996
key_val= (unsigned int)(random() % primary_keys_number_of);
19971997
key= primary_keys[key_val];
19981998

1999-
DBUG_ASSERT(key);
1999+
assert(key);
20002000

20012001
length= snprintf(buffer, HUGE_STRING_LENGTH, "%.*s '%s'",
20022002
(int)ptr->length, ptr->string, key);

client/mysqltest.cc

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2020, Oracle and/or its affiliates.
1+
/* Copyright (c) 2000, 2021, Oracle and/or its affiliates.
22

33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -754,11 +754,11 @@ class LogFile {
754754
void write(DYNAMIC_STRING* ds)
755755
{
756756
DBUG_ENTER("LogFile::write");
757-
DBUG_ASSERT(m_file);
757+
assert(m_file);
758758

759759
if (ds->length == 0)
760760
DBUG_VOID_RETURN;
761-
DBUG_ASSERT(ds->str);
761+
assert(ds->str);
762762

763763
if (fwrite(ds->str, 1, ds->length, m_file) != ds->length)
764764
die("Failed to write %lu bytes to '%s', errno: %d",
@@ -919,7 +919,7 @@ extern "C" void *connection_thread(void *arg)
919919
cn->result= mysql_read_query_result(&cn->mysql);
920920
break;
921921
default:
922-
DBUG_ASSERT(0);
922+
assert(0);
923923
}
924924
cn->command= 0;
925925
native_mutex_lock(&cn->result_mutex);
@@ -937,7 +937,7 @@ extern "C" void *connection_thread(void *arg)
937937

938938
static void wait_query_thread_done(struct st_connection *con)
939939
{
940-
DBUG_ASSERT(con->has_thread);
940+
assert(con->has_thread);
941941
if (!con->query_done)
942942
{
943943
native_mutex_lock(&con->result_mutex);
@@ -950,7 +950,7 @@ static void wait_query_thread_done(struct st_connection *con)
950950

951951
static void signal_connection_thd(struct st_connection *cn, int command)
952952
{
953-
DBUG_ASSERT(cn->has_thread);
953+
assert(cn->has_thread);
954954
cn->query_done= 0;
955955
cn->command= command;
956956
native_mutex_lock(&cn->query_mutex);
@@ -978,7 +978,7 @@ static int do_send_query(struct st_connection *cn, const char *q, size_t q_len)
978978

979979
static int do_read_query_result(struct st_connection *cn)
980980
{
981-
DBUG_ASSERT(cn->has_thread);
981+
assert(cn->has_thread);
982982
wait_query_thread_done(cn);
983983
signal_connection_thd(cn, EMB_READ_QUERY_RESULT);
984984
wait_query_thread_done(cn);
@@ -1302,7 +1302,7 @@ void check_command_args(struct st_command *command,
13021302
break;
13031303

13041304
default:
1305-
DBUG_ASSERT("Unknown argument type");
1305+
assert("Unknown argument type");
13061306
break;
13071307
}
13081308

@@ -1491,7 +1491,7 @@ static void cleanup_and_exit(int exit_code)
14911491
break;
14921492
default:
14931493
printf("unknown exit code: %d\n", exit_code);
1494-
DBUG_ASSERT(0);
1494+
assert(0);
14951495
}
14961496
}
14971497

@@ -2110,7 +2110,7 @@ void check_result()
21102110
const char* mess= "Result content mismatch\n";
21112111

21122112
DBUG_ENTER("check_result");
2113-
DBUG_ASSERT(result_file_name);
2113+
assert(result_file_name);
21142114
DBUG_PRINT("enter", ("result_file_name: %s", result_file_name));
21152115

21162116
switch (compare_files(log_file.file_name(), result_file_name)) {
@@ -2428,7 +2428,7 @@ void var_set(const char *var_name, const char *var_name_end,
24282428
v->str_val_len= strlen(v->str_val);
24292429
}
24302430
/* setenv() expects \0-terminated strings */
2431-
DBUG_ASSERT(v->name[v->name_len] == 0);
2431+
assert(v->name[v->name_len] == 0);
24322432
setenv(v->name, v->str_val, 1);
24332433
}
24342434
DBUG_VOID_RETURN;
@@ -7278,7 +7278,7 @@ get_one_option(int optid, const struct my_option *opt, char *argument)
72787278
argument= buff;
72797279
}
72807280
fn_format(buff, argument, "", "", MY_UNPACK_FILENAME);
7281-
DBUG_ASSERT(cur_file == file_stack && cur_file->file == 0);
7281+
assert(cur_file == file_stack && cur_file->file == 0);
72827282
if (!(cur_file->file=
72837283
fopen(buff, "rb")))
72847284
die("Could not open '%s' for reading, errno: %d", buff, errno);
@@ -7902,7 +7902,7 @@ int append_warnings(DYNAMIC_STRING *ds, MYSQL* mysql)
79027902
through PS API we should not issue SHOW WARNINGS until
79037903
we have not read all results...
79047904
*/
7905-
DBUG_ASSERT(!mysql_more_results(mysql));
7905+
assert(!mysql_more_results(mysql));
79067906

79077907
if (mysql_real_query(mysql, "SHOW WARNINGS", 13))
79087908
die("Error running query \"SHOW WARNINGS\": %s", mysql_error(mysql));
@@ -8043,7 +8043,7 @@ void run_query_normal(struct st_connection *cn, struct st_command *command,
80438043
mysql_sqlstate(mysql), ds);
80448044
goto end;
80458045
}
8046-
DBUG_ASSERT(err == -1); /* Successful and there are no more results */
8046+
assert(err == -1); /* Successful and there are no more results */
80478047

80488048
/* If we come here the query is both executed and read successfully */
80498049
handle_no_error(command);
@@ -10301,7 +10301,7 @@ void replace_strings_append(REPLACE *rep, DYNAMIC_STRING* ds,
1030110301
DBUG_PRINT("exit", ("Found end of from string"));
1030210302
DBUG_VOID_RETURN;
1030310303
}
10304-
DBUG_ASSERT(from <= str+len);
10304+
assert(from <= str+len);
1030510305
start= from;
1030610306
rep_pos=rep;
1030710307
}

dbug/user.r

-8
Original file line numberDiff line numberDiff line change
@@ -867,14 +867,6 @@ EX:\fC
867867
.SP 1
868868
.LI DBUG_UNLOCK_FILE\
869869
Unlocks DBUG_FILE stream, that was locked with a DBUG_LOCK_FILE.
870-
.LI DBUG_ASSERT\
871-
This macro just does a regular assert(). The difference is that it will be
872-
disabled by DBUG_OFF togeher with the
873-
.I dbug
874-
library. So there will be no need to disable asserts separately with NDEBUG.
875-
.SP 1
876-
EX:\ \fCDBUG_ASSERT(\ a\ >\ 0\ );\fR
877-
.SP 1
878870
.LI DBUG_ABORT\
879871
This macro could be used instead of abort(). It flushes DBUG_FILE stream
880872
to ensure that no

0 commit comments

Comments
 (0)