From 6c734c822122ce1045c91ef21eeef2f1fdec17d6 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Mon, 30 Aug 2021 16:10:52 +0300 Subject: Vanilla cleanup: DBUG_EVALUATE_IF() macro replaced by shorter form DBUG_IF() --- dbug/user.r | 14 ++++++++------ include/my_dbug.h | 5 +---- plugin/win_auth_client/handshake_client.cc | 2 +- sql/sql_table.h | 4 ++-- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/dbug/user.r b/dbug/user.r index 8d8a9ce6910..3740a60851c 100644 --- a/dbug/user.r +++ b/dbug/user.r @@ -785,18 +785,20 @@ EX:\fC .br DBUG_EVALUATE\ ("info", "ON", "OFF"));\fR .SP 1 -.LI DBUG_EVALUATE_IF\ -Works like DBUG_EVALUATE macro, but the second argument is -.B not -evaluated, if the keyword is not explicitly listed in -the 'd' flag. Like DBUG_EXECUTE_IF this could be used to conditionally execute +.LI DBUG_IF\ +Returns +.B 1 +if the keyword is explicitly listed in +the 'd' flag. Otherwise returns +.B 0 +Like DBUG_EXECUTE_IF this could be used to conditionally execute "dangerous" actions. .SP 1 EX:\fC .br if (prepare_transaction () || .br - DBUG_EVALUATE ("crashme", (DBUG_ABORT(), 0), 0) || + (DBUG_IF("crashme") && (DBUG_ABORT(), 0)) || .br commit_transaction () )\fR .SP 1 diff --git a/include/my_dbug.h b/include/my_dbug.h index 46101163d58..2afcb010e7c 100644 --- a/include/my_dbug.h +++ b/include/my_dbug.h @@ -102,9 +102,7 @@ extern int (*dbug_sanity)(void); do {if (_db_keyword_(0, (keyword), 1)) { a1 }} while(0) #define DBUG_EVALUATE(keyword,a1,a2) \ (_db_keyword_(0,(keyword), 0) ? (a1) : (a2)) -#define DBUG_EVALUATE_IF(keyword,a1,a2) \ - (_db_keyword_(0,(keyword), 1) ? (a1) : (a2)) -#define DBUG_IF(keyword) DBUG_EVALUATE_IF(keyword, 1, 0) +#define DBUG_IF(keyword) _db_keyword_(0, (keyword), 1) #define DBUG_PRINT(keyword,arglist) \ do if (_db_pargs_(__LINE__,keyword)) _db_doprnt_ arglist; while(0) @@ -174,7 +172,6 @@ extern void _db_suicide_(void); #define DBUG_EXECUTE(keyword,a1) do { } while(0) #define DBUG_EXECUTE_IF(keyword,a1) do { } while(0) #define DBUG_EVALUATE(keyword,a1,a2) (a2) -#define DBUG_EVALUATE_IF(keyword,a1,a2) (a2) #define DBUG_IF(keyword) 0 #define DBUG_PRINT(keyword,arglist) do { } while(0) #define DBUG_PUSH_EMPTY do { } while(0) diff --git a/plugin/win_auth_client/handshake_client.cc b/plugin/win_auth_client/handshake_client.cc index 28a228cc210..feeaae88d19 100644 --- a/plugin/win_auth_client/handshake_client.cc +++ b/plugin/win_auth_client/handshake_client.cc @@ -252,7 +252,7 @@ Blob Handshake_client::process_data(const Blob &data) static byte test_buf[2048]; if (m_round == 1 - && DBUG_EVALUATE_IF("winauth_first_packet_test", true, false)) + && DBUG_IF("winauth_first_packet_test")) { const char *env= getenv("TEST_PACKET_LENGTH"); size_t len= env ? atoi(env) : 0; diff --git a/sql/sql_table.h b/sql/sql_table.h index 963625c9583..83e88c82f0e 100644 --- a/sql/sql_table.h +++ b/sql/sql_table.h @@ -21,9 +21,9 @@ #include "m_string.h" // LEX_CUSTRING #define ERROR_INJECT_CRASH(code) \ - DBUG_EVALUATE_IF(code, (DBUG_SUICIDE(), 0), 0) + (DBUG_IF(code) && (DBUG_SUICIDE(), 0)) #define ERROR_INJECT_ERROR(code) \ - DBUG_EVALUATE_IF(code, (my_error(ER_UNKNOWN_ERROR, MYF(0)), TRUE), 0) + (DBUG_IF(code) && (my_error(ER_UNKNOWN_ERROR, MYF(0)), 1)) class Alter_info; class Alter_table_ctx; -- cgit v1.2.1