Bug #43414 Parenthesis (and other) warnings compiling MySQL

with gcc 4.3.2

Cleaning up warnings not present in 5.0.
This commit is contained in:
Staale Smedseng 2009-09-23 15:21:29 +02:00
parent 613297ff1e
commit 8b9843408d
30 changed files with 75 additions and 76 deletions

View File

@ -3561,7 +3561,7 @@ static void print_warnings()
messages. To be safe, skip printing the duplicate only if it is the only
warning.
*/
if (!cur || num_rows == 1 && error == (uint) strtoul(cur[1], NULL, 10))
if (!cur || (num_rows == 1 && error == (uint) strtoul(cur[1], NULL, 10)))
goto end;
/* Print the warnings */

View File

@ -423,6 +423,7 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr)
stats *sptr;
conclusions conclusion;
unsigned long long client_limit;
int sysret;
head_sptr= (stats *)my_malloc(sizeof(stats) * iterations,
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
@ -463,7 +464,9 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr)
run_query(mysql, "SET AUTOCOMMIT=0", strlen("SET AUTOCOMMIT=0"));
if (pre_system)
system(pre_system);
if ((sysret= system(pre_system)) != 0)
fprintf(stderr, "Warning: Execution of pre_system option returned %d.\n",
sysret);
/*
Pre statements are always run after all other logic so they can
@ -478,7 +481,9 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr)
run_statements(mysql, post_statements);
if (post_system)
system(post_system);
if ((sysret= system(post_system)) != 0)
fprintf(stderr, "Warning: Execution of post_system option returned %d.\n",
sysret);
/* We are finished with this run */
if (auto_generate_sql_autoincrement || auto_generate_sql_guid_primary)

View File

@ -465,10 +465,10 @@ rl_redisplay ()
int newlines, lpos, temp, modmark;
const char *prompt_this_line;
#if defined (HANDLE_MULTIBYTE)
int num, n0;
int num, n0= 0;
wchar_t wc;
size_t wc_bytes;
int wc_width;
int wc_width= 0;
mbstate_t ps;
int _rl_wrapped_multicolumn = 0;
#endif
@ -828,7 +828,7 @@ rl_redisplay ()
cpos_buffer_position = out;
lb_linenum = newlines;
}
for (i = in; i < in+wc_bytes; i++)
for (i = in; i < in+(int)wc_bytes; i++)
line[out++] = rl_line_buffer[i];
for (i = 0; i < wc_width; i++)
CHECK_LPOS();

View File

@ -441,7 +441,7 @@ public:
const Ciphers& GetCiphers() const;
const DH_Parms& GetDH_Parms() const;
const Stats& GetStats() const;
const VerifyCallback getVerifyCallback() const;
VerifyCallback getVerifyCallback() const;
pem_password_cb GetPasswordCb() const;
void* GetUserData() const;
bool GetSessionCacheOff() const;

View File

@ -1833,7 +1833,7 @@ SSL_CTX::GetCA_List() const
}
const VerifyCallback SSL_CTX::getVerifyCallback() const
VerifyCallback SSL_CTX::getVerifyCallback() const
{
return verifyCallback_;
}

View File

@ -137,13 +137,13 @@ extern FILE *_db_fp_(void);
#define DBUG_EVALUATE_IF(keyword,a1,a2) (a2)
#define DBUG_PRINT(keyword,arglist) do { } while(0)
#define DBUG_PUSH(a1)
#define DBUG_SET(a1)
#define DBUG_SET_INITIAL(a1)
#define DBUG_SET(a1) do { } while(0)
#define DBUG_SET_INITIAL(a1) do { } while(0)
#define DBUG_POP()
#define DBUG_PROCESS(a1)
#define DBUG_SETJMP(a1) setjmp(a1)
#define DBUG_LONGJMP(a1) longjmp(a1)
#define DBUG_DUMP(keyword,a1,a2)
#define DBUG_DUMP(keyword,a1,a2) do { } while(0)
#define DBUG_END()
#define DBUG_ASSERT(A) do { } while(0)
#define DBUG_LOCK_FILE

View File

