Skip to content

Commit

Permalink
MDEV-9998 Fix issues caught by Clang's -Wpointer-bool-conversion warning
Browse files Browse the repository at this point in the history
remove useless checks
and a couple of others
  • Loading branch information
vuvova committed May 15, 2017
1 parent f926428 commit 71b4503
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 37 deletions.
2 changes: 1 addition & 1 deletion libmysql/libmysql.c
Expand Up @@ -1405,7 +1405,7 @@ void set_stmt_errmsg(MYSQL_STMT *stmt, NET *net)
DBUG_ASSERT(stmt != 0);

stmt->last_errno= net->last_errno;
if (net->last_error && net->last_error[0])
if (net->last_error[0])
strmov(stmt->last_error, net->last_error);
strmov(stmt->sqlstate, net->sqlstate);

Expand Down
2 changes: 1 addition & 1 deletion sql/log.cc
Expand Up @@ -1294,7 +1294,7 @@ bool LOGGER::slow_log_print(THD *thd, const char *query, uint query_length,

/* fill in user_host value: the format is "%s[%s] @ %s [%s]" */
user_host_len= (strxnmov(user_host_buff, MAX_USER_HOST_SIZE,
sctx->priv_user ? sctx->priv_user : "", "[",
sctx->priv_user, "[",
sctx->user ? sctx->user : (thd->slave_thread ? "SQL_SLAVE" : ""), "] @ ",
sctx->host ? sctx->host : "", " [",
sctx->ip ? sctx->ip : "", "]", NullS) -
Expand Down
6 changes: 2 additions & 4 deletions sql/log_event_old.cc
Expand Up @@ -1681,8 +1681,7 @@ int Old_rows_log_event::do_apply_event(rpl_group_info *rgi)
default:
rli->report(ERROR_LEVEL, thd->net.last_errno, NULL,
"Error in %s event: row application failed. %s",
get_type_str(),
thd->net.last_error ? thd->net.last_error : "");
get_type_str(), thd->net.last_error);
thd->is_slave_error= 1;
break;
}
Expand Down Expand Up @@ -1721,8 +1720,7 @@ int Old_rows_log_event::do_apply_event(rpl_group_info *rgi)
"Error in %s event: error during transaction execution "
"on table %s.%s. %s",
get_type_str(), table->s->db.str,
table->s->table_name.str,
thd->net.last_error ? thd->net.last_error : "");
table->s->table_name.str, thd->net.last_error);

