Skip to content

Commit

Permalink
Fix -Wunused for CMAKE_BUILD_TYPE=RelWithDebInfo
Browse files Browse the repository at this point in the history
For release builds, do not declare unused variables.

unpack_row(): Omit a debug-only variable from WSREP diagnostic message.

create_wsrep_THD(): Fix -Wmaybe-uninitialized for the PSI_thread_key.
  • Loading branch information
dr-m committed Sep 30, 2019
1 parent bc70862 commit 46b7852
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 39 deletions.
10 changes: 4 additions & 6 deletions sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1186,12 +1186,9 @@ PSI_statement_info stmt_info_new_packet;
#endif

#ifndef EMBEDDED_LIBRARY
void net_before_header_psi(struct st_net *net, void *user_data, size_t /* unused: count */)
void net_before_header_psi(struct st_net *net, void *thd, size_t /* unused: count */)
{
THD *thd;
thd= static_cast<THD*> (user_data);
DBUG_ASSERT(thd != NULL);

DBUG_ASSERT(thd);
/*
We only come where when the server is IDLE, waiting for the next command.
Technically, it is a wait on a socket, which may take a long time,
Expand All @@ -1200,7 +1197,8 @@ void net_before_header_psi(struct st_net *net, void *user_data, size_t /* unused
Instead, start explicitly an IDLE event.
*/
MYSQL_SOCKET_SET_STATE(net->vio->mysql_socket, PSI_SOCKET_STATE_IDLE);
MYSQL_START_IDLE_WAIT(thd->m_idle_psi, &thd->m_idle_state);
MYSQL_START_IDLE_WAIT(static_cast<THD*>(thd)->m_idle_psi,
&static_cast<THD*>(thd)->m_idle_state);
}

void net_after_header_psi(struct st_net *net, void *user_data,
Expand Down
9 changes: 4 additions & 5 deletions sql/rpl_record.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright (c) 2007, 2013, Oracle and/or its affiliates.
Copyright (c) 2008, 2014, SkySQL Ab.
Copyright (c) 2008, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -318,7 +318,7 @@ unpack_row(rpl_group_info *rgi,
normal unpack operation.
*/
uint16 const metadata= tabledef->field_metadata(i);
uchar const *const old_pack_ptr= pack_ptr;
IF_DBUG(uchar const *const old_pack_ptr= pack_ptr;,)

pack_ptr= f->unpack(f->ptr, pack_ptr, row_end, metadata);
DBUG_PRINT("debug", ("field: %s; metadata: 0x%x;"
Expand All @@ -336,10 +336,9 @@ unpack_row(rpl_group_info *rgi,
Galera Node throws "Could not read field" error and drops out of cluster
*/
WSREP_WARN("ROW event unpack field: %s metadata: 0x%x;"
" pack_ptr: %p; conv_table %p conv_field %p table %s"
" conv_table %p conv_field %p table %s"
" row_end: %p",
f->field_name, metadata,
old_pack_ptr, conv_table, conv_field,
f->field_name, metadata, conv_table, conv_field,
(table_found) ? "found" : "not found", row_end
);
}
Expand Down
4 changes: 2 additions & 2 deletions sql/sql_parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8405,9 +8405,9 @@ bool st_select_lex::add_cross_joined_table(TABLE_LIST *left_op,

TABLE_LIST *tbl;
List<TABLE_LIST> *right_op_jl= right_op->join_list;
TABLE_LIST *r_tbl= right_op_jl->pop();
IF_DBUG(const TABLE_LIST *r_tbl=,) right_op_jl->pop();
DBUG_ASSERT(right_op == r_tbl);
TABLE_LIST *l_tbl= right_op_jl->pop();
IF_DBUG(const TABLE_LIST *l_tbl=,) right_op_jl->pop();
DBUG_ASSERT(left_op == l_tbl);
TABLE_LIST *cj_nest;

Expand Down
2 changes: 1 addition & 1 deletion sql/sql_partition_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ bool Sql_cmd_alter_table_exchange_partition::execute(THD *thd)
referenced from this structure will be modified.
@todo move these into constructor...
*/
HA_CREATE_INFO create_info(lex->create_info);
IF_DBUG(HA_CREATE_INFO create_info(lex->create_info);,)
Alter_info alter_info(lex->alter_info, thd->mem_root);
ulong priv_needed= ALTER_ACL | DROP_ACL | INSERT_ACL | CREATE_ACL;

Expand Down
4 changes: 2 additions & 2 deletions sql/sql_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10606,10 +10606,10 @@ bool Sql_cmd_create_table::execute(THD *thd)
{
DBUG_ENTER("Sql_cmd_create_table::execute");
LEX *lex= thd->lex;
TABLE_LIST *all_tables= lex->query_tables;
SELECT_LEX *select_lex= &lex->select_lex;
TABLE_LIST *first_table= select_lex->table_list.first;
DBUG_ASSERT(first_table == all_tables && first_table != 0);
DBUG_ASSERT(first_table == lex->query_tables);
DBUG_ASSERT(first_table != 0);
bool link_to_local;
TABLE_LIST *create_table= first_table;
TABLE_LIST *select_tables= lex->create_last_non_select_table->next_global;
Expand Down
4 changes: 2 additions & 2 deletions sql/sys_vars.ic
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright (c) 2002, 2011, Oracle and/or its affiliates.
Copyright (c) 2010, 2013, Monty Program Ab.
Copyright (c) 2010, 2019, MariaDB Corporation.

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -629,7 +629,7 @@ public:
/* parse and feel list with default values */
if (thd)
{
bool res=
IF_DBUG(bool res=,)
sysvartrack_validate_value(thd,
var->save_result.string_value.str,
var->save_result.string_value.length);
Expand Down
25 changes: 6 additions & 19 deletions sql/wsrep_thd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -420,25 +420,12 @@ static bool create_wsrep_THD(wsrep_thread_args* args)
{
mysql_mutex_lock(&LOCK_thread_count);
ulong old_wsrep_running_threads= wsrep_running_threads;
#ifdef HAVE_PSI_THREAD_INTERFACE
PSI_thread_key key;

switch (args->thread_type)
{
case WSREP_APPLIER_THREAD:
key= key_wsrep_applier;
break;
case WSREP_ROLLBACKER_THREAD:
key= key_wsrep_rollbacker;
break;
default:
assert(0);
break;
}
#endif

bool res= mysql_thread_create(key, &args->thread_id, &connection_attrib, start_wsrep_THD,
(void*)args);
DBUG_ASSERT(args->thread_type == WSREP_APPLIER_THREAD ||
args->thread_type == WSREP_ROLLBACKER_THREAD);
bool res= mysql_thread_create(args->thread_type == WSREP_APPLIER_THREAD
? key_wsrep_applier : key_wsrep_rollbacker,
&args->thread_id, &connection_attrib,
start_wsrep_THD, (void*)args);
/*
if starting a thread on server startup, wait until the this thread's THD
is fully initialized (otherwise a THD initialization code might
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/fil/fil0crypt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2308,8 +2308,8 @@ static void fil_crypt_rotation_list_fill()
/* Protect the tablespace while we may
release fil_system->mutex. */
space->n_pending_ops++;
fil_space_t* s= fil_system->read_page0(
space->id);
ut_d(const fil_space_t* s=)
fil_system->read_page0(space->id);
ut_ad(!s || s == space);
space->n_pending_ops--;
if (!space->size) {
Expand Down

0 comments on commit 46b7852

Please sign in to comment.