@ -711,7 +711,7 @@ Event_db_repository::update_event(THD *thd, Event_parse_data *parse_data,
DBUG_ENTER("Event_db_repository::update_event");
/* None or both must be set */
DBUG_ASSERT(new_dbname && new_name || new_dbname == new_name);
DBUG_ASSERT((new_dbname && new_name) || new_dbname == new_name);
/* Reset sql_mode during data dictionary operations. */
thd->variables.sql_mode= 0;

View File

@ -1001,7 +1001,7 @@ static bool print_admin_msg(THD* thd, const char* msg_type,
if (!thd->vio_ok())
{
sql_print_error(msgbuf);
sql_print_error("%s", msgbuf);
return TRUE;
}

View File

@ -773,10 +773,10 @@ public:
if (m_handler_status < handler_initialized ||
m_handler_status >= handler_closed)
DBUG_RETURN(PARTITION_ENABLED_TABLE_FLAGS);
else
DBUG_RETURN((m_file[0]->ha_table_flags() &
~(PARTITION_DISABLED_TABLE_FLAGS)) |
(PARTITION_ENABLED_TABLE_FLAGS));
DBUG_RETURN((m_file[0]->ha_table_flags() &
~(PARTITION_DISABLED_TABLE_FLAGS)) |
(PARTITION_ENABLED_TABLE_FLAGS));
}
/*

View File

@ -3501,14 +3501,10 @@ int handler::index_next_same(uchar *buf, const uchar *key, uint keylen)
if (!(error=index_next(buf)))
{
my_ptrdiff_t ptrdiff= buf - table->record[0];
uchar *save_record_0;
KEY *key_info;
KEY_PART_INFO *key_part;
KEY_PART_INFO *key_part_end;
LINT_INIT(save_record_0);
LINT_INIT(key_info);
LINT_INIT(key_part);
LINT_INIT(key_part_end);
uchar *UNINIT_VAR(save_record_0);
KEY *UNINIT_VAR(key_info);
KEY_PART_INFO *UNINIT_VAR(key_part);
KEY_PART_INFO *UNINIT_VAR(key_part_end);
/*
key_cmp_if_same() compares table->record[0] against 'key'.

View File

@ -1344,15 +1344,11 @@ bool get_interval_value(Item *args,interval_type int_type,
String *str_value, INTERVAL *interval)
{
ulonglong array[5];
longlong value;
const char *str;
size_t length;
longlong UNINIT_VAR(value);
const char *UNINIT_VAR(str);
size_t UNINIT_VAR(length);
CHARSET_INFO *cs=str_value->charset();
LINT_INIT(value);
LINT_INIT(str);
LINT_INIT(length);
bzero((char*) interval,sizeof(*interval));
if ((int) int_type <= INTERVAL_MICROSECOND)
{

View File

@ -1354,7 +1354,7 @@ my_xpath_lex_scan(MY_XPATH *xpath,
MY_XPATH_LEX *lex, const char *beg, const char *end)
{
int ch, ctype, length;
for ( ; beg < end && *beg == ' ' ; beg++); // skip leading spaces
for ( ; beg < end && *beg == ' ' ; beg++) ; // skip leading spaces
lex->beg= beg;
if (beg >= end)
@ -1423,7 +1423,7 @@ my_xpath_lex_scan(MY_XPATH *xpath,
if (my_xdigit(ch)) // a sequence of digits
{
for ( ; beg < end && my_xdigit(*beg) ; beg++);
for ( ; beg < end && my_xdigit(*beg) ; beg++) ;
lex->end= beg;
lex->term= MY_XPATH_LEX_DIGITS;
return;
@ -1431,7 +1431,7 @@ my_xpath_lex_scan(MY_XPATH *xpath,
if (ch == '"' || ch == '\'') // a string: either '...' or "..."
{
for ( ; beg < end && *beg != ch ; beg++);
for ( ; beg < end && *beg != ch ; beg++) ;
if (beg < end)
{
lex->end= beg+1;

View File

@ -1245,8 +1245,8 @@ Old_rows_log_event::Old_rows_log_event(THD *thd_arg, TABLE *tbl_arg, ulong tid,
solution, to be able to terminate a started statement in the
binary log: the extraneous events will be removed in the future.
*/
DBUG_ASSERT(tbl_arg && tbl_arg->s && tid != ~0UL ||
!tbl_arg && !cols && tid == ~0UL);
DBUG_ASSERT((tbl_arg && tbl_arg->s && tid != ~0UL) ||
(!tbl_arg && !cols && tid == ~0UL));
if (thd_arg->options & OPTION_NO_FOREIGN_KEY_CHECKS)
set_flags(NO_FOREIGN_KEY_CHECKS_F);
@ -1409,7 +1409,7 @@ int Old_rows_log_event::do_add_row_data(uchar *row_data, size_t length)
#endif
DBUG_ASSERT(m_rows_buf <= m_rows_cur);
DBUG_ASSERT(!m_rows_buf || m_rows_end && m_rows_buf < m_rows_end);
DBUG_ASSERT(!m_rows_buf || (m_rows_end && m_rows_buf < m_rows_end));
DBUG_ASSERT(m_rows_cur <= m_rows_end);
/* The cast will always work since m_rows_cur <= m_rows_end */

View File

@ -3719,6 +3719,7 @@ static void end_ssl()
static int init_server_components()
{
FILE* reopen;
DBUG_ENTER("init_server_components");
/*
We need to call each of these following functions to ensure that
@ -3761,7 +3762,7 @@ static int init_server_components()
if (freopen(log_error_file, "a+", stdout))
#endif
{
freopen(log_error_file, "a+", stderr);
reopen= freopen(log_error_file, "a+", stderr);
setbuf(stderr, NULL);
}
}

View File

@ -483,10 +483,8 @@ static bool check_engine_condition(partition_element *p_elem,
{
DBUG_RETURN(TRUE);
}
else
{
DBUG_RETURN(FALSE);
}
DBUG_RETURN(FALSE);
}

View File

@ -33,10 +33,10 @@ Relay_log_info::Relay_log_info()
:Slave_reporting_capability("SQL"),
no_storage(FALSE), replicate_same_server_id(::replicate_same_server_id),
info_fd(-1), cur_log_fd(-1), save_temporary_tables(0),
cur_log_old_open_count(0), group_relay_log_pos(0), event_relay_log_pos(0),
#if HAVE_purify
is_fake(FALSE),
#endif
cur_log_old_open_count(0), group_relay_log_pos(0), event_relay_log_pos(0),
group_master_log_pos(0), log_space_total(0), ignore_log_space_limit(0),
last_master_timestamp(0), slave_skip_counter(0),
abort_pos_wait(0), slave_run_id(0), sql_thd(0),
@ -300,7 +300,7 @@ Failed to open the existing relay log info file '%s' (errno %d)",
DBUG_RETURN(error);
err:
sql_print_error(msg);
sql_print_error("%s", msg);
end_io_cache(&rli->info_file);
if (info_fd >= 0)
my_close(info_fd, MYF(0));

View File

@ -3349,7 +3349,7 @@ int set_var_init()
uint count= 0;
DBUG_ENTER("set_var_init");
for (sys_var *var=vars.first; var; var= var->next, count++);
for (sys_var *var=vars.first; var; var= var->next, count++) ;
if (hash_init(&system_variable_hash, system_charset_info, count, 0,
0, (hash_get_key) get_sys_var_length, 0, HASH_UNIQUE))
@ -4184,10 +4184,10 @@ bool sys_var_opt_readonly::update(THD *thd, set_var *var)
can cause to wait on a read lock, it's required for the client application
to unlock everything, and acceptable for the server to wait on all locks.
*/
if (result= close_cached_tables(thd, NULL, FALSE, TRUE, TRUE))
if ((result= close_cached_tables(thd, NULL, FALSE, TRUE, TRUE)))
goto end_with_read_lock;
if (result= make_global_read_lock_block_commit(thd))
if ((result= make_global_read_lock_block_commit(thd)))
goto end_with_read_lock;
/* Change the opt_readonly system variable, safe because the lock is held */
@ -4200,6 +4200,7 @@ end_with_read_lock:
}
#ifndef DBUG_OFF
/* even session variable here requires SUPER, because of -#o,file */
bool sys_var_thd_dbug::check(THD *thd, set_var *var)
{
@ -4226,6 +4227,8 @@ uchar *sys_var_thd_dbug::value_ptr(THD *thd, enum_var_type type, LEX_STRING *b)
DBUG_EXPLAIN(buf, sizeof(buf));
return (uchar*) thd->strdup(buf);
}
#endif /* DBUG_OFF */
#ifdef HAVE_EVENT_SCHEDULER
bool sys_var_event_scheduler::check(THD *thd, set_var *var)

View File

@ -621,6 +621,7 @@ public:
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base);
};
#ifndef DBUG_OFF
class sys_var_thd_dbug :public sys_var_thd
{
public:
@ -634,7 +635,7 @@ public:
void set_default(THD *thd, enum_var_type type) { DBUG_POP(); }
uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *b);
};
#endif /* DBUG_OFF */
/* some variables that require special handling */