/*
If one day we honour --skip-slave-errors in row-based replication, and
Expand Down
5 changes: 2 additions & 3 deletions sql/slave.cc
Expand Up @@ -5647,8 +5647,7 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
TODO: handling `when' for SHOW SLAVE STATUS' snds behind
*/
if ((memcmp(mi->master_log_name, hb.get_log_ident(), hb.get_ident_len())
&& mi->master_log_name != NULL)
if (memcmp(mi->master_log_name, hb.get_log_ident(), hb.get_ident_len())
|| mi->master_log_pos > hb.log_pos)
{
/* missed events of heartbeat from the past */
Expand Down Expand Up @@ -6153,7 +6152,7 @@ static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi,
mysql_options(mysql, MYSQL_PLUGIN_DIR, opt_plugin_dir_ptr);

/* we disallow empty users */
if (mi->user == NULL || mi->user[0] == 0)
if (mi->user[0] == 0)
{
mi->report(ERROR_LEVEL, ER_SLAVE_FATAL_ERROR, NULL,
ER(ER_SLAVE_FATAL_ERROR),
Expand Down
6 changes: 0 additions & 6 deletions sql/sql_acl.cc
Expand Up @@ -10639,12 +10639,6 @@ void fill_effective_table_privileges(THD *thd, GRANT_INFO *grant,
/* global privileges */
grant->privilege= sctx->master_access;

if (!sctx->priv_user)
{
DBUG_PRINT("info", ("privilege 0x%lx", grant->privilege));
DBUG_VOID_RETURN; // it is slave
}

if (!thd->db || strcmp(db, thd->db))
{
/* db privileges */
Expand Down
3 changes: 1 addition & 2 deletions sql/sql_audit.cc
Expand Up @@ -369,8 +369,7 @@ int initialize_audit_plugin(st_plugin_int *plugin)
{
st_mysql_audit *data= (st_mysql_audit*) plugin->plugin->info;

if (!data->class_mask || !data->event_notify ||
!data->class_mask[0])
if (!data->event_notify || !data->class_mask[0])
{
sql_print_error("Plugin '%s' has invalid data.",
plugin->name.str);
Expand Down
2 changes: 1 addition & 1 deletion storage/connect/filamzip.cpp
Expand Up @@ -341,7 +341,7 @@ bool ZIPUTIL::OpenTable(PGLOBAL g, MODE mode, char *fn, bool append)
bool ZIPUTIL::addEntry(PGLOBAL g, char *entry)
{
//?? we dont need the stinking time
zip_fileinfo zi = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
zip_fileinfo zi = { {0, 0, 0, 0, 0, 0}, 0, 0, 0 };

getTime(zi.tmz_date);
target = entry;
Expand Down
2 changes: 1 addition & 1 deletion storage/connect/ha_connect.cc
Expand Up @@ -1192,7 +1192,7 @@ char *ha_connect::GetRealString(const char *s)
{
char *sv;

if (IsPartitioned() && s && partname && *partname) {
if (IsPartitioned() && s && *partname) {
sv= (char*)PlugSubAlloc(xp->g, NULL, 0);
sprintf(sv, s, partname);
PlugSubAlloc(xp->g, NULL, strlen(sv) + 1);
Expand Down
2 changes: 1 addition & 1 deletion storage/connect/tabext.h
Expand Up @@ -7,7 +7,7 @@
/***********************************************************************/

#ifndef __TABEXT_H
#define __TABEXTF_H
#define __TABEXT_H

#include "reldef.h"

Expand Down
5 changes: 2 additions & 3 deletions storage/innobase/dict/dict0dict.cc
Expand Up @@ -6251,6 +6251,7 @@ dict_set_corrupted_index_cache_only(
dict_table_t* table) /*!< in/out: table */
{
ut_ad(index != NULL);
ut_ad(table != NULL);
ut_ad(mutex_own(&dict_sys->mutex));
ut_ad(!dict_table_is_comp(dict_sys->sys_tables));
ut_ad(!dict_table_is_comp(dict_sys->sys_indexes));
Expand All @@ -6260,9 +6261,7 @@ dict_set_corrupted_index_cache_only(
if (dict_index_is_clust(index)) {
dict_table_t* corrupt_table;

corrupt_table = (table != NULL) ? table : index->table;
ut_ad((index->table != NULL) || (table != NULL)
|| index->table == table);
corrupt_table = table;

if (corrupt_table) {
corrupt_table->corrupted = TRUE;
Expand Down
11 changes: 5 additions & 6 deletions storage/innobase/handler/ha_innodb.cc
Expand Up @@ -2000,12 +2000,11 @@ innobase_get_stmt(
{
const char* query = NULL;
LEX_STRING *stmt = NULL;
if (thd) {
stmt = thd_query_string(thd);
if (stmt) {
*length = stmt->length;
query = stmt->str;
}
ut_ad(thd != NULL);
stmt = thd_query_string(thd);
if (stmt) {
*length = stmt->length;
query = stmt->str;
}
return (query);
}
Expand Down
2 changes: 1 addition & 1 deletion storage/sphinx/ha_sphinx.cc
Expand Up @@ -911,7 +911,7 @@ bool sphinx_show_status ( THD * thd )
}

// show last error or warning (either in addition to stats, or on their own)
if ( pTls && pTls->m_pHeadTable && pTls->m_pHeadTable->m_tStats.m_sLastMessage && pTls->m_pHeadTable->m_tStats.m_sLastMessage[0] )
if ( pTls && pTls->m_pHeadTable && pTls->m_pHeadTable->m_tStats.m_sLastMessage[0] )
{
const char * sMessageType = pTls->m_pHeadTable->m_tStats.m_bLastError ? "error" : "warning";

Expand Down
1 change: 0 additions & 1 deletion storage/spider/spd_table.cc
Expand Up @@ -517,7 +517,6 @@ int spider_free_share_alloc(
) {
int roop_count;
DBUG_ENTER("spider_free_share_alloc");
if (share->dbton_bitmap)
{
for (roop_count = SPIDER_DBTON_SIZE - 1; roop_count >= 0; roop_count--)
{
Expand Down
11 changes: 5 additions & 6 deletions storage/xtradb/handler/ha_innodb.cc
Expand Up @@ -2326,12 +2326,11 @@ innobase_get_stmt(
{
const char* query = NULL;
LEX_STRING *stmt = NULL;
if (thd) {
stmt = thd_query_string(thd);
if (stmt) {
*length = stmt->length;
query = stmt->str;
}
ut_ad(thd != NULL);
stmt = thd_query_string(thd);
if (stmt) {
*length = stmt->length;
query = stmt->str;
}
return (query);
}
Expand Down

0 comments on commit 71b4503

Please sign in to comment.