View File

@ -1195,7 +1195,7 @@ err:
if (master_res)
mysql_free_result(master_res);
DBUG_ASSERT(err_code != 0);
mi->report(ERROR_LEVEL, err_code, err_buff);
mi->report(ERROR_LEVEL, err_code, "%s", err_buff);
DBUG_RETURN(1);
}
@ -2386,7 +2386,7 @@ static bool check_io_slave_killed(THD *thd, Master_info *mi, const char *info)
if (io_slave_killed(thd, mi))
{
if (info && global_system_variables.log_warnings)
sql_print_information(info);
sql_print_information("%s", info);
return TRUE;
}
return FALSE;
@ -2456,13 +2456,13 @@ static int try_to_reconnect(THD *thd, MYSQL *mysql, Master_info *mi,
}
else
{
sql_print_information(buf);
sql_print_information("%s", buf);
}
}
if (safe_reconnect(thd, mysql, mi, 1) || io_slave_killed(thd, mi))
{
if (global_system_variables.log_warnings)
sql_print_information(messages[SLAVE_RECON_MSG_KILLED_AFTER]);
sql_print_information("%s", messages[SLAVE_RECON_MSG_KILLED_AFTER]);
return 1;
}
return 0;
@ -2679,7 +2679,7 @@ slave. If the entry is correct, restart the server with a higher value of \
max_allowed_packet",
thd->variables.max_allowed_packet);
mi->report(ERROR_LEVEL, ER_NET_PACKET_TOO_LARGE,
ER(ER_NET_PACKET_TOO_LARGE));
"%s", ER(ER_NET_PACKET_TOO_LARGE));
goto err;
case ER_MASTER_FATAL_ERROR_READING_BINLOG:
mi->report(ERROR_LEVEL, ER_MASTER_FATAL_ERROR_READING_BINLOG,
@ -2690,7 +2690,7 @@ max_allowed_packet",
sql_print_error("\
Stopping slave I/O thread due to out-of-memory error from master");
mi->report(ERROR_LEVEL, ER_OUT_OF_RESOURCES,
ER(ER_OUT_OF_RESOURCES));
"%s", ER(ER_OUT_OF_RESOURCES));
goto err;
}
if (try_to_reconnect(thd, mysql, mi, &retry_count, suppress_warnings,
@ -3050,7 +3050,7 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME,
This function is reporting an error which was not reported
while executing exec_relay_log_event().
*/
rli->report(ERROR_LEVEL, thd->main_da.sql_errno(), errmsg);
rli->report(ERROR_LEVEL, thd->main_da.sql_errno(), "%s", errmsg);
}
else if (last_errno != thd->main_da.sql_errno())
{

View File

@ -383,7 +383,7 @@ static void debug_wait_for_kill(const char *info)
thd= current_thd;
prev_info= thd->proc_info;
thd->proc_info= info;
sql_print_information(info);
sql_print_information("%s", info);
while(!thd->killed)
my_sleep(1000);
thd->killed= THD::NOT_KILLED;

View File

@ -985,7 +985,7 @@ static void end_connection(THD *thd)
if (thd->user_connect)
decrease_user_connections(thd->user_connect);
if (thd->killed || net->error && net->vio != 0)
if (thd->killed || (net->error && net->vio != 0))
{
statistic_increment(aborted_threads,&LOCK_status);
}

View File

@ -1450,11 +1450,11 @@ cmp_db_names(const char *db1_name,
{
return
/* db1 is NULL and db2 is NULL */
!db1_name && !db2_name ||
(!db1_name && !db2_name) ||
/* db1 is not-NULL, db2 is not-NULL, db1 == db2. */
db1_name && db2_name &&
my_strcasecmp(system_charset_info, db1_name, db2_name) == 0;
(db1_name && db2_name &&
my_strcasecmp(system_charset_info, db1_name, db2_name) == 0);
}

View File

@ -7098,9 +7098,9 @@ static uint32 get_next_partition_via_walking(PARTITION_ITERATOR *part_iter)
longlong dummy;
field->store(part_iter->field_vals.cur++,
((Field_num*)field)->unsigned_flag);
if (part_iter->part_info->is_sub_partitioned() &&
if ((part_iter->part_info->is_sub_partitioned() &&
!part_iter->part_info->get_part_partition_id(part_iter->part_info,
&part_id, &dummy) ||
&part_id, &dummy)) ||
!part_iter->part_info->get_partition_id(part_iter->part_info,
&part_id, &dummy))
return part_id;

View File

@ -368,7 +368,7 @@ static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report)
if (report & REPORT_TO_USER)
my_error(ER_UDF_NO_PATHS, MYF(0));
if (report & REPORT_TO_LOG)
sql_print_error(ER(ER_UDF_NO_PATHS));
sql_print_error("%s", ER(ER_UDF_NO_PATHS));
DBUG_RETURN(0);
}
/* If this dll is already loaded just increase ref_count. */

View File

@ -3529,7 +3529,9 @@ static int get_schema_tables_record(THD *thd, TABLE_LIST *tables,
TABLE_SHARE *share= show_table->s;
handler *file= show_table->file;
handlerton *tmp_db_type= share->db_type();
#ifdef WITH_PARTITION_STORAGE_ENGINE
bool is_partitioned= FALSE;
#endif
if (share->tmp_table == SYSTEM_TMP_TABLE)
table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), cs);
else if (share->tmp_table)

View File

@ -147,7 +147,7 @@ static uint parse_name(TYPELIB *lib, const char **strpos, const char *end,
}
}
else
for (; pos != end && *pos != '=' && *pos !=',' ; pos++);
for (; pos != end && *pos != '=' && *pos !=',' ; pos++) ;
uint var_len= (uint) (pos - start);
/* Determine which flag it is */

View File

@ -522,8 +522,8 @@ int ha_archive::open(const char *name, int mode, uint open_options)
{
DBUG_RETURN(0);
}
else
DBUG_RETURN(rc);
DBUG_RETURN(rc);
}
@ -1575,10 +1575,8 @@ int ha_archive::check(THD* thd, HA_CHECK_OPT* check_opt)
share->crashed= FALSE;
DBUG_RETURN(HA_ADMIN_CORRUPT);
}
else
{
DBUG_RETURN(HA_ADMIN_OK);
}
DBUG_RETURN(HA_ADMIN_OK);
}
/*

View File

@ -1598,8 +1598,8 @@ int ha_tina::check(THD* thd, HA_CHECK_OPT* check_opt)
share->crashed= TRUE;
DBUG_RETURN(HA_ADMIN_CORRUPT);
}
else
DBUG_RETURN(HA_ADMIN_OK);
DBUG_RETURN(HA_ADMIN_OK);
}

View File

@ -392,7 +392,7 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking,
int save_errno;
uint idx;
uint child_nr;
uint key_parts;
uint UNINIT_VAR(key_parts);
uint min_keys;
my_bool bad_children= FALSE;
DBUG_ENTER("myrg_attach_children");
@ -409,7 +409,6 @@ int myrg_attach_children(MYRG_INFO *m_info, int handle_locking,
rc= 1;
errpos= 0;
file_offset= 0;
LINT_INIT(key_parts);
min_keys= 0;
child_nr= 0;
while ((myisam= (*callback)(callback_param)))

View File

@ -84,7 +84,7 @@ main(void)
unsigned char c= dst[k+l];
sprintf(buf, "%.2x ", (unsigned)c);
}
diag(buf);
diag("%s", buf);
}
diag("src length: %.8x, dst length: %.8x\n",
(uint) src_len, (uint) dst_